在标星表中包括标准化系数

时间:2017-02-06 20:41:31

标签: r stargazer significance standardized

我有一系列线性模型,我想报告每个模型的标准化系数。然而,当我在观星者中打印模型时,看起来像stargazer会自动打印标准化系数的重要星,就好像它们是非标准化系数一样。你可以看到下面出现的差异。

根据非标准值打印重要星星是否在统计上是错误的?怎么在观星者身上完成?谢谢!

#load libraries
library(stargazer)
library(lm.beta)
#fake data
var1<-rnorm(100, mean=10, sd=5)
var2<-rnorm(100, mean=5, sd=2)
var3<-rnorm(100, mean=2, sd=3)
var4<-rnorm(100, mean=5, sd=1)
df<-data.frame(var1, var2, var3, var4)
#model with unstandardized betas
model1<-lm(var1~var2+var3+var4, data=df)
#Standardized betas
model1.beta<-lm.beta(model1)
#print
stargazer(model1, model1.beta, type='text')

1 个答案:

答案 0 :(得分:0)

lm.beta不会自动知道它应该在第二个模型中查找标准化系数。 lm.object只需将标准系数添加到lm.object即可。因此它仍然是model1.beta$coefficients,因此它会按常规提取系数(来自coef =。使用coef = list(model1$coefficients, model1.beta$standardized.coefficients)参数指定要使用的特定系数:> stargazer(model1, model1.beta, coef = list(model1$coefficients, model1.beta$standardized.coefficients), type='text') ========================================================== Dependent variable: ---------------------------- var1 (1) (2) ---------------------------------------------------------- var2 0.135 0.048 (0.296) (0.296) var3 -0.088 -0.044 (0.205) (0.205) var4 -0.190 -0.030 (0.667) (0.667) Constant 10.195** 0.000 (4.082) (4.082) ---------------------------------------------------------- Observations 100 100 R2 0.006 0.006 Adjusted R2 -0.025 -0.025 Residual Std. Error (df = 96) 5.748 5.748 F Statistic (df = 3; 96) 0.205 0.205 ========================================================== Note: *p<0.1; **p<0.05; ***p<0.01

<div class="login">
 <div class="container">
  <div class="form">

<h1>Sign up</h1>

    <%= form_for(@user) do |f| %>
  <%= f.text_field :first_name, :placeholder => "First name" %>
  <%= f.text_field :last_name, :placeholder => "Last name" %>
  <%= f.email_field :email, :placeholder => "Email" %>
  <%= f.password_field :password, :placeholder => "Password" %>
  <%= f.submit "Create an account", class: "btn-submit" %>
<% end %>

</div>