Reputation: 1082
I'd like to predict values using a generated model. That is the simple part:
predicted = fitted.values(glm(dep ~ indep, family = myFamily, maxit = myMaxit)
But: for each case I don't want to use that case for building that model (without using a for-loop)
Example:
Grade Sex Age Course School
-------------------------------
1 m 11 math St.Adam
2 w 12 engl St.Adam
3 m 13 fren St.Adam
4 w 14 math St.Eve
5 m 15 engl St.Eve
6 w 16 fren St.Eve
… … … … …
Assume I want to predict a mean grade for St.Adam's pupils but don't want to use them for building the model.
Upvotes: 0
Views: 149
Reputation: 44555
Maybe something like...
lapply(1:dim(df)[1], FUN = function(x)
fitted.values(glm(dep ~ indep, family = myFamily, maxit = myMaxit, data=df[-x,])) )
Upvotes: 1