作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在使用 summary() 函数(例如,stata 中的 absorb() 函数的等价物)时,是否有一种方法可以抑制线性模型中固定效应的系数。例如,我希望汇总函数只输出截距和 x,而不是因子的系数和标准误差:
frame <- data.frame(x = rnorm(100), y = rnorm(100), z = rep(c("A", "B", "C", "D"),25))
summary(lm(y~x + as.factor(z), data = frame))
Call:
lm(formula = y ~ x + as.factor(z), data = frame)
Residuals:
Min 1Q Median 3Q Max
-2.2417 -0.6407 0.1783 0.5789 2.4347
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.25829 0.19196 -1.346 0.1816
x 0.09983 0.09788 1.020 0.3104
...
谢谢。
最佳答案
您可以执行以下任一操作:
mod <- lm(y~x + as.factor(z), data = frame)
coef(mod)[c("(Intercept)", "x")]
# (Intercept) x
# 0.12357491 -0.06430765
coef(mod)[grepl("Intercept|x", names(coef(mod)))]
# (Intercept) x
# 0.12357491 -0.06430765
coef(mod)[1:2]
# (Intercept) x
# 0.12357491 -0.06430765
mod$coefficients[1:2]
# (Intercept) x
# 0.12357491 -0.06430765
关于r - 抑制 R 中的固定效应系数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26565879/
图像显示,但不转换。 CSS 代码显示在上传的页面上。 我正在使用 EverWeb 构建页面。 下面是我正在尝试的代码。提前致谢。 HTML 片段 CSS .image { width: 100
我是一名优秀的程序员,十分优秀!