View source: R/scoringprobability.R
scoringprobability | R Documentation |
Computes the probability of scoring certain shot types in certain conditions, by looking at the result of the shots in the PbP provided
scoringprobability(
PbP_data,
team_name = "",
shotclock_interval = c(0, 24),
totaltime = 0,
score_difference = c(-100, 100),
shot_type = "field",
team_data
)
PbP_data |
a play-by-play dataframe, previously handled by the PbPmanipulation function |
team_name |
character, if the play-by-play dataframe given as an input contains data for multiple teams, this parameters filters only the shots of the team we are interested in |
shotclock_interval |
vector of two numeric values or single numeric value, condition on the value of shotclock of the shots that will be considered |
totaltime |
numeric value, condition on the value of totalTime of the shots that will be considered |
score_difference |
vector of two numeric values or single numeric value, condition on the value of shotclock of the shots that will be considered |
shot_type |
character, the type of shots to be analyzed; available options: "2P", "3P", "FT", "field" |
team_data |
dataframe, contains several data regarding the teams in the NBA. Inside this function it is used only to check if |
numeric value, indicating the probability that a shots which respects all the conditions defined is made
Andrea Fox
P. Zuccolotto and M. Manisera (2020) Basketball Data Science: With Applications in R. CRC Press.
P. Zuccolotto, M. Manisera and M. Sandri (2018) Big data analytics for modeling scoring probability in basketball: The effect of shooting under high pressure conditions. International Journal of Sports Science & Coaching.
# probability that a 2 point shot attempted by the Golden State Warriors
# in the last two seconds of an action is made
PbP <- PbPmanipulation(PbP.BDB)
PbP <- scoredifference(PbP, team_name = "GSW", player_data=Pbox, team_data=Tadd)
PbP <- shotclock(PbP, sec_14_after_oreb = FALSE, team_data=Tadd)
scoringprobability(PbP, team_name = "GSW", shotclock_interval = c(0, 2),
shot_type = "2P", team_data=Tadd)
# probability that a 3 point shot attempted when the score difference is
# between -5 and 1 is made
PbP <- PbPmanipulation(PbP.BDB)
PbP <- scoredifference(PbP, team_name = "GSW", player_data=Pbox, team_data=Tadd)
PbP <- shotclock(PbP, sec_14_after_oreb = FALSE, team_data=Tadd)
scoringprobability(PbP, team_name = "GSW", score_difference = c(-5, 1),
shot_type = "3P", team_data=Tadd)
# probability that a free throw attempted in the last 5 minutes is made
PbP <- PbPmanipulation(PbP.BDB)
PbP <- scoredifference(PbP, team_name = "GSW", player_data=Pbox, team_data=Tadd)
PbP <- shotclock(PbP, sec_14_after_oreb = FALSE, team_data=Tadd)
scoringprobability(PbP, team_name = "GSW", totaltime = 43, shot_type = "FT",
team_data=Tadd)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.