Poistan
We illustrate how the package works using the two included data sets.
The data set m
is made-up, but illustrates the kind of data that the package uses as input:
library(poistan) data(m) m
The data frame has four columns: the names of the home and away teams, and the number of goals scored by each in the game where they met. Thus, each row represents a game.
If necessary, the Stan model object must be compiled first:
poisson.sc=poistan:::compiled_model() poisson.sc
As long as the object poisson.sc
is kept around, this only ever needs to be done once (eg.\ when the package is first installed).
Before fitting the model, we have to create a design matrix X
and response matrix y
that represent the teams by numbers (and maintain a separate list of team names). This is done using makexy
:
xy=poistan:::makexy(m) xy
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.