[R] problem with 'predict'

Meesters, Christian meesters at aesku.com
Tue Jul 12 10:02:53 CEST 2011


> > flags <- c(rep(1, length(patient_indices)), rep(0,
> > length(control_indices)))
> > # dataset is a data.frame and param the parameter to be analysed:
> > data1  <- dataset[,param][c(patient_indices, control_indices)]
> > fit1 <- glm(flags ~ data1, family = binomial)
> > new.data    <- seq(0, 300, 10)
> > new.p   <- predict(fit1, data.frame(newdata = new.data), type =
> > "response")
> 
> Should (probably)  have been ... names of RHS variables need to be
> exact match:
> 
> new.p   <- predict(fit1, newdata= data.frame(data1 = new.data), type =
> "response")

Thanks, David and Dennis. That's the thing. I have tried so many alterations overlooking that I mangled old and new variable names, unable to see the obvious. Well, again a nice demonstration of the perils of copy & paste.

Thanks,
Christian



More information about the R-help mailing list