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 <frien...@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: > 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 ______________________________________________ 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. ______________________________________________ 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.