[R] Confidence intervals for estimates of all independent variables in WLS regression

Rui Barradas ruipbarradas at sapo.pt
Thu Nov 29 14:17:59 CET 2012


Hello,

Try the following function.

ci_lm <- function(object, level = 0.95){
      summfit <- summary(object)
      beta <- summfit$coefficients[, 1]
      se <- summfit$coefficients[, 2]
      df <- summfit$df[1]
      alpha <- 1 - level
      lower <- beta + qt(alpha/2, df = df)*se
      upper <- beta + qt(1 - alpha/2, df = df)*se
      data.frame(beta, lower, upper)
}

Hope this helps,

Rui Barradas
Em 29-11-2012 00:07, Torvon escreveu:
> I would like to obtain Confidence Intervals for the estimates
> (unstandardized beta weights) of each predictor in a WLS regression:
>
> m1 = lm(x~ x1+x2+x3, weights=W, data=D)
>
> SPSS offers that output by default, and I am not able to find a way to do
> this in R. I read through predict.lm, but I do not find a way to get the
> CIs for multiple independent variables.
>
> Thank you
> Torvon
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list