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.
look at ?summary.lm(), and specifically at the `Value' section, e.g.,
try this:
lmFit <- lm(weight ~ group - 1)
summ.lmFit <- summary(lmFit)
summ.lmFit$coefficients
summ.lmFit$r.squared
I hope it helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
----- Original Message -----
From: "livia" <yn19832 at msn.com>
To: <r-help at r-project.org>
Sent: Tuesday, October 02, 2007 1:04 PM
Subject: [R] Linear Regression
>
> 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.
>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
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}}
Hello, I am performing a multiple linear regression, is there a way of get the mean and standard error of the response variable? Could anyone give me some advice? Many thanks. -- View this message in context: http://www.nabble.com/Linear-Regression-tf4574635.html#a13057768 Sent from the R help mailing list archive at Nabble.com.
livia wrote:> > Hello, > > I am performing a multiple linear regression, is there a way of get the > mean and standard error of the response variable? > > Could anyone give me some advice? Many thanks. >You may need to give us more information/express your request more clearly. Two answers I can think of (if your model is LM1 = lm(z~x+y)) are mean(z) sd(z)/sqrt(length(z)) or predict(LM1,se.fit=TRUE) Ben Bolker -- View this message in context: http://www.nabble.com/Linear-Regression-tf4574635.html#a13058756 Sent from the R help mailing list archive at Nabble.com.
Thank you very much for your reply and I did not make myself clear. My model is like lm(y ~ x1+x2+x3,data), I would like to see E(y) and the standard error. Ben Bolker wrote:> > > > livia wrote: >> >> Hello, >> >> I am performing a multiple linear regression, is there a way of get the >> mean and standard error of the response variable? >> >> Could anyone give me some advice? Many thanks. >> > > You may need to give us more information/express your request more > clearly. Two > answers I can think of (if your model is LM1 = lm(z~x+y)) are > > mean(z) > sd(z)/sqrt(length(z)) > > or > > predict(LM1,se.fit=TRUE) > > Ben Bolker >-- View this message in context: http://www.nabble.com/Linear-Regression-tf4574635.html#a13059177 Sent from the R help mailing list archive at Nabble.com.