如何覆盖p值并删除星际式包装中的标准错误?
我试图覆盖星际包装显示的P值及其显着性水平。
使用此简单模型(从下面引用的“ sjplot”软件包取):
data(efc)
library(sjPlot)
# fit a model
fit1 <- lm(barthtot ~ c160age + c12hour + c161sex + c172code, data = efc)
# plot model
plot_models(fit1, std.est = "std", show.p = TRUE, p.shape =TRUE, grid = TRUE)
现在我想使用表中的Stargazer中与此图相关的结果。 为此,我将获得标准化的系数(使用下面引用的lm.Beta):
library(lm.beta)
fit1_std = lm.beta(fit1)
现在我正在制作表,并且我指定我想使用标准化的系数:
stargazer(fit_1_std,
coef = list(fit_1_std$standardized.coefficients),
type='text')
它具有输出:
===============================================
Dependent variable:
---------------------------
barthtot
-----------------------------------------------
c160age -0.100
(0.071)
c12hour -0.477***
(0.019)
c161sex -0.004
(2.086)
c172code -0.016
(1.420)
Constant 0.000
(6.172)
-----------------------------------------------
Observations 821
R2 0.270
Adjusted R2 0.266
Residual Std. Error 25.353 (df = 816)
F Statistic 75.284*** (df = 4; 816)
===============================================
Note: *p<0.1; **p<0.05; ***p<0.01
在这里,系数看起来正确。它们与图中的标准化系数相同。但是,查看p值:它们绝对不同。
看着《森林情节》中重要的“职业时代”,突然在星际合伙人提供的桌子上不再重要了。此外,标准误差是原始模型的误差(不再对应于标准化系数)。
如何删除标准错误并使用正确的p值?换句话说,如何使我的观星桌子准确地反映了“ plot_model”图中显示的内容?
我尝试了这样的事情,其中我将手动添加P值并尝试删除标准错误:
stargazer(fit_1_std,
coef = list(fit_1_std$standardized.coefficients),
p = list(c(0.0019),c(<2e-16),c(0.9002),c(0.5915)), se = FALSE,
type='text')
但是它不起作用。
引用lm.beta: https:https://cran.r -project.org/web/packages/lm.beta/lm.beta.pdf 引用sjplot: https:// https://cran.r-project.org/web/web/web/web/web/web/web/web/web/web/web/web/web/web/web/web/web = /packages/sjplot/index.html
I am trying to override the p-values that are displayed by stargazer package and its significance levels.
Using this simple model (taken from the "SjPlot" package, referenced below):
data(efc)
library(sjPlot)
# fit a model
fit1 <- lm(barthtot ~ c160age + c12hour + c161sex + c172code, data = efc)
# plot model
plot_models(fit1, std.est = "std", show.p = TRUE, p.shape =TRUE, grid = TRUE)
This creates:
Now I want to report the results associated with this plot in stargazer using a table.
To do this, I will obtain the standardized coefficients (using lm.beta referenced below):
library(lm.beta)
fit1_std = lm.beta(fit1)
Now I am making the table, and I am specifying I want to use the standardized coefficients:
stargazer(fit_1_std,
coef = list(fit_1_std$standardized.coefficients),
type='text')
Which has the output:
===============================================
Dependent variable:
---------------------------
barthtot
-----------------------------------------------
c160age -0.100
(0.071)
c12hour -0.477***
(0.019)
c161sex -0.004
(2.086)
c172code -0.016
(1.420)
Constant 0.000
(6.172)
-----------------------------------------------
Observations 821
R2 0.270
Adjusted R2 0.266
Residual Std. Error 25.353 (df = 816)
F Statistic 75.284*** (df = 4; 816)
===============================================
Note: *p<0.1; **p<0.05; ***p<0.01
Here, the coefficients look right. They are the same standardized coefficients as in the plot. However, looking at the p-values: they are definitely different.
Looking at "career's age", which was significant in the forest plot, it suddenly is not significant anymore in the table provided by the stargazer. Further, the standard errors are the ones from the original model (not corresponding to the standardized coefficients anymore).
How could I remove the standard errors and use the correct p-values? In other words, how can I make my stargazer table reflect exactly what is shown in the "plot_model" figure?
I tried something like this, in which I would manually add the p-values and try to remove the standard errors:
stargazer(fit_1_std,
coef = list(fit_1_std$standardized.coefficients),
p = list(c(0.0019),c(<2e-16),c(0.9002),c(0.5915)), se = FALSE,
type='text')
But it did not work.
Citation lm.beta: https://cran.r-project.org/web/packages/lm.beta/lm.beta.pdf
Citation sjPlot: https://cran.r-project.org/web/packages/sjPlot/index.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为默认情况下,估计值在估计下显示什么是误解,即标准错误。您可以使用
Report
选项将它们变成P值。无需替代手册。I think there is a misunderstanding of what
stargazer
show underneath estimates by default, i.e. the standard errors. You can turn them into p-values with thereport
option. No need to substitute something manual.