library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.2 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.3 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggplot2)
library(dbplyr)
##
## Attaching package: 'dbplyr'
##
## The following objects are masked from 'package:dplyr':
##
## ident, sql
library(ggthemes)
library(ggrepel)
library(ggrepel)
library(broom)
library(lindia)
week3_dataset <- read.csv("baseball.csv",header = TRUE)
model <- glm(Playoffs ~ W, data = week3_dataset,
family = binomial(link = 'logit'))
model$coefficients
## (Intercept) W
## -34.206104 0.372348
sigmoid <- \(x) 1 / (1 + exp(-(-34.206 + 0.372 * x)))
week3_dataset %>%
ggplot(mapping = aes(x = W, y = Playoffs)) +
geom_jitter(width = 0, height = 0.1, shape = 'O', size = 3) +
geom_function(fun = sigmoid, color = 'blue', linewidth = 1)+
labs(title = "Modeling a Binary Response with Playsoff teams and Wins") +
scale_y_continuous(breaks = c(0, 1)) +
theme_minimal()
0 = -34.206 + 0.372* W
w = 34.206/0.372
w
## [1] 91.95161
w = 91.95 This means that when a team wins 91 games, then then have a 50/50 chance of making the playoffs