Skip to content
Prev 332609 / 398502 Next

Subject: Regress multiple independent variables on multiple dependent variables

Hi,

This gives an error.? 

glm(cbind(O3, temp) ~ ., data=ozone)
Error in x[good, , drop = FALSE] : (subscript) logical subscript too long


?lm(cbind(O3, temp) ~ ., data=ozone) #works



R version 3.0.2 (2013-09-25)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
?[1] LC_CTYPE=en_CA.UTF-8?????? LC_NUMERIC=C????????????? 
?[3] LC_TIME=en_CA.UTF-8??????? LC_COLLATE=en_CA.UTF-8??? 
?[5] LC_MONETARY=en_CA.UTF-8??? LC_MESSAGES=en_CA.UTF-8?? 
?[7] LC_PAPER=en_CA.UTF-8?????? LC_NAME=C???????????????? 
?[9] LC_ADDRESS=C?????????????? LC_TELEPHONE=C??????????? 
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C?????? 

attached base packages:
[1] stats???? graphics? grDevices utils???? datasets? methods?? base???? 

other attached packages:
[1] faraway_1.0.5?? ggplot2_0.9.3.1 plotrix_3.5-1?? stringr_0.6.2? 
[5] reshape2_1.2.2 

loaded via a namespace (and not attached):
?[1] colorspace_1.2-3?? dichromat_2.0-0??? digest_0.6.3?????? grid_3.0.2??????? 
?[5] gtable_0.1.2?????? labeling_0.2?????? MASS_7.3-29??????? munsell_0.4.2???? 
?[9] plyr_1.8?????????? proto_0.3-10?????? RColorBrewer_1.0-5 scales_0.2.3????? 
[13] tcltk_3.0.2??????? tools_3.0.2??????
On Monday, November 4, 2013 8:55 AM, Michael Friendly <friendly at yorku.ca> wrote:
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: