I wrote a script that create a logistic model, for Email opening probability, for each user name.
form<-formula(OpenOrNor~as.factor(TimeSend)
+OpenWithSmartphoneind)
models<- dlply(Data, "User_id",
function(df) {
model<-glm(formula = form,family = binomial("logit"),data = df,control = glm.control(epsilon = 1e-9, maxit = 500))
return(model)})
for some users it return me
Call: glm(formula = form, family = binomial("logit"), data = df, weights = HistoryWeights,
control = glm.control(epsilon = 0.000000001, maxit = 500))
Coefficients:
(Intercept) as.factor(TimeSend)2 as.factor(TimeSend)3 as.factor(TimeSend)4
-22.61106 20.21853 0.07738 20.54737
as.factor(TimeSend)5 as.factor(TimeSend)6 as.factor(TimeSend)7 as.factor(TimeSend)9
0.19292 -0.03624 0.22013 0.11837
OpenWithSmartphoneind
NA
Degrees of Freedom: 83 Total (i.e. Null); 76 Residual
Null Deviance: 190.6
Residual Deviance: 166.8 AIC: 182.8
We can see that for OpenWithSmartphoneind their is NA. and this is because their are no Opening With Smartphone at all In this user history.
My question is how it will impact on predict?
And doe's it make different if OpenWithSmartphoneind in the formula will be a factor type or not?
OpenWithSmartphoneind
is NA throughout, is this because the value of that variable is unknown for those users, or because it always takes a "no" value? If the latter, maybe it's better to transform the NAs to 0s before modeling. If the former, though, this shouldn't affectpredict()
, because --- thanks to thedrop=TRUE
default indlply()
--- the models for the relevant users won't be looking for a variable with nothing but missing values. $\endgroup$ – ulfelder Aug 4 '15 at 13:11predict()
should work fine. Did you try applying it and have some kind of problem? $\endgroup$ – ulfelder Aug 4 '15 at 13:40