#Necessary libraries

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(pwr)
# Loading the dataset
data <- read.csv("player_data.csv")
linear_model <- lm(Wt ~ Colleges, data = data)
# Diagnostic plots
par(mfrow = c(2, 2))  # Create a 2x2 grid of plots
plot(linear_model)
## Warning: not plotting observations with leverage one:
##   38, 50, 73, 80, 85, 93, 122, 154, 307, 333, 337, 368, 371, 403, 439, 440, 453, 476, 488, 524, 535, 550, 559, 571, 572, 609, 651, 665, 669, 686, 693, 694, 720, 732, 735, 765, 818, 823, 827, 828, 844, 901, 902, 916, 931, 936, 975, 1057, 1096, 1114, 1141, 1148, 1163, 1169, 1433, 1436, 1440, 1491, 1494, 1516, 1519, 1533, 1555, 1560, 1571, 1576, 1581, 1587, 1593, 1601, 1619, 1629, 1638, 1648, 1687, 1714, 1737, 1741, 1785, 1793, 1813, 1827, 1841, 1864, 1871, 1877, 1878, 1910, 1933, 1962, 1998, 2000, 2010, 2055, 2060, 2085, 2130, 2131, 2137, 2160, 2161, 2165, 2183, 2191, 2199, 2214, 2220, 2226, 2228, 2234, 2240, 2243, 2245, 2251, 2260, 2273, 2347, 2361, 2366, 2433, 2438, 2465, 2504, 2510, 2513, 2515, 2585, 2599, 2622, 2624, 2635, 2663, 2672, 2765, 2800, 2826, 2832, 2851, 2855, 2858, 2912, 2915, 2921, 2937, 2972, 3011, 3015, 3027, 3031, 3043, 3057, 3062, 3064, 3140, 3146, 3152, 3166, 3169, 3187, 3258, 3262, 3285, 3301, 3327, 3357, 3371, 3379, 3401, 3421, 3439, 3475, 3477, 3526, 3536, 3545, 3567, 3588, 3643, 3663, 3668, 3733, 3745, 3747, 3777, 3782, 3812, 3815, 3847, 3848, 3875, 3889, 3937, 3977, 3986, 3996, 4007, 4014, 4017, 4083, 4091, 4106, 4119, 4135, 4159, 4182, 4198, 4200, 4208, 4217, 4247, 4256, 4306, 4326, 4358, 4411, 4432, 4453, 4471, 4477, 4481, 4482, 4500, 4503, 4555, 4572, 4580, 4612, 4658, 4665, 4695, 4736, 4778, 4779, 4782, 4786, 4790, 4796, 4801, 4819, 4845, 4853, 4861, 4863, 4895, 4897, 4898, 4904, 4944, 4954, 4964
## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced

## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced

Residuals vs. Fitted Values Plot

This plot appears to show a slight U-shaped pattern, suggesting that the relationship between my dependent variable and independent variable may not be perfectly linear. This could indicate that a quadratic term or some other transformation of the independent variable might be needed to improve the fit of the model.

Residuals vs. Leverage Plot

This plot does not show any clear pattern, suggesting that there is no evidence of heteroscedasticity. This means that the variance of the residuals is approximately constant across the range of the independent variable.

Scale-Location Plot

This plot shows some deviation from the 45-degree reference line, suggesting that the residuals may not be perfectly normally distributed. However, the deviation is not severe, and it is possible that the normality assumption still holds.

QQ Plot

This plot also shows some deviation from the reference line, particularly at the tails of the distribution. This suggests that the normality assumption may be slightly violated. However, the deviation is not extreme, and it is possible that the model is still robust to violations of the normality assumption.

My diagnostic plots suggest that the linear regression model may not be a perfect fit for the data, but it is likely still a reasonable approximation. The slight U-shaped pattern in the residuals vs. fitted values plot suggests that a quadratic term or some other transformation of the independent variable might be worth considering. However, the absence of heteroscedasticity and the only mild violation of the normality assumption suggest that the model is not seriously flawed.

coeff_summary <- summary(linear_model)


#Extracting values of one of the college
coef_college <- coeff_summary$coefficients["CollegesAlabama", "Estimate"]

coef_college
## [1] -12.54615

The value of -12.54615 for “Alabama” suggests that, on average, individuals associated with this college tend to have a lower “Ht” compared to the reference category, and this effect is statistically significant.