This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Cmd+Shift+Enter.
library(tidyverse)
library(dplyr)
library(ggplot2)
library(readr)
library(MASS)
library(tidyr)
require(sandwich)
require(msm)
setwd("/Users/akashchoudhury/Desktop/nba")
Warning: The working directory was changed to /Users/akashchoudhury/Desktop/nba inside a notebook chunk. The working directory will be reset when the chunk is finished running. Use the knitr root.dir option in the setup chunk to change the working directory for notebook chunks.
full <- read.csv("nba_full.csv")
full %>% count(Lower.Extremity.Structure)
full %>% count(Brand.Shoe.Model.Simplified)
full %>% count(Brand)
full %>% count(Lower.Extremity.Structure.Coded)
NA
full %>% count(Brand.Coded)
setwd("/Users/akashchoudhury/Desktop/nba")
Warning: The working directory was changed to /Users/akashchoudhury/Desktop/nba inside a notebook chunk. The working directory will be reset when the chunk is finished running. Use the knitr root.dir option in the setup chunk to change the working directory for notebook chunks.
mod <- read.csv("poi_2.csv")
mod$Brand <- as.factor(mod$Brand)
mod$Brand <- relevel(mod$Brand, ref = "1")
model_poi <- glm(Injury.Count ~ Brand + offset(log(Minute)), data = mod, family = poisson)
summary(model_poi)
Call:
glm(formula = Injury.Count ~ Brand + offset(log(Minute)), family = poisson,
data = mod)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -6.77103 0.02716 -249.336 < 2e-16 ***
Brand2 0.15378 0.06498 2.367 0.01794 *
Brand3 0.14557 0.07478 1.947 0.05158 .
Brand4 0.35556 0.12257 2.901 0.00372 **
Brand5 0.04702 0.11244 0.418 0.67577
Brand6 0.34674 0.11862 2.923 0.00347 **
Brand7 -0.05399 0.15668 -0.345 0.73039
Brand8 -0.00679 0.14992 -0.045 0.96387
Brand9 1.78060 0.33444 5.324 1.01e-07 ***
Brand10 -0.16495 0.23102 -0.714 0.47520
Brand11 -0.32875 0.21027 -1.563 0.11796
Brand12 0.94700 0.28995 3.266 0.00109 **
Brand13 0.26363 0.28995 0.909 0.36323
Brand14 -0.84501 0.70763 -1.194 0.23242
Brand15 -0.59983 1.00036 -0.600 0.54876
Brand16 0.43067 0.70763 0.609 0.54278
Brand17 -0.04186 0.70763 -0.059 0.95282
Brand18 -1.10085 0.70763 -1.556 0.11978
Brand22 0.65772 0.40915 1.608 0.10794
Brand23 -0.20998 0.70763 -0.297 0.76667
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 5.8685e+01 on 19 degrees of freedom
Residual deviance: 2.6201e-14 on 0 degrees of freedom
AIC: 134.71
Number of Fisher Scoring iterations: 3
IRR <- exp(coef(model_poi))
conf_int <- exp(confint(model_poi))
Waiting for profiling to be done...
p_values <- summary(model_poi)$coefficients[, 4]
results <- data.frame(
Brand = rownames(summary(model_poi)$coefficients),
IRR = IRR,
Lower_CI = conf_int[, 1],
Upper_CI = conf_int[, 2],
p_value = p_values
)
# Display the table
print(results)
```