我正在尝试对响应变量在0到1之间的数据进行建模,因此我决定在R中使用分数响应模型。根据我目前的理解,分数响应模型与逻辑回归相似,但是使用qausi-确定参数的似然法。我不确定我是否正确理解。

到目前为止,我尝试过的是以下数据中的frmfrm包中的glm,与该OP相同

library(foreign)
mydata <- read.dta("k401.dta")

此外,我遵循了OP中使用glm的过程。但是,对于具有frm的相同数据集,它将返回不同的SE
library(frm)
y <- mydata$prate
x <- mydata[,c('mrate', 'age', 'sole', 'totemp1')]
myfrm <- frm(y, x, linkfrac = 'logit')
frm返回,
*** Fractional logit regression model ***

           Estimate Std. Error t value Pr(>|t|)
INTERCEPT  1.074062   0.048902  21.963    0.000 ***
mrate      0.573443   0.079917   7.175    0.000 ***
age        0.030895   0.002788  11.082    0.000 ***
sole       0.363596   0.047595   7.639    0.000 ***
totemp1   -0.057799   0.011466  -5.041    0.000 ***

Note: robust standard errors

Number of observations: 4734
R-squared: 0.124

glm一起使用
myglm <- glm(prate ~ mrate + totemp1 + age + sole, data = mydata, family = quasibinomial('logit'))
summary(myglm)

Call:
glm(formula = prate ~ mrate + totemp1 + age + sole, family = quasibinomial("logit"),
    data = mydata)

Deviance Residuals:
    Min       1Q   Median       3Q      Max
-3.1214  -0.1979   0.2059   0.4486   0.9146

Coefficients:
             Estimate Std. Error t value Pr(>|t|)
(Intercept)  1.074062   0.047875  22.435  < 2e-16 ***
mrate        0.573443   0.048642  11.789  < 2e-16 ***
totemp1     -0.057799   0.011912  -4.852 1.26e-06 ***
age          0.030895   0.003148   9.814  < 2e-16 ***
sole         0.363596   0.051233   7.097 1.46e-12 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for quasibinomial family taken to be 0.2913876)

    Null deviance: 1166.6  on 4733  degrees of freedom
Residual deviance: 1023.7  on 4729  degrees of freedom
AIC: NA

Number of Fisher Scoring iterations: 6

我应该依靠哪一个?最好使用glm而不是frm,因为我已经看到SE估计的OP可能有所不同

最佳答案

两种方法的差异源于鲁棒性标准误差的计算中不同的自由度校正。使用相似的默认值,结果将相同。请参见以下示例:

library(foreign)
library(frm)
library(sandwich)
library(lmtest)

df <- read.dta("http://fmwww.bc.edu/ec-p/data/wooldridge/401k.dta")
df$prate <- df$prate/100

y <- df$prate
x <- df[,c('mrate', 'age', 'sole', 'totemp')]

myfrm <- frm(y, x, linkfrac = 'logit')

*** Fractional logit regression model ***

           Estimate Std. Error t value Pr(>|t|)
INTERCEPT  0.931699   0.084077  11.081    0.000 ***
mrate      0.952872   0.137079   6.951    0.000 ***
age        0.027934   0.004879   5.726    0.000 ***
sole       0.340332   0.080658   4.219    0.000 ***
totemp    -0.000008   0.000003  -2.701    0.007 ***

现在,GLM:
myglm <- glm(prate ~ mrate + totemp + age + sole,
             data = df, family = quasibinomial('logit'))
coeftest(myglm, vcov.=vcovHC(myglm, type="HC0"))

z test of coefficients:

                 Estimate    Std. Error z value              Pr(>|z|)
(Intercept)  0.9316994257  0.0840772572 11.0815 < 0.00000000000000022 ***
mrate        0.9528723652  0.1370808798  6.9512     0.000000000003623 ***
totemp      -0.0000082352  0.0000030489 -2.7011              0.006912 **
age          0.0279338963  0.0048785491  5.7259     0.000000010291017 ***
sole         0.3403324262  0.0806576852  4.2195     0.000024488075931 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

使用HC0,标准错误是相同的。也就是说,默认情况下frm使用HC0。有关详细讨论,请参见this postsandwich使用的默认值在某些情况下可能会更好,尽管我怀疑总体上这没什么大不了。您已经从结果中看到了这一点:差异在数值上很小。

关于r - R中的分数响应回归,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37584715/

10-12 18:50