我正在使用coefplotStata 中的包来绘制系数如何根据所采用的模型而变化。我特别想看看利息系数是如何随时间变化的。我正在垂直绘制它,因此 x 轴可以显示每个系数所指的年份。但是,我无法相应地标记 x 轴(而不是显示我感兴趣的变量的名称x1,它应该说明 1、2 和 3。我还想通过使用选项来省略图例,legend(off)但是不起作用。
这是我正在使用的代码:
reg y x1 x2 if year==1;
estimates store t1;
reg y x1 x2 if year==2;
estimates store t2;
reg y x1 x2 if year==3;
estimates store t3;
coefplot t1 t2 t3, drop(x2) vertical yline(0);
Run Code Online (Sandbox Code Playgroud)
任何建议将不胜感激。
嗨,我在r中使用coefplot函数绘制出广义线性模型的系数.我想将95%CI线的颜色更改为与50%CI线不同.对于95%和50%CI行,颜色参数默认颜色相同.
coeff<-coefplot(model1,pointSize=5,color="black",fillColor="grey",lwdOuter = 1.2,lwdInner=2)
coeff + theme_bw() +
theme(panel.grid.major=element_blank(),panel.grid.minor=element_blank()) +
theme (axis.title.y = element_text(size=16)) +
theme(axis.title.x = element_text(size=16)) +
scale_y_discrete(name="",labels=c("NDAA","GAP","SS","PS","LL")) +
theme (axis.text.x = element_text(size=16)) +
theme(axis.text.x = element_text(size=16)) +
scale_x_continuous(name="Regression Estimate") +
labs(title = "") +
coord_flip()
Run Code Online (Sandbox Code Playgroud)
在 Stata 中进行回归后,我试图仅绘制交互项的系数。
我无法使用社区贡献的命令来做到这一点coefplot。
这是一个可重现的示例和我尝试的解决方案:
sysuse auto, clear
reg price foreign i.turn foreign#i.turn
*this plots all coefficients:
coefplot,
*this drops _cons and foreign but not i.turn
coefplot, drop(i.turn _cons foreign )
*variations with keep also do not work
coefplot, keep(foreign#i.turn )
Run Code Online (Sandbox Code Playgroud)
有没有其他方法可以做到这一点?
我已经在Statalist上交叉发布了这个问题。
使用社区提供的 Stata命令考虑以下玩具示例coefplot:
sysuse auto
reg weight i.foreign
eststo, title("Weight"): margins, eydx(foreign) post
reg price i.foreign
eststo, title("Price"): margins, eydx(foreign) post
coefplot est1 est2, horizontal
Run Code Online (Sandbox Code Playgroud)
是否有可能获得传说中的标题(甚至变量标签),而不是估计的名字(即Weight和Price,而不是est1和est2)?
我知道如何手动完成,但我无法弄清楚如何使用许多模型自动执行此操作.