Hi, I am trying to find out a collinearity in explanatory variables with alias(). I creat a dataframe: dat <- ds[,sapply(ds,nlevels)>=2] dat$Y <- Response Explanatory variables are factor and response is continuous random variable. When I run a regression, I have the following error: fit <- aov( Y ~ . , data = dat) Error in "contrasts<-"(`*tmp*`, value "contr.treatment") : contrasts can be applied only to factors with 2 or more levels I think there is a dependency in explanatory variables. So, I wanted to use alias to find out a dependency in design matrix but I can't because I cannot create "fit" in the first place. One of examples I found is: carprice1.lm <- lm(gpm100 ~ Type+Min.Price+Price+Max.Price+Range.Price,data=carprice) alias(carprice1.lm) But, what if I can create lm object ? Then is there a way to find out a dependency in design matrix? Thanks a lot for help in advance! -Young.
Hi, Young Cho wrote:> fit <- aov( Y ~ . , data = dat) > Error in "contrasts<-"(`*tmp*`, value > "contr.treatment") : > contrasts can be applied only to factors with > 2 or more levels > > I think there is a dependency in explanatory > variables. So, I wanted to use alias to find out a > dependency in design matrix but I can't because I > cannot create "fit" in the first place.The error message actually looks like you have got (at least) a variable that only has 1 level, e.g. a factor with only one level. Cheers, Kev -- Ko-Kang Kevin Wang PhD Student Centre for Bioinformation Science Building 27, Room 1004 Mathematical Sciences Institute (MSI) Australian National University Canberra, ACT 2601 Australia Homepage: http://wwwmaths.anu.edu.au/~wangk/ Ph (W): +61-2-6125-2431 Ph (H): +61-2-6125-7407 Ph (M): +61-40-451-8301
At 01:45 PM 30/06/2005, Young Cho wrote:>Hi, I am trying to find out a collinearity in >explanatory variables with alias(). > >I creat a dataframe: > >dat <- ds[,sapply(ds,nlevels)>=2] >dat$Y <- Response > >Explanatory variables are factor and response is >continuous random variable. When I run a regression, I >have the following error: > >fit <- aov( Y ~ . , data = dat) >Error in "contrasts<-"(`*tmp*`, value >"contr.treatment") : > contrasts can be applied only to factors with >2 or more levels1. Sounds like at least one of your factors has only one level. This should be easy to spot. 2. Have you considered package perturb? HTH, Simon.>I think there is a dependency in explanatory >variables. So, I wanted to use alias to find out a >dependency in design matrix but I can't because I >cannot create "fit" in the first place. > >One of examples I found is: > >carprice1.lm <- lm(gpm100 ~ >Type+Min.Price+Price+Max.Price+Range.Price,data=carprice) >alias(carprice1.lm) > >But, what if I can create lm object ? Then is there a >way to find out a dependency in design matrix? Thanks >a lot for help in advance! > >-Young. > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlSimon Blomberg, B.Sc.(Hons.), Ph.D, M.App.Stat. Centre for Resource and Environmental Studies The Australian National University Canberra ACT 0200 Australia T: +61 2 6125 7800 email: Simon.Blomberg_at_anu.edu.au F: +61 2 6125 0757 CRICOS Provider # 00120C