vs_simulate_set | R Documentation |
vs_simulate_set_theor
and vs_simulate_set_mc
are convenience functions for vs_simulate_set(..., method = "theoretical")
and vs_simulate_set(..., method = "monte carlo")
respectively.
vs_simulate_set(
rates,
process_model = "phase",
serving = NA,
go_to = 25,
point_margin = 2,
simple = FALSE,
id = NULL,
method = "theoretical"
)
vs_simulate_set_mc(...)
vs_simulate_set_theor(...)
rates |
list: A two-element list, each element of which is a set of rates as returned by
|
process_model |
string: either "sideout" or "phase". The "sideout" model uses the estimated sideout rates (in the |
serving |
logical: if |
go_to |
integer: the minimum score that must be reached to end the set (typically 25 for indoor volleyball in sets 1 to 4, 15 in set 5, or 21 in beach volleyball) |
point_margin |
integer: the minimum score difference in order to win the set. Only applicable to |
simple |
logical: if |
id |
: an optional value that (if non- |
method |
string: the simulation method to use. Either "monte carlo" or "theoretical". Details TBD |
... |
: parameters as for |
Integer (1 or 2) or a data frame, depending on the value of simple
vs_estimate_rates()
vs_simulate_match()
## Not run:
library(datavolley)
x <- dv_read(dv_example_file())
rates <- vs_estimate_rates(x, target_team = "each")
vs_simulate_set(rates) ## simulate a single set
vs_simulate_match(rates) ## simulate a match
## so given the performances of the two teams during that match, we expect
## that the home team should have won, with 3-0 being the most likely scoreline
## compare to the actual match result
summary(x)
## End(Not run)
## sideout rates as a function for team 2
sofun2 <- function(serving, point_won_by, ...) {
## if team 2 won their previous sideout opportunity, their sideout rate is 0.6
## otherwise it's 0.5
prevso <- tail(na.omit(point_won_by[serving == 1]), 1)
if (length(prevso) < 1 || prevso == 1) {
## first sideout opportunity or lost the last one
0.5
} else {
0.6
}
}
rates <- list(list(sideout = 0.55), ## first team has constant 55% sideout rate
list(sideout = sofun2)) ## function for team 2's sideout rate
## need to use method = "monte carlo" for this
vs_simulate_set(rates = rates, process_model = "sideout", method = "monte carlo")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.