簡體   English   中英

與觀星者並排報告系數和指數系數

[英]Report coefficients and exponentiated coefficients side by side with stargazer

如何在模型輸出中增加一列,其中包括系數的指數值和系數的非指數值? 這是add.lines選項的目的嗎? 謝謝你的幫助。

#load library
library(stargazer)
#sample data
var1<-sample(c('men', 'women'), replace=TRUE, 100, prob=c(0.3, 0.7))
var2<-sample(c('left', 'right'), replace=TRUE, 100, prob=c(0.5, 0.5))
df<-data.frame(gender=var1, vote=var2)
#binomial logistic regression
model1<-glm(vote~gender, data=df, family='binomial')
#report model without
stargazer(model1)
#report model with exponentiated coefficients
stargazer(model1, apply.coef=exp)

也許有更好的方法,但是如何進行如下快速黑客攻擊:

model1Exp = model1 
model1Exp$coefficients = exp(model1Exp$coefficients)

stargazer(model1, model1Exp)

您需要調整默認標簽以標記第二個模型與第一個模型相同,但是系數取冪。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM