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

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

Find Pseudo R-squared for quantile regression models

问题

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

library(MASS)
data(Boston)
attach(Boston)

qr_res_0.9 <- rq(medv ~ lstat + rm + crim + dis,
               tau = 0.9,
               data = Boston)

Now, results of model summary is shown below

summary(qr_res_0.9,se="boot")
## 
## Call: rq(formula = medv ~ lstat + rm + crim + dis, tau = 0.9, data = Boston)
## 
## tau: [1] 0.9
## 
## Coefficients:
##             Value     Std. Error t value   Pr(>|t|) 
## (Intercept) -20.75975  13.81979   -1.50218   0.13368
## lstat        -0.25857   0.22411   -1.15378   0.24914
## rm            9.01335   1.58000    5.70464   0.00000
## crim         -0.04028   0.11367   -0.35440   0.72319
## 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

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

The R-squared should be between 0 to 1?

英文:

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


library(MASS)
    
data(Boston)
    
attach(Boston)

qr_res_0.9 &lt;- rq(medv ~ lstat + rm + crim + dis,
               tau = 0.9,
               data = Boston)

Now, results of model summary is shown below

summary(qr_res_0.9,se=&quot;boot&quot;)
## 
## Call: rq(formula = medv ~ lstat + rm + crim + dis, tau = 0.9, data = Boston)
## 
## tau: [1] 0.9
## 
## Coefficients:
##             Value     Std. Error t value   Pr(&gt;|t|) 
## (Intercept) -20.75975  13.81979   -1.50218   0.13368
## lstat        -0.25857   0.22411   -1.15378   0.24914
## rm            9.01335   1.58000    5.70464   0.00000
## crim         -0.04028   0.11367   -0.35440   0.72319
## 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

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

The R-squared should be between 0 to 1?

答案1

得分: 1

以下是翻译的内容:

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

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

library(MASS)
library(quantreg)

data(Boston)
# 不要使用 `attach`

qr_res_0.9 <- rq(medv ~ lstat + rm + crim + dis,
                 tau = 0.9,
                 data = Boston)

qr_res_0.9_0 <- rq(medv ~ 1,
                 tau = 0.9,
                 data = Boston)

rho <- function(u, tau = 0.5) u * (tau - (u < 0))
Vhat <- sum(rho(qr_res_0.9$resid, qr_res_0.9$tau))
V0 <- sum(rho(qr_res_0.9_0$resid, qr_res_0.9_0$tau))

R1 <- 1 - Vhat / V0
#[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

library(MASS)
library(quantreg)

data(Boston)
#don&#39;t use `attach`


qr_res_0.9 &lt;- rq(medv ~ lstat + rm + crim + dis,
                 tau = 0.9,
                 data = Boston)

qr_res_0.9_0 &lt;- rq(medv ~ 1,
                 tau = 0.9,
                 data = Boston)

rho &lt;- function(u,tau=.5)u*(tau - (u &lt; 0))
Vhat &lt;- sum(rho(qr_res_0.9$resid, qr_res_0.9$tau))
V0 &lt;- sum(rho(qr_res_0.9_0$resid, qr_res_0.9_0$tau))

R1 &lt;- 1-Vhat/V0
#[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:

确定