`R/bpc_get_probabilities.R`

`get_probabilities_df.Rd`

Get the empirical win/draw probabilities based on the ability/strength parameters.

get_probabilities_df(bpc_object, newdata = NULL, n = 100, model_type = NULL)

bpc_object | a bpc object |
---|---|

newdata | default to NULL. If used, it will calculate the probabilities only for the newdata. Otherwise it will calculate for all combinations |

n | number of samples to draw from the posterior |

model_type | when dealing with some models (such as random effects) one might want to make predictions using the estimated parameters with the random effects but without specifying the specific values of random effects to predict. Therefore one can set a subset of the model to make predictions. For example: a model sampled with bt-U can be used to make predictions of the model bt only. |

a data frame table with the respective probabilities

# \donttest{ m<-bpc(data = tennis_agresti, player0 = 'player0', player1 = 'player1', result_column = 'y', model_type = 'bt', solve_ties = 'none') #> Running MCMC with 4 parallel chains... #> #> Chain 1 finished in 3.0 seconds. #> Chain 3 finished in 3.1 seconds. #> Chain 2 finished in 3.2 seconds. #> Chain 4 finished in 3.0 seconds. #> #> All 4 chains finished successfully. #> Mean chain execution time: 3.0 seconds. #> Total execution time: 3.2 seconds. prob<-get_probabilities_df(m) print(prob) #> i j i_beats_j j_beats_i #> 1 Graf Navratilova 0.69 0.31 #> 2 Graf Sabatini 0.78 0.22 #> 3 Graf Sanchez 0.93 0.07 #> 4 Graf Seles 0.61 0.39 #> 5 Navratilova Sabatini 0.60 0.40 #> 6 Navratilova Sanchez 0.68 0.32 #> 7 Navratilova Seles 0.46 0.54 #> 8 Sabatini Sanchez 0.75 0.25 #> 9 Sabatini Seles 0.37 0.63 #> 10 Sanchez Seles 0.19 0.81 # Now we can try just specifying a few data combinations of probabilities m2<-bpc(data = tennis_agresti, player0 = 'player0', player1 = 'player1', result_column = 'y', model_type = 'bt', solve_ties = 'none') #> Running MCMC with 4 parallel chains... #> #> Chain 2 finished in 2.9 seconds. #> Chain 3 finished in 3.2 seconds. #> Chain 1 finished in 3.4 seconds. #> Chain 4 finished in 3.3 seconds. #> #> All 4 chains finished successfully. #> Mean chain execution time: 3.2 seconds. #> Total execution time: 3.5 seconds. prob<-get_probabilities_df(m2, newdata=tennis_agresti[c(1,15),]) print(prob) #> i j i_beats_j j_beats_i #> 1 Seles Graf 0.60 0.40 #> 2 Graf Sabatini 0.22 0.78 # }