1
$\begingroup$

I have created a model using glmer(). The battle_seq_num is the number of sessions, each player_idhas 100 sessions (observations). My goal is to make a prediction for the test sample whether they are going to buy a membership or not. xp is a continuous quantitative variable.

m2 <- glmer(is_tier_ten ~ xp + battle_seq_num + (battle_seq_num || player_id), family = binomial(link="logit"), control = glmerControl(optimize = "nloptwrap"), data = dfs)

summary(m2) returns:

Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
 Family: binomial  ( logit )
Formula: is_tier_ten ~ xp + battle_seq_num + (battle_seq_num || player_id)
   Data: dfs
Control: glmerControl(optimize = "nloptwrap")

     AIC      BIC   logLik deviance df.resid 
 10911.5  10969.4  -5450.7  10901.5   799995 

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-0.01098  0.00000  0.00000  0.00000  0.10277 

Random effects:
 Groups      Name           Variance  Std.Dev. 
 player_id   (Intercept)    1.476e-05  0.003841
 player_id.1 battle_seq_num 1.379e+03 37.130895
Number of obs: 800000, groups:  player_id, 8000

Fixed effects:
               Estimate Std. Error z value Pr(>|z|)    
(Intercept)    -3.01428    0.34902  -8.636   <2e-16 ***
xp              0.07115    0.06879   1.034    0.301    
battle_seq_num -6.79224    0.40190 -16.900   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
            (Intr) xp    
xp          -0.047       
battl_sq_nm -0.921  0.025

Prediction:

str(p2 <- predict(m2,bs2, allow.new.levels = TRUE, type = "response"))

Result:

       39046        32744        36225        40022        37105        32809        39818        41095        38585        36820        40429 
1.000000e+00 1.000000e+00 1.000000e+00 3.631456e-12 9.999998e-01 1.513329e-11 2.048973e-13 2.220446e-16 2.220446e-16 2.220446e-16 1.000000e+00 
       36854        42161         3625        40777        50639        37231        36263        36170        36179       159788       186746 
2.220446e-16 2.220446e-16 2.220446e-16 2.220446e-16 2.220446e-16 2.220446e-16 2.220446e-16 2.220446e-16 2.220446e-16 2.220446e-16 2.220446e-16 

While my identifiers for bs2 are:

       [1]    7   10   16   27   29   32   37   51   58   60   64   75   77   80   87   90   98  102  103  108  113  121  122  130  136  141  150  166
  [29]  174  184  189  193  194  198  204  212  214  230  232  233  235  241  258  267  271  279  280  282  287  293  294  295  296  299  303  313
  [57]  315  330  336  346  347  355  358  361  367  387  399  404  405  414  420  424  432  446  454  456  459  469  472  484  488  495  496  506
  [85]  524  526  528  530  531  537  541  542  550  551  552  553  561  582  587  588  591  595  605  606  622  624  634  656  664  665  671  674
 [113]  676  680  681  691  694  702  705  711  714  717  720  722  729  734  737  744  759  760  765  766  772  777  786  789  793  804  819  823
 [141]  825  827  840  849  855  868  869  870  871  874  878  890  898  907  909  916  919  921  924  927  933  938  939  942  944  947  956  958
 [169]  961  974  980  984  987  989  990  991  997 1006 1007 1019 1022 1025 1028 1029 1031 1032 1034 1038 1043 1053 1055 1059 1060 1066 1071 1073
 [197] 1076 1077 1080 1092 1098 1100 1101 1104 1110 1114 1120 1126 1129 1133 1136 1137 1145 1150 1161 1163 1167 1169 1180 1185 1189 1193 1201 1203

Is there any way of making a prediction with the initials ids? Just a prediction of whether a person will become is_tier_ten generally for each id and not for every repeated obs (battle_seq_num). As a result, I have to make a .csv document for every id from bs2 with individual prediction.

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.