[R] predict for a model with a subset

Spencer Graves spencer.graves at pdf.com
Fri Oct 24 18:56:29 CEST 2003


Have you tried the following: 

notmar1 <- glm(yprisx~age+harddrug+sex, subset = marcom == 0,
 family = quasipoisson), data=DF)

predict(notmar1, newdata=DF[DF$marcom==0,])

      I haven't tested this specific code, but I've gotten sensible 
results from constructs like this in the past. 

hope this helps.  spencer graves

Peter Flom wrote:

>Hello
>
>running R 1.7.1 on Windows 2000
>
>I have a model
>
>notmar1 <- glm(yprisx~age+harddrug+sex, subset = marcom == 0,
> family = quasipoisson)
>
>and summary(notmar1) gives (as it should) 433 df for the null model
>
>but when I run
>predict(notmar1 <- glm(yprisx~age+harddrug+sex, subset = marcom == 0, 
>family = quasipoisson))
>
>I get preditions for 528 people (the full data set, not the subset)
>
>How do I get predict to work on just the subset of people for whom the
>model is estimated?
>
>Thanks
>
>Peter
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>  
>




More information about the R-help mailing list