Torvon
2012-Nov-29 00:07 UTC
[R] Confidence intervals for estimates of all independent variables in WLS regression
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]]
Jeff Newmiller
2012-Nov-29 00:22 UTC
[R] Confidence intervals for estimates of all independent variables in WLS regression
?summary.lm
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live
Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
Torvon <torvon at gmail.com> wrote:
>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.
Rui Barradas
2012-Nov-29 13:17 UTC
[R] Confidence intervals for estimates of all independent variables in WLS regression
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.