Hi,
 
I have a problem in getting step function work. I am getting the following error:
 
> fit1 <- lm(Response~1)
> fmla <- as.formula(paste(" ~ ",paste(colnames,collapse="+")))
> sfit <- step(fit1,scope=list(upper= fmla,lower= ~1),k=log(nrow(dat)))
Start:  AIC= -1646.66 
 Response ~ 1 
Error in "contrasts<-"(`*tmp*`, value = "contr.treatment") : 
        contrasts can be applied only to factors with 2 or more levels

But if i count the unique values in each column by

A <- NULL
for (ii in 1:length(colnames)){
        A[ii] <- length(unique( eval(parse(text=paste('dat$',colnames[ii])))))
}
 
I do not see any column with only 1 value. Is there some other possible reason why I am getting the error? Thanks a lot!
 
Young.
 

__________________________________________________



	[[alternative HTML version deleted]]


