[R] Linear Regression

John Sorkin jsorkin at grecc.umaryland.edu
Tue Oct 2 13:52:48 CEST 2007


OOPPSS,
I forgot a right parenthesis

fit1<-summary(lm(weight~group-1)   )




John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
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)

>>> "John Sorkin" <jsorkin at grecc.umaryland.edu> 10/2/2007 7:40 AM >>>
Livia,
Try the following:

fit1<-summary(lm(weight~group-1)
summary(fit1)
names(fit1)

#The code above wil fit the model and print the results. 
#The statement names(fit1) will give you the components of
#the summary such as
#coefficients, R.squared  adj.R.squared, etc.
#You can then access the components, viz.

coeffs<-summary(fit1)$coefficients

#or 

RSq<-summary(fit1)$r.squared


John
 



John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
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)

>>> livia <yn19832 at msn.com> 10/2/2007 7:04 AM >>>

Hello,

I would like to fit a linear regression and when I use summary(), I got the
following result:

Call:
lm(formula = weight ~ group - 1)

Residuals:
    Min      1Q  Median      3Q     Max 
-1.0710 -0.4938  0.0685  0.2462  1.3690 

Coefficients:
         Estimate Std. Error t value Pr(>|t|)    
groupCtl   5.0320     0.2202   22.85 9.55e-15 ***
groupTrt   4.6610     0.2202   21.16 3.62e-14 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Residual standard error: 0.6964 on 18 degrees of freedom
Multiple R-Squared: 0.9818,     Adjusted R-squared: 0.9798 
F-statistic: 485.1 on 2 and 18 DF,  p-value: < 2.2e-16 

In fact, I do not need them all. Is there a way of exacting part of the
infomation, like the Coefficient or Multiple R-Squared?
-- 
View this message in context: http://www.nabble.com/Linear-Regression-tf4554258.html#a12996725 
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Confidentiality Statement:
This email message, including any attachments, is for the so...{{dropped}}

______________________________________________
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.

Confidentiality Statement:
This email message, including any attachments, is for the so...{{dropped}}



More information about the R-help mailing list