# Out of sample predictions for logistic regression models in R

I have a problem of the form "what is the probability that a user will 'like' a certain movie?" For a bunch of users, I know the movies each has watched historically, and the movies each has liked. Additionally, for each movie I know the name of the director.

I calibrated a logistic regression for each user of the form:

glm(liked_by_user_1 ~ liked_by_user_2 + ... + liked_by_user_k + factor(director), family=binomial, data = subset(MovieWatchings, user_id == 1))

But my problem is: say that in the past, user 1 has watched movies from directors D1 through DM, but next month U1 watches a movie directed by DN? In that case the R predict() function will give an error, because the glm model for user 1 doesn't have an estimated parameter for the case of director = DN. But I must know something about U1's probability of liking the new movie, because I still know which other users have seen and liked this movie, and that has some predictive power.

How can I set up my model so that I can take into account other users' liking behavior, AND user 1's director preferences, but still have sensible predictions when user 1 sees his first movie from a new director? Is logistic regression even the right type of model for this case?

-
While I have never conducted a similar study myself, this seems like the Netflix problem, which uses collaborative filtering (I believe). Check out the package this package. cran.r-project.org/web/packages/recommenderlab/vignettes/… –  Btibert3 Feb 21 '12 at 18:49
Random effect for director? –  conjugateprior Mar 23 '12 at 8:57
If you know nothing about director N (ie whether they make similar movies to director G) it would seem to me that your best chance would be to substitute for factor(director) in your linear predictor the "average" value of the director coefficients. This would require estimating who the average director is and using them instead of DN.
Alternatively, you could fit the model without the factor(director) as an explanatory variable at all. If the purpose is to predict a value based on a certain set of explanatory variables, there's not good including in the model something that isn't going to be available to the predictor.
A final comment, not really part of the "answer" to your question - it seems likely that the variables liked_by_user_2 ... liked_by_user_k will be highly collinear. Collinearity can play havoc with predictive models; one reason why parsimonious models are generally preferred for predictve purposes. Whether this is a problem for you (and what should be done about it) depends on how big k is compared to your sample size.