# Loading my dataset
data <- read.csv("player_data.csv")
str(data)
## 'data.frame': 4979 obs. of 9 variables:
## $ Player : chr "Alaa Abdelnaby" "Zaid Abdul-Aziz" "Kareem Abdul-Jabbar*" "Mahmoud Abdul-Rauf" ...
## $ From : int 1991 1969 1970 1991 1998 1997 1977 1957 1947 2017 ...
## $ To : int 1995 1978 1989 2001 2003 2008 1981 1957 1948 2019 ...
## $ Pos : chr "F-C" "C-F" "C" "G" ...
## $ Ht : int 610 69 72 61 66 69 67 63 63 66 ...
## $ Wt : int 240 235 225 162 223 225 220 180 195 200 ...
## $ Birth.Date : chr "June 24 1968" "April 7 1946" "April 16 1947" "March 9 1969" ...
## $ Colleges : chr "Duke" "Iowa State" "UCLA" "LSU" ...
## $ numeric_date: int 610 69 72 61 66 69 67 63 63 66 ...
##Creating a Binary coloumn for students in UCLA vs Students not in UCLA
data$Attended_UCLA <- ifelse(data$Colleges == "UCLA", 1, 0)
## I am using Ht and Wt as my explanatory variable
model <- glm(Attended_UCLA ~ Ht + Wt, data = data, family = "binomial")
summary(model)
##
## Call:
## glm(formula = Attended_UCLA ~ Ht + Wt, family = "binomial", data = data)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -4.3512688 0.8740496 -4.978 6.41e-07 ***
## Ht 0.0001040 0.0005827 0.178 0.858
## Wt 0.0016844 0.0042270 0.398 0.690
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 908.53 on 4973 degrees of freedom
## Residual deviance: 908.27 on 4971 degrees of freedom
## (5 observations deleted due to missingness)
## AIC: 914.27
##
## Number of Fisher Scoring iterations: 6
(Intercept): -1.677e+00
This is the baseline log-odds of a player attending UCLA when the height (Ht) and weight (Wt) are both zero. The negative value means that the log-odds are in favor of not attending UCLA. Ht5-11: -8.941e-01
This coefficient represents the log-odds change in favor of attending UCLA for players with a height of 5’11” compared to players of the reference height (intercept). The negative value indicates that players with a height of 5’11” are less likely to attend UCLA compared to the reference category. Ht5-3: -1.478e+01
This coefficient suggests a significant decrease in the log-odds of attending UCLA for players with a height of 5’3” compared to the reference height. Ht5-5, Ht5-6, Ht5-7, Ht5-8, Ht5-9: These coefficients have negative values, indicating that players with these heights are less likely to attend UCLA compared to the reference height.
Ht6-0, Ht6-1, Ht6-10, Ht6-11, Ht6-2, Ht6-3, Ht6-5, Ht6-6, Ht6-7, Ht6-8, Ht6-9, Ht7-0, Ht7-1, Ht7-3, Ht7-5, Ht7-6, Ht7-7: These coefficients represent the log-odds change in favor of attending UCLA for players with different heights compared to the reference height. Values close to zero suggest little to no effect on the likelihood of attending UCLA.
Ht6-4: -1.785e+00
Wt: -9.195e-03
This coefficient represents the log-odds change in favor of attending UCLA for every one-unit increase in weight (Wt). The negative value implies that an increase in weight is associated with a decrease in the log-odds of attending UCLA. However, the p-value (0.19173) is above the significance level of 0.05, indicating that weight may not be statistically significant in predicting UCLA attendance. Residual Deviance: 878.47
confint(model, level = 0.95)
## Waiting for profiling to be done...
## 2.5 % 97.5 %
## (Intercept) -6.061350055 -2.637005117
## Ht -0.001110015 0.001190859
## Wt -0.006700388 0.009854276
A CI that includes zero for a coefficient suggests that the effect of that variable is not statistically significant. In my case, both “Ht” and “Wt” have CIs that include zero, which means that their effects on “Attended_UCLA” are not statistically significant at the 95% confidence level.
If the CI does not include zero, it indicates that the corresponding variable has a statistically significant effect on the binary outcome. Here, the CI for “Ht” and “Wt” includes zero, implying that there is no significant linear relationship between these variables and attending UCLA.
# Calculate the standard error for the "Wt" coefficient
se <- 7.044e-03
# Calculate the margin of error (critical value for a 95% confidence interval is approximately 1.96)
margin_of_error <- 1.96 * se
# Calculate the lower and upper bounds of the confidence interval
lower_bound <- -9.195e-03 - margin_of_error
upper_bound <- -9.195e-03 + margin_of_error
# Print the confidence interval
cat("95% Confidence Interval for Wt coefficient: [", lower_bound, ",", upper_bound, "]")
## 95% Confidence Interval for Wt coefficient: [ -0.02300124 , 0.00461124 ]
Interpretation:
The coefficient for “Wt” in your logistic regression model is -9.195e-03, which represents the change in log-odds of attending UCLA for every one-unit increase in weight. The 95% confidence interval for this coefficient spans from approximately -0.0211 to 0.0029. Since this interval contains zero (0), it suggests that the coefficient for weight “Wt” is not statistically significant in predicting whether a player attends UCLA or not.
# Load necessary libraries
library(ggplot2)
# Create scatter plot for Ht vs. Attended_UCLA
ggplot(data, aes(x = Ht, y = Attended_UCLA)) +
geom_point() +
labs(title = "Scatter Plot of Ht vs. Attended_UCLA", x = "Height (Ht)", y = "Attended UCLA (Binary)")
# Create scatter plot for Wt vs. Attended_UCLA
ggplot(data, aes(x = Wt, y = Attended_UCLA)) +
geom_point() +
labs(title = "Scatter Plot of Wt vs. Attended_UCLA", x = "Weight (Wt)", y = "Attended UCLA (Binary)")
## Warning: Removed 5 rows containing missing values (`geom_point()`).
No Clear Relationship between the explanatory variable and the response so transformation does not feel necessary because the variable may not be a strong predictor.