---
title: "Answer Key: PBR Bulls"
format: 
  html:
    embed-resources: true
---

Experience the adrenaline-packed world of professional bull riding (PBR), where the spotlight shines not only on the daring riders but also on the powerful bulls. In this worksheet, we'll dive into the data from the 2023 season of the Touring Pro Division to understand how points are achieved by bulls themselves.

```{r,message=FALSE, warning=FALSE}
library(tidyverse)
bulls <- read_csv(here::here("Bull Riding/data/Bulls.csv"))
```



# 1.  

**Fit a logistic regression model where we want to predict the probability of a bull gets over a 45pt ride using average buckoff time.**

## A. 

**Fit the model and rite out the predicted model.**
	
```{r}
mod <- glm(fortyFivePt_Rides ~ Avg_Buckoff_Time, data = bulls, family = binomial)
summary(mod)
```
	*logit:*
	
  $\widehat{ln(\pi/1-\pi)} = -0.004223 - 0.073787*Avg.Buckoff.Time$
  
  *Probability:*
  
  $\widehat{\pi} = e^{(-0.004223 - 0.073787*Avg.Buckoff.Time)} / (1 + e^{(-0.004223 - 0.073787*Avg.Buckoff.Time)})$

## B. 

**Calculate the estimated odds ratio of the model**

```{r}
(estOddsRatio = exp(-0.073787))
```

	*The estimated odds ratio of the model is 0.928.*
	

## C. 

**Given that the bulls average buckoff time is 2.20 seconds, what is the predicted probability that the bull will achieve a 45pt ride?**

```{r}
Avg_Buckoff_Time = 2.20
(pi = exp(-0.004223 - 0.073787*Avg_Buckoff_Time) / (1 + exp(-0.004223 - 0.073787*Avg_Buckoff_Time)))
```

	*If the bulls average buckoff time is 2.20 seconds then it has a 45.8% chance of achieving a 45pt ride or greater.*
	
	
	
## D.

**Calculate the average buckoff time of a bull given that odds are 50:50.**

```{r}
percentFromOdds = 50/100
(Avg_Buckoff_Time = (-0.004223 - percentFromOdds) / -0.073787)
```

	*With 50:50 odds the average buckoff time is 0.06 seconds.*
	
	
	
	
	
