![](/img/trans.png)
[英]Standard error and confidence interval for nonlinear function of least squares regression coefficients
[英]Plot confidence interval for regression with clustered standard error in ggplot
我想在ggplot
繪制具有置信區間的回歸模型。 在我的模型中,我想使用基於變量的健壯標准誤差。 但是,找不到適合聚類錯誤的變量。
我已經用lm_robust
方法嘗試過geom_smooth
函數,但是找不到在哪里添加集群錯誤變量。
p1 +geom_smooth(data=data,aes(y=y,x=x),method='lm_robust',se = T)
我需要ggplot中的以下行的ggplot
線圖:
lm_robust(y~ x, data = data, clusters = z)
似乎非標准評估會帶來問題,但是您可以像這樣傳遞整個data.frame列:
library(ggplot2)
library(estimatr)
ggplot(mtcars, aes(hp, qsec)) +
geom_smooth(method = 'lm_robust', method.args = list(cluster = mtcars$cyl))
請注意,這在繪制多條線(例如使用顏色)或多面時不起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.