[R] regression analyses using a vector of means and a variance-covariance matrix
Gabor Grothendieck
ggrothendieck at gmail.com
Sun Oct 15 06:36:18 CEST 2006
There was a missing line:
On 10/14/06, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
> Here is another approach using the same data as in
> John Fox's reply. His is probably superior but this
> does have the advantage that its very simple. Note
> that it gives the same coefficients and R squared
> to several decimal places. We just simulate a
> data set with the given means and variance covariance
> matrix
>
>
> > library(car) # for Duncan
> > library(MASS) # for mvrnorm
> > set.seed(1)
data <- Duncan[,c("prestige", "income", "education")] # as in John Fox's post
> > DF <- mvrnorm(10000, colMeans(data), var(data), empirical = TRUE)
> > summary(lm(prestige ~ income + education, as.data.frame(DF)))
>
> Call:
> lm(formula = prestige ~ income + education, data = as.data.frame(DF))
>
> Residuals:
> Min 1Q Median 3Q Max
> -49.0377 -8.7332 0.2068 8.8342 50.2737
>
> Coefficients:
> Estimate Std. Error t value Pr(>|t|)
> (Intercept) -6.064663 0.277576 -21.85 <2e-16 ***
> income 0.598733 0.007756 77.19 <2e-16 ***
> education 0.545834 0.006368 85.71 <2e-16 ***
> ---
> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>
> Residual standard error: 13.06 on 9997 degrees of freedom
> Multiple R-Squared: 0.8282, Adjusted R-squared: 0.8281
> F-statistic: 2.409e+04 on 2 and 9997 DF, p-value: < 2.2e-16
>
> On 10/14/06, John Sorkin <jsorkin at grecc.umaryland.edu> wrote:
> > R 2.2.0
> > windows XP
> >
> > How can I perform a regression analyses using a vector of means, a
> > variance-covariance matrix? I looked at the help screen for lm and did
> > not see any option for using the afore mentioned structures as input to
> > lm.
> > Thanks,
> > John
> >
> > John Sorkin M.D., Ph.D.
> > Chief, Biostatistics and Informatics
> > Baltimore VA Medical Center GRECC,
> > University of Maryland School of Medicine Claude D. Pepper OAIC,
> > University of Maryland Clinical Nutrition Research Unit, and
> > Baltimore VA Center Stroke of Excellence
> >
> > University of Maryland School of Medicine
> > Division of Gerontology
> > Baltimore VA Medical Center
> > 10 North Greene Street
> > GRECC (BT/18/GR)
> > Baltimore, MD 21201-1524
> >
> > (Phone) 410-605-7119
> > (Fax) 410-605-7913 (Please call phone number above prior to faxing)
> > jsorkin at grecc.umaryland.edu
> >
> > Confidentiality Statement:
> > This email message, including any attachments, is for the so...{{dropped}}
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch 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