【问题标题】:Pseudo R2 with pglm package in R. (poisson regression with fixed effect model)R中带有pglm包的伪R2。(具有固定效应模型的泊松回归)
【发布时间】:2021-09-30 13:38:19
【问题描述】:

我需要从使用pglm 包进行的一些回归中计算伪 R2,并固定泊松族和模型。

摘要中的伪 R2 在哪里?或者我该如何计算?

pglm(y~x+x1, data=pdata, model= within, family=poisson)

【问题讨论】:

标签: linear-regression panel logistic-regression fixed poisson


【解决方案1】:

对于伪 R2 计算,您需要空模型的对数似然或偏差。在上面带有 model = "within" 的面板 glm 中,无法拟合空模型。所以你无法计算伪 R2。

如果你使用model = "random"model = "pooling" 是可能的:

library(pglm)
dat = data.frame(y = rpois(50,10),x = runif(50),
x1 = rnorm(50),grp = factor(sample(1:2,nrow(dat),replace=TRUE)))
fit =  pglm(y ~ x+x1,data=dat,model="pooling",family="poisson",index="grp")

fit0 =  pglm(y ~ 1,data=dat,model="pooling",family="poisson",index="grp")

所以使用最简单的 McFadden rsquared:

我们这样做:

pseudoR2 = as.numeric(1 - logLik(fit)/logLik(fit0))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-13
    相关资源
    最近更新 更多