找到分位数回归模型的伪R平方。

huangapple go评论104阅读模式
英文:

Find Pseudo R-squared for quantile regression models

问题

I have tried to implement quantile regression for the Boston dataset.

  1. library(MASS)
  2. data(Boston)
  3. attach(Boston)
  4. qr_res_0.9 <- rq(medv ~ lstat + rm + crim + dis,
  5. tau = 0.9,
  6. data = Boston)

Now, results of model summary is shown below

  1. summary(qr_res_0.9,se="boot")
  2. ##
  3. ## Call: rq(formula = medv ~ lstat + rm + crim + dis, tau = 0.9, data = Boston)
  4. ##
  5. ## tau: [1] 0.9
  6. ##
  7. ## Coefficients:
  8. ## Value Std. Error t value Pr(>|t|)
  9. ## (Intercept) -20.75975 13.81979 -1.50218 0.13368
  10. ## lstat -0.25857 0.22411 -1.15378 0.24914
  11. ## rm 9.01335 1.58000 5.70464 0.00000
  12. ## crim -0.04028 0.11367 -0.35440 0.72319
  13. ## dis -0.94489 0.29403 -3.21355 0.00140

This does not include Psuedo R-squared/McFadden R-squared value? How can I estimate this?

What I have tried?

Referring to the discussion in https://stackoverflow.com/questions/19861194/extract-r2-from-quantile-regression-summary

I have implemented the following

  1. rho <- function(u, tau = 0.5) u * (tau - (u < 0))
  2. V <- sum(rho(qr_res_0.9$resid, qr_res_0.9$tau))
  3. V
  4. ## [1] 558.4133

The R-squared should be between 0 to 1?

英文:

I have tried to implement quantile regression for the Boston dataset.

  1. library(MASS)
  2. data(Boston)
  3. attach(Boston)
  4. qr_res_0.9 &lt;- rq(medv ~ lstat + rm + crim + dis,
  5. tau = 0.9,
  6. data = Boston)

Now, results of model summary is shown below

  1. summary(qr_res_0.9,se=&quot;boot&quot;)
  2. ##
  3. ## Call: rq(formula = medv ~ lstat + rm + crim + dis, tau = 0.9, data = Boston)
  4. ##
  5. ## tau: [1] 0.9
  6. ##
  7. ## Coefficients:
  8. ## Value Std. Error t value Pr(&gt;|t|)
  9. ## (Intercept) -20.75975 13.81979 -1.50218 0.13368
  10. ## lstat -0.25857 0.22411 -1.15378 0.24914
  11. ## rm 9.01335 1.58000 5.70464 0.00000
  12. ## crim -0.04028 0.11367 -0.35440 0.72319
  13. ## dis -0.94489 0.29403 -3.21355 0.00140

This does not include Psuedo R-squared/McFadden R-squared value? How can I estimate this?

What I have tried?

Referring to the discussion in https://stackoverflow.com/questions/19861194/extract-r2-from-quantile-regression-summary

I have implemented the following

  1. rho &lt;- function(u,tau=.5)u*(tau - (u &lt; 0))
  2. V &lt;- sum(rho(qr_res_0.9$resid, qr_res_0.9$tau))
  3. V
  4. ## [1] 558.4133

The R-squared should be between 0 to 1?

答案1

得分: 1

以下是翻译的内容:

显然,您正在尝试计算Koenker和Machado R1:

链接:https://stats.stackexchange.com/a/129246/11849

  1. library(MASS)
  2. library(quantreg)
  3. data(Boston)
  4. # 不要使用 `attach`
  5. qr_res_0.9 <- rq(medv ~ lstat + rm + crim + dis,
  6. tau = 0.9,
  7. data = Boston)
  8. qr_res_0.9_0 <- rq(medv ~ 1,
  9. tau = 0.9,
  10. data = Boston)
  11. rho <- function(u, tau = 0.5) u * (tau - (u < 0))
  12. Vhat <- sum(rho(qr_res_0.9$resid, qr_res_0.9$tau))
  13. V0 <- sum(rho(qr_res_0.9_0$resid, qr_res_0.9_0$tau))
  14. R1 <- 1 - Vhat / V0
  15. #[1] 0.4659297

从链接的回答中:

我认为R^2的概念不太适用于分位数回归。您可以定义各种更或少类似的量,如此处所示,但无论您选择什么,都不会具有OLS回归中真实R^2的大多数属性。

英文:

Apparently, you are trying to calculate the Koenker and Machado R1:

https://stats.stackexchange.com/a/129246/11849

  1. library(MASS)
  2. library(quantreg)
  3. data(Boston)
  4. #don&#39;t use `attach`
  5. qr_res_0.9 &lt;- rq(medv ~ lstat + rm + crim + dis,
  6. tau = 0.9,
  7. data = Boston)
  8. qr_res_0.9_0 &lt;- rq(medv ~ 1,
  9. tau = 0.9,
  10. data = Boston)
  11. rho &lt;- function(u,tau=.5)u*(tau - (u &lt; 0))
  12. Vhat &lt;- sum(rho(qr_res_0.9$resid, qr_res_0.9$tau))
  13. V0 &lt;- sum(rho(qr_res_0.9_0$resid, qr_res_0.9_0$tau))
  14. R1 &lt;- 1-Vhat/V0
  15. #[1] 0.4659297

From the linked answer:

> I don't think the concept of R^2 translates well to quantile
> regression. You can define various more-or-less analogous quantities,
> as here, but no matter what you choose, you won't have most of the
> properties real R^2 has in OLS regression.

huangapple
  • 本文由 发表于 2023年6月8日 13:19:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76428807.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定