- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 stargazer
创建我的 plm 汇总表。
library(plm)
library(pglm)
data("Unions", package = "pglm")
anb1 <- plm(wage ~ union + exper + rural, Unions, model = "random", method = "bfgs")
stargazer(anb1)
很遗憾,stargazer 不支持 pglm 模型。我正在寻找有关如何绘制具有二进制因变量的 pglm 模型的结果的解决方案,因为以下 stargazer 调用不适用于 pglm 模型。
anb2 <- pglm(union ~ wage + exper + rural, Unions, family = "binomial",
model = "random", method = "bfgs")
stargazer(anb2)
除了提取每个摘要项并分别对其进行格式化之外,还有什么替代方法吗?结果的类别是:
[1] "maxLik" "maxim" "list"
最佳答案
这是一个简单的提取函数,可以让 texreg 与 pglm 一起工作:
extract.pglm <- function (model, include.nobs = TRUE, include.loglik = TRUE, ...) {
s <- summary(model, ...)
coefficient.names <- rownames(s$estimate)
coefficients <- s$estimate[, 1]
standard.errors <- s$estimate[, 2]
significance <- s$estimate[, 4]
loglik.value <- s$loglik
n <- nrow(model$model)
gof <- numeric()
gof.names <- character()
gof.decimal <- logical()
if (include.loglik == TRUE) {
gof <- c(gof, loglik.value)
gof.names <- c(gof.names, "Log-Likelihood")
gof.decimal <- c(gof.decimal, TRUE)
}
if (include.nobs == TRUE) {
gof <- c(gof, n)
gof.names <- c(gof.names, "Num. obs.")
gof.decimal <- c(gof.decimal, FALSE)
}
tr <- createTexreg(coef.names = coefficient.names, coef = coefficients,
se = standard.errors, pvalues = significance, gof.names = gof.names,
gof = gof, gof.decimal = gof.decimal)
return(tr)
}
为了让这段代码正常工作,你还应该注册函数,以便在调用 extract
时默认处理 pglm maxLik
对象:
setMethod("extract", signature = className("maxLik", "maxLik"),
definition = extract.pglm)
之后,您可以将 texreg 与 pglm 一起使用,就像使用 plm 或 texreg 支持的其他模型一样。
关于R Stargazer 与 pglm 模型 - 在 plm 模型中转换二项式 pglm 模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42161129/
使用 glm 时,binomial、binomial() 和 'binomial' 之间有什么区别。它们并不相同,如以下代码所示: > library(MASS) > bwdf = birthwt[-
我一直在用我的(非 r-savvy)大脑来让 R 产生二项式 glmer 模型的正确预测的百分比。我知道这不是统计上的 super 信息,但经常被报道;所以我也想举报。 数据: 因变量:Tipo,它有
我一直在寻找一种方法来使数据符合 beta 二项分布并估计 alpha 和 beta,类似于 VGAM 库中的 vglm 包的方式。我一直无法找到如何在 python 中执行此操作。有一个 scipy
如何在 Julia 中提取一般线性模型中指定的数据分布?例如,下面我安装了一个玩具示例 Poisson GLM。我想从模型中提取一个字符串“Poisson”。同样,如果使用数据分布指定模型 = Bin
我是一名优秀的程序员,十分优秀!