Hi all, I wanted to have a seasonality study like whether a particular month has significant effect as compared to others. Here is my data : 0.10499 0 0 1 0 0 0 0 0 0 0 0 0.00259 0 0 0 1 0 0 0 0 0 0 0 -0.06015 0 0 0 0 1 0 0 0 0 0 0 0.10721 0 0 0 0 0 1 0 0 0 0 0 0.03597 0 0 0 0 0 0 1 0 0 0 0 0.10584 0 0 0 0 0 0 0 1 0 0 0 0.02063 0 0 0 0 0 0 0 0 1 0 0 -0.03509 0 0 0 0 0 0 0 0 0 1 0 -0.03485 0 0 0 0 0 0 0 0 0 0 1 0.01632 0 0 0 0 0 0 0 0 0 0 0 0.06844 1 0 0 0 0 0 0 0 0 0 0 -0.01766 0 1 0 0 0 0 0 0 0 0 0 0.00989 0 0 1 0 0 0 0 0 0 0 0 0.11673 0 0 0 1 0 0 0 0 0 0 0 0.01789 0 0 0 0 1 0 0 0 0 0 0 -0.00323 0 0 0 0 0 1 0 0 0 0 0 0.06811 0 0 0 0 0 0 1 0 0 0 0 -0.01292 0 0 0 0 0 0 0 1 0 0 0 -0.12244 0 0 0 0 0 0 0 0 1 0 0 -0.06645 0 0 0 0 0 0 0 0 0 1 0 -0.03355 0 0 0 0 0 0 0 0 0 0 1 0.02308 0 0 0 0 0 0 0 0 0 0 0 -0.11711 1 0 0 0 0 0 0 0 0 0 0 0.06116 0 1 0 0 0 0 0 0 0 0 0 0.02832 0 0 1 0 0 0 0 0 0 0 0 0.01441 0 0 0 1 0 0 0 0 0 0 0 -0.04412 0 0 0 0 1 0 0 0 0 0 0 0.05558 0 0 0 0 0 1 0 0 0 0 0 0.08363 0 0 0 0 0 0 1 0 0 0 0 -0.01063 0 0 0 0 0 0 0 1 0 0 0 i.e. all explanatory variables here are dichotomous. However once I run lm() i got following error :> lm(dat[,1]~dat[,-1])Error in model.frame.default(formula = dat[, 1] ~ dat[, -1], drop.unused.levels = TRUE) : invalid type (list) for variable 'dat[, -1]' Can anyone please tell me what to do? Best, -- View this message in context: http://old.nabble.com/Error-in-lm%28%29-function-tp26300324p26300324.html Sent from the R help mailing list archive at Nabble.com.
Hi Bogaso, Try this vecnames<-names(test[,2:11]) fmla <- as.formula(paste("test[,1] ~ ", paste(vecnames, collapse= "+"))) res<-lm(fmla) Regards M Bogaso a ?crit :> Hi all, > > I wanted to have a seasonality study like whether a particular month has > significant effect as compared to others. Here is my data : > > 0.10499 0 0 1 0 0 0 0 0 0 0 0 > 0.00259 0 0 0 1 0 0 0 0 0 0 0 > -0.06015 0 0 0 0 1 0 0 0 0 0 0 > 0.10721 0 0 0 0 0 1 0 0 0 0 0 > 0.03597 0 0 0 0 0 0 1 0 0 0 0 > 0.10584 0 0 0 0 0 0 0 1 0 0 0 > 0.02063 0 0 0 0 0 0 0 0 1 0 0 > -0.03509 0 0 0 0 0 0 0 0 0 1 0 > -0.03485 0 0 0 0 0 0 0 0 0 0 1 > 0.01632 0 0 0 0 0 0 0 0 0 0 0 > 0.06844 1 0 0 0 0 0 0 0 0 0 0 > -0.01766 0 1 0 0 0 0 0 0 0 0 0 > 0.00989 0 0 1 0 0 0 0 0 0 0 0 > 0.11673 0 0 0 1 0 0 0 0 0 0 0 > 0.01789 0 0 0 0 1 0 0 0 0 0 0 > -0.00323 0 0 0 0 0 1 0 0 0 0 0 > 0.06811 0 0 0 0 0 0 1 0 0 0 0 > -0.01292 0 0 0 0 0 0 0 1 0 0 0 > -0.12244 0 0 0 0 0 0 0 0 1 0 0 > -0.06645 0 0 0 0 0 0 0 0 0 1 0 > -0.03355 0 0 0 0 0 0 0 0 0 0 1 > 0.02308 0 0 0 0 0 0 0 0 0 0 0 > -0.11711 1 0 0 0 0 0 0 0 0 0 0 > 0.06116 0 1 0 0 0 0 0 0 0 0 0 > 0.02832 0 0 1 0 0 0 0 0 0 0 0 > 0.01441 0 0 0 1 0 0 0 0 0 0 0 > -0.04412 0 0 0 0 1 0 0 0 0 0 0 > 0.05558 0 0 0 0 0 1 0 0 0 0 0 > 0.08363 0 0 0 0 0 0 1 0 0 0 0 > -0.01063 0 0 0 0 0 0 0 1 0 0 0 > > i.e. all explanatory variables here are dichotomous. However once I run lm() > i got following error : > > >> lm(dat[,1]~dat[,-1]) >> > Error in model.frame.default(formula = dat[, 1] ~ dat[, -1], > drop.unused.levels = TRUE) : > invalid type (list) for variable 'dat[, -1]' > > Can anyone please tell me what to do? > > Best, > >-- Mohamed Lajnef INSERM Unit? 955. 40 rue de Mesly. 94000 Cr?teil. Courriel : Mohamed.lajnef at inserm.fr tel.: 01 49 81 31 31 (poste 18470) Sec : 01 49 81 32 90 fax : 01 49 81 30 99 Portable:06 15 60 01 62
On Nov 11, 2009, at 7:14 AM, Bogaso wrote:> > Hi all, > > I wanted to have a seasonality study like whether a particular month > has > significant effect as compared to others. Here is my data : > > 0.10499 0 0 1 0 0 0 0 0 0 0 0 > 0.00259 0 0 0 1 0 0 0 0 0 0 0 > -0.06015 0 0 0 0 1 0 0 0 0 0 0 > 0.10721 0 0 0 0 0 1 0 0 0 0 0 > 0.03597 0 0 0 0 0 0 1 0 0 0 0 > 0.10584 0 0 0 0 0 0 0 1 0 0 0 > 0.02063 0 0 0 0 0 0 0 0 1 0 0 > -0.03509 0 0 0 0 0 0 0 0 0 1 0 > -0.03485 0 0 0 0 0 0 0 0 0 0 1 > 0.01632 0 0 0 0 0 0 0 0 0 0 0 > 0.06844 1 0 0 0 0 0 0 0 0 0 0 > -0.01766 0 1 0 0 0 0 0 0 0 0 0 > 0.00989 0 0 1 0 0 0 0 0 0 0 0 > 0.11673 0 0 0 1 0 0 0 0 0 0 0 > 0.01789 0 0 0 0 1 0 0 0 0 0 0 > -0.00323 0 0 0 0 0 1 0 0 0 0 0 > 0.06811 0 0 0 0 0 0 1 0 0 0 0 > -0.01292 0 0 0 0 0 0 0 1 0 0 0 > -0.12244 0 0 0 0 0 0 0 0 1 0 0 > -0.06645 0 0 0 0 0 0 0 0 0 1 0 > -0.03355 0 0 0 0 0 0 0 0 0 0 1 > 0.02308 0 0 0 0 0 0 0 0 0 0 0 > -0.11711 1 0 0 0 0 0 0 0 0 0 0 > 0.06116 0 1 0 0 0 0 0 0 0 0 0 > 0.02832 0 0 1 0 0 0 0 0 0 0 0 > 0.01441 0 0 0 1 0 0 0 0 0 0 0 > -0.04412 0 0 0 0 1 0 0 0 0 0 0 > 0.05558 0 0 0 0 0 1 0 0 0 0 0 > 0.08363 0 0 0 0 0 0 1 0 0 0 0 > -0.01063 0 0 0 0 0 0 0 1 0 0 0 > > i.e. all explanatory variables here are dichotomous. However once I > run lm() > i got following error : > >> lm( > Error in model.frame.default(formula = dat[, 1] ~ dat[, -1], > drop.unused.levels = TRUE) : > invalid type (list) for variable 'dat[, -1]'Assuming that dat really is a data.frame, then the error message is saying you have attempted to pass most of it (since it is a list) to the rhs of the formula and the lm procedure was expecting a vector or vectors. What do you get with: lm( dat[,1]~. , data = dat) (It would be preferable for readability and possibly even for code correctness to refer to the column name for data[,1].)> > Can anyone please tell me what to do?Better to post the output of str(dat) , or even better, the output of dput(dat).> > Best, >-- David Winsemius, MD Heritage Laboratories West Hartford, CT