An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121128/8f968f9b/attachment.pl>
Confidence intervals for estimates of all independent variables in WLS regression
5 messages · Jeff Newmiller, Torvon, Rui Barradas
?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.
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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121129/88d4bb06/attachment.pl>
Hello,
You don't have to exchange 'object' by the name of your model, you call
the function with the name of your model:
x <- 1:20
y <- x + rnorm(20)
fit <- lm(y ~ x)
ci_lm(fit)
beta lower upper
(Intercept) 0.6741130 -0.9834827 2.331709
x 0.9575906 0.8192171 1.095964
Hope this helps,
Rui Barradas
Em 30-11-2012 01:07, Torvon escreveu:
Rui, Thank you very much. Are there other things I have to adjust except for exchanging "object" by the name of my model? Torvon On 29 November 2012 08:17, Rui Barradas <ruipbarradas at sapo.pt> wrote:
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)
}