[R] Subject: Regress multiple independent variables on multiple dependent variables

Michael Friendly friendly at yorku.ca
Mon Nov 4 14:54:00 CET 2013


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



More information about the R-help mailing list