pga = read.csv('C:/Users/13175/Downloads/PgaTour5.csv',header = T)
head(pga)
##    Player.Name AvgScore DriveDst FrwyHit PttsperHo GreensReg AvgFin   TotWin
## 1  S.Scheffler    69.02    297.9   73.54     1.668     76.13   5.11 15093235
## 2    R.McIlroy    70.68    312.2   72.05     1.744     67.87  22.14  1608505
## 3       J.Rahm    68.82    304.0   55.71     1.580     74.81  12.17  9871540
## 4      W.Clark    70.22    309.2   58.29     1.698     71.33  22.00  7951009
## 5 X.Schauffele    69.92    302.4   68.78     1.706     71.40  12.56  5284208
## 6    V.Hovland    72.10    300.4   65.19     1.725     66.96  33.00   653025
summary(pga)
##  Player.Name           AvgScore        DriveDst        FrwyHit     
##  Length:25          Min.   :68.82   Min.   :285.5   Min.   :55.71  
##  Class :character   1st Qu.:70.57   1st Qu.:295.8   1st Qu.:65.19  
##  Mode  :character   Median :70.88   Median :299.5   Median :68.21  
##                     Mean   :70.79   Mean   :299.1   Mean   :68.33  
##                     3rd Qu.:71.21   3rd Qu.:302.4   3rd Qu.:72.05  
##                     Max.   :72.10   Max.   :312.2   Max.   :81.21  
##    PttsperHo       GreensReg         AvgFin          TotWin        
##  Min.   :1.580   Min.   :63.58   Min.   : 5.11   Min.   :  443873  
##  1st Qu.:1.705   1st Qu.:65.94   1st Qu.:22.14   1st Qu.: 2026050  
##  Median :1.725   Median :67.87   Median :32.83   Median : 2150141  
##  Mean   :1.728   Mean   :68.41   Mean   :32.57   Mean   : 3736763  
##  3rd Qu.:1.753   3rd Qu.:70.00   3rd Qu.:37.40   3rd Qu.: 4492870  
##  Max.   :1.813   Max.   :76.13   Max.   :62.60   Max.   :15093235

Regression Model Total Variables

model1 = lm(log(TotWin)~GreensReg+AvgScore+DriveDst+FrwyHit+PttsperHo+AvgFin, data = pga)
summary(model1)
## 
## Call:
## lm(formula = log(TotWin) ~ GreensReg + AvgScore + DriveDst + 
##     FrwyHit + PttsperHo + AvgFin, data = pga)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.71570 -0.22438  0.00649  0.32519  0.58231 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept) 59.456310  15.463629   3.845  0.00119 **
## GreensReg    0.002546   0.054005   0.047  0.96292   
## AvgScore    -0.534520   0.184430  -2.898  0.00958 **
## DriveDst    -0.035559   0.018040  -1.971  0.06429 . 
## FrwyHit     -0.022341   0.021628  -1.033  0.31531   
## PttsperHo    3.764253   3.008743   1.251  0.22691   
## AvgFin      -0.040554   0.011051  -3.670  0.00175 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4247 on 18 degrees of freedom
## Multiple R-squared:  0.8071, Adjusted R-squared:  0.7427 
## F-statistic: 12.55 on 6 and 18 DF,  p-value: 1.392e-05

Total Winnings ~ strongest variables

model2 = lm(TotWin~GreensReg+AvgScore+AvgFin, data=pga)
summary(model2)
## 
## Call:
## lm(formula = TotWin ~ GreensReg + AvgScore + AvgFin, data = pga)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2707070 -1099062   144919   890511  3892950 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept) 113594600   54395693   2.088  0.04913 * 
## GreensReg      348907     195198   1.787  0.08831 . 
## AvgScore     -1864448     649514  -2.871  0.00916 **
## AvgFin         -53304      36590  -1.457  0.15996   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1576000 on 21 degrees of freedom
## Multiple R-squared:  0.8011, Adjusted R-squared:  0.7727 
## F-statistic: 28.19 on 3 and 21 DF,  p-value: 1.48e-07

Quadratic Model

model3 = lm(TotWin~GreensReg+(AvgScore^2)+AvgFin, data=pga)
summary(model3)
## 
## Call:
## lm(formula = TotWin ~ GreensReg + (AvgScore^2) + AvgFin, data = pga)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2707070 -1099062   144919   890511  3892950 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept) 113594600   54395693   2.088  0.04913 * 
## GreensReg      348907     195198   1.787  0.08831 . 
## AvgScore     -1864448     649514  -2.871  0.00916 **
## AvgFin         -53304      36590  -1.457  0.15996   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1576000 on 21 degrees of freedom
## Multiple R-squared:  0.8011, Adjusted R-squared:  0.7727 
## F-statistic: 28.19 on 3 and 21 DF,  p-value: 1.48e-07

Interaction Term

model4 = lm(TotWin~GreensReg*AvgScore+AvgFin, data=pga)
summary(model4)
## 
## Call:
## lm(formula = TotWin ~ GreensReg * AvgScore + AvgFin, data = pga)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2324844  -858482    87524   509094  2245499 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)   
## (Intercept)        -1.353e+09  5.205e+08  -2.600  0.01714 * 
## GreensReg           2.130e+07  7.406e+06   2.876  0.00934 **
## AvgScore            1.897e+07  7.386e+06   2.569  0.01831 * 
## AvgFin             -5.310e+04  3.168e+04  -1.676  0.10930   
## GreensReg:AvgScore -2.978e+05  1.052e+05  -2.830  0.01035 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1364000 on 20 degrees of freedom
## Multiple R-squared:  0.858,  Adjusted R-squared:  0.8296 
## F-statistic:  30.2 on 4 and 20 DF,  p-value: 3.202e-08

#Answers to Step3: This model will provide the most accurate prediction, as the adjusted r-squared value is the highest.

85.8% of variation in an average pro golfer’s winnings is explained by greens in regulation*average score, and average finish.

Coefficients: - for every additional increase in the GIR statistic, the yearly average total winnings will increase by about $21 million - for every additional decrease in average score, the yearly average total winnings will increase by about $18 million - for every additional decrease in average finishm the yearly average total winnings will increase by about $53 thousand.

Scatterplot of Greens in regulation against total winnings

library(ggplot2)
attach(pga)
ggplot(data = pga, aes(x = GreensReg, y = TotWin)) +
geom_point() +
geom_smooth(method = "lm") +
labs(title = "OLS",
x = "% Greens in Reg",
y = "2024 Earnings")
## `geom_smooth()` using formula = 'y ~ x'

Scatterplot of Total Average Score against total winnings

library(ggplot2)
attach(pga)
## The following objects are masked from pga (pos = 3):
## 
##     AvgFin, AvgScore, DriveDst, FrwyHit, GreensReg, Player.Name,
##     PttsperHo, TotWin
ggplot(data = pga, aes(x = AvgScore, y = TotWin)) +
geom_point() +
geom_smooth(method = "lm") +
labs(title = "OLS",
x = "Average Score",
y = "2024 Earnings")
## `geom_smooth()` using formula = 'y ~ x'

### Regression model of average score compared against earnings

model5 = lm(TotWin~AvgFin, data = pga)
summary(model5)
## 
## Call:
## lm(formula = TotWin ~ AvgFin, data = pga)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -4025899 -1358532  -170402   551332  6358954 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  9664426    1157216   8.351 2.04e-08 ***
## AvgFin       -182025      32843  -5.542 1.23e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2209000 on 23 degrees of freedom
## Multiple R-squared:  0.5718, Adjusted R-squared:  0.5532 
## F-statistic: 30.72 on 1 and 23 DF,  p-value: 1.228e-05
pga %>%
  drop_na(DriveDst) %>%
  mutate(Over300 = ifelse(DriveDst >= 300,1,0)) -> pga_grp
model6=lm(TotWin ~ Over300,data = pga_grp)
summary(model6)
## 
## Call:
## lm(formula = TotWin ~ Over300, data = pga_grp)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -3193737 -1820712 -1485083   857646 11458011 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3635225     935858   3.884 0.000749 ***
## Over300       211538    1350795   0.157 0.876925    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3374000 on 23 degrees of freedom
## Multiple R-squared:  0.001065,   Adjusted R-squared:  -0.04237 
## F-statistic: 0.02452 on 1 and 23 DF,  p-value: 0.8769
result=exp(15.66)
print(result)
## [1] 6324870

Answers to Step 4

We chose to select Saheeth Theegala from our data set, the 16th best golfer in the world at the time our data was taken. The best model that we created was model3. By plugging the figures in by hand, we predicted that his yearly golf earnings would be 6.32 million. His actual golf earnings are 4.4 million. The percentage error between these two values is 43.6%. This percentage error could be due to a number of factors, but I would expect that this difference was mostly due to unknown factors not included in our model predicting golf earnings.