series_probability: Calculate the probability of winning a series

Description Usage Arguments Examples

Description

Calculate the probability of winning a series

Usage

1
2
3
4
series_probability(theta1, theta2, alpha1, alpha2, alpha, series_length = 1,
  ...)

series_probability_df(data, series_length = 1, ...)

Arguments

theta1

value of theta

theta2

value of theta for other team

alpha1

HFA for team1

alpha2

HFA for team2

alpha

HFA for overall sport

series_length

number of games in the series

...

currently ignored

data

a data frame like bigfour_end

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
if (require(dplyr)) {

  # should be around 40%
  series_probability(spurs_bulls$mean_theta[1], spurs_bulls$mean_theta[2],
                     spurs_bulls$mean_alpha[1], spurs_bulls$mean_alpha[2],
                     spurs_bulls$alpha_sport[1], series_length = 1)
  long_run_prob(spurs_bulls, n = 10)

  series_probability(spurs_bulls$mean_theta[1], spurs_bulls$mean_theta[2],
                     spurs_bulls$mean_alpha[1], spurs_bulls$mean_alpha[2],
                     spurs_bulls$alpha_sport[1], series_length = 7)
  long_run_prob(spurs_bulls, n = 10, series_length = 7)

  # should be nearly certain
  series_probability(spurs_bulls$mean_theta[1], spurs_bulls$mean_theta[2],
                     spurs_bulls$mean_alpha[1], spurs_bulls$mean_alpha[2],
                     spurs_bulls$alpha_sport[1], series_length = 99)
  long_run_prob(spurs_bulls, n = 10, series_length = 99)
}

# Spurs at home, single game
if (require(dplyr)) {
  x <- spurs_bulls %>%
    rename(theta = mean_theta, alpha = mean_alpha) %>%
    arrange(desc(theta))

  series_probability_df(x, 1)
  series_probability_df(arrange(x, theta), 1)

  # Spurs at home, seven game series
  series_probability_df(x, 7)

  # Spurs at home, 99 game series
  series_probability_df(x, 99)

  # monotonic increase for Spurs
  sapply(seq(1, 15, by = 2), series_probability_df,
         data = x)

  # monotonic decrease for Bulls
  sapply(seq(1, 15, by = 2), series_probability_df,
         data = arrange(x, theta))
}

beanumber/tourneyr documentation built on May 27, 2019, 4:49 a.m.