library("topmodels")
## Poisson regression model for FIFA 2018 data:
## number of goals scored by each team in each game, explained by
## predicted ability difference of the competing teams
data("FIFA2018", package = "distributions3")
m <- glm(goals ~ difference, data = FIFA2018, family = poisson)
## prediction using a new data set (final of the tournament)
final <- tail(FIFA2018, 2)
## base predict method computes linear predictor on link scale (here in logs)
predict(m, newdata = final) 127 128
0.47275699 -0.04731455
distribution
127 Poisson(lambda = 1.6044114)
128 Poisson(lambda = 0.9537873)
## all other procast types are available as well
predict(pm, newdata = final, type = "density", at = 0:4) d_0 d_1 d_2 d_3 d_4
127 0.2010078 0.3224993 0.2587107 0.13835949 0.05549639
128 0.3852791 0.3674743 0.1752462 0.05571586 0.01328527
predict(pm, newdata = final, type = "cdf", at = 0:4) p_0 p_1 p_2 p_3 p_4
127 0.2010078 0.5235071 0.7822178 0.9205773 0.9760737
128 0.3852791 0.7527534 0.9279995 0.9837154 0.9970007
1 2 3 4 5 6
1.98287409 -1.31569179 -1.43503752 -0.42419390 1.13746339 -0.06469232
1 2 3 4 5 6
2.1762144 -0.3493612 -0.7490645 -0.3311326 1.0111548 0.1040442