How can I run multivariate linear regression in R (I have got 3 dependent variables and only 1 independent variable)? I tried lm function, but it gave different R2 and p values for every dependent variable. I need one R2 and p value for the model. [[alternative HTML version deleted]]
Please help us help you. Follow the posting rules and send us a copy of your code and output. John John Sorkin Chief Biostatistics and Informatics Univ. of Maryland School of Medicine Division of Gerontology and Geriatric Medicine JSorkin at grecc.umaryland.edu -----Original Message----- From: Deniz SIGIRLI <denizsigirli at hotmail.com> To: <r-help at r-project.org> Sent: 2/4/2011 7:54:56 AM Subject: [R] multivariate regression How can I run multivariate linear regression in R (I have got 3 dependent variables and only 1 independent variable)? I tried lm function, but it gave different R2 and p values for every dependent variable. I need one R2 and p value for the model. [[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. Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}}
On 04.02.2011 13:54, Deniz SIGIRLI wrote:> > How can I run multivariate linear regression in R (I have got 3 dependent variables and only 1 independent variable)? I tried lm function, but it gave different R2 and p values for every dependent variable. I need one R2 and p value for the model.Well, then you have to tell us how this one R^2 / p-value should be defined from your point of view. Uwe Ligges> [[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.
#I have got 3 dependent variables: Y<-matrix(c(3,5,6,3,4,2,4,5,3,2,3,5,6,3,4,2,4,5,3,2,3,5,6,3,4,2,4,5,3,2), nrow = 10, ncol=3, byrow=TRUE) #I've got one independent variable: X<-matrix(c(42,54,67,76,45,76,54,87,34,65), nrow = 10, ncol=1, byrow=TRUE) summary(lm(Y~X)) and the result is as below: Response Y1 : Call: lm(formula = Y1 ~ X) Residuals: Min 1Q Median 3Q Max -1.5040 -0.8838 -0.3960 1.1174 2.1162 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 4.43507 1.70369 2.603 0.0315 * X -0.01225 0.02742 -0.447 0.6668 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.401 on 8 degrees of freedom Multiple R-squared: 0.02435, Adjusted R-squared: -0.09761 F-statistic: 0.1997 on 1 and 8 DF, p-value: 0.6668 Response Y2 : Call: lm(formula = Y2 ~ X) Residuals: Min 1Q Median 3Q Max -1.4680 -0.8437 -0.2193 0.9050 1.9960 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.37994 1.50111 0.919 0.385 X 0.03867 0.02416 1.601 0.148 Residual standard error: 1.235 on 8 degrees of freedom Multiple R-squared: 0.2426, Adjusted R-squared: 0.1479 F-statistic: 2.562 on 1 and 8 DF, p-value: 0.1481 Response Y3 : Call: lm(formula = Y3 ~ X) Residuals: Min 1Q Median 3Q Max -1.7689 -0.7316 -0.1943 1.1448 2.0933 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 4.38913 1.70626 2.572 0.033 * X -0.01149 0.02746 -0.418 0.687 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.403 on 8 degrees of freedom Multiple R-squared: 0.0214, Adjusted R-squared: -0.1009 F-statistic: 0.175 on 1 and 8 DF, p-value: 0.6867 There are 3 F statistics, R2 and p-values. But I want just one R2 and pvalue for my multivariate regression model.> Date: Fri, 4 Feb 2011 08:23:39 -0500 > From: jsorkin@grecc.umaryland.edu > To: denizsigirli@hotmail.com; r-help@r-project.org > Subject: Re: [R] multivariate regression > > Please help us help you. Follow the posting rules and send us a copy of your code and output. > John > John Sorkin > Chief Biostatistics and Informatics > Univ. of Maryland School of Medicine > Division of Gerontology and Geriatric Medicine > JSorkin@grecc.umaryland.edu > -----Original Message----- > From: Deniz SIGIRLI <denizsigirli@hotmail.com> > To: <r-help@r-project.org> > > Sent: 2/4/2011 7:54:56 AM > Subject: [R] multivariate regression > > > How can I run multivariate linear regression in R (I have got 3 dependent variables and only 1 independent variable)? I tried lm function, but it gave different R2 and p values for every dependent variable. I need one R2 and p value for the model. > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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 ...{{dropped:5}}
Deniz,>> There are 3 F statistics, R2 and p-values. But I want just one R2 and >> pvalue for my multivariate >> regression model.Which is as it should. Maybe the following will help, but we are making the dependent variables the independent variables, which may or may not be what you really have in mind. (Otherwise, as Uwe has said, you need to specify how "this one R^2 / p-value should be defined from your point of view".)> summary(lm(X~Y))Call: lm(formula = X ~ Y) Residuals: Min 1Q Median 3Q Max -20.329 -9.770 0.271 11.167 18.986 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 65.663 31.464 2.087 0.082 . Y1 -4.232 4.616 -0.917 0.395 Y2 6.846 4.181 1.637 0.153 Y3 -4.145 4.616 -0.898 0.404 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Residual standard error: 16.64 on 6 degrees of freedom Multiple R-squared: 0.3641, Adjusted R-squared: 0.04622 F-statistic: 1.145 on 3 and 6 DF, p-value: 0.4041 -- View this message in context: http://r.789695.n4.nabble.com/multivariate-regression-tp3260141p3263712.html Sent from the R help mailing list archive at Nabble.com.