Kumar Raj
2013-Nov-04 07:55 UTC
[R] Subject: Regress multiple independent variables on multiple dependent variables
I want to estimate the effect of several independent variables on several dependent variables. In the example below I wanted to estimate the effect of three independent variables on ozone and temperature. My aim is to create a list of dependent and independent variables and automate the process rather than writing every dependent and independent variable in each model as I have done below. Example data is provided by the following library: library(faraway) data(ozone) mo3 <- glm(O3 ~ humidity + ibh + ibt, data=ozone) mtemp<- glm(temp ~ humidity + ibh + ibt, data=ozone) Thanks [[alternative HTML version deleted]]
Michael Friendly
2013-Nov-04 13:54 UTC
[R] Subject: Regress multiple independent variables on multiple dependent variables
It's not clear exactly what you mean by 'automate' but you can simplify a bit by fitting a multivariate linear model to all the responses together, and using . on the RHS of the formula to represent all other variables in the data set as independent variables, m.all <- glm(cbind(O3, temp) ~ ., data=ozone) (assuming that only humidity, ibh and ibt remain; otherwise, use data=subset(ozone, ...)) -Michael On 11/4/2013 2:55 AM, Kumar Raj wrote:> I want to estimate the effect of several independent variables on several > dependent > variables. In the example below I wanted to estimate the > effect of three independent variables on ozone and temperature. My aim is > to create a list of dependent and independent variables and automate the > process rather than writing every dependent and independent variable in > each model as I have done below. > > Example data is provided by the following library: > library(faraway) > > data(ozone) > > mo3 <- glm(O3 ~ humidity + ibh + ibt, data=ozone) > > mtemp<- glm(temp ~ humidity + ibh + ibt, data=ozone) > > > Thanks > > [[alternative HTML version deleted]] >-- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. & Chair, Quantitative Methods York University Voice: 416 736-2100 x66249 Fax: 416 736-5814 4700 Keele Street Web: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA
Seemingly Similar Threads
- selection of hinge function with restrictions, machine learning, earth package,
- selection of hinge function with restrictions, machine learning, earth package,
- Error in solve.default message using lme
- [LLVMdev] ARM thumb-2 instruction used for non-thumb2 CPUs
- Longman iBT 2.0 Toefl