Exercise 1: Predict Runs Scored

If a baseball team’s OBP is 0.361 and SLG is 0.409, how many runs do we expect the team to score? Using the linear regression model constructed during the lecture (the one that uses OBP and SLG as independent variables), find the number of runs we expect the team to score:

# RS = -804.63 + 2737.77 * OBP + 1584.91 * SLG

# Given values
OBP <- 0.361
SLG <- 0.409

# Calculate expected runs scored
RS <- -804.63 + 2737.77 * OBP + 1584.91 * SLG
print(paste("Expected Runs Scored:", round(RS, 2)))
## [1] "Expected Runs Scored: 831.93"

Exercise 2: Predict Runs Allowed

If a baseball team’s opponents OBP (OOBP) is 0.267 and opponents SLG (OSLG) is 0.392, how many runs do we expect the team to allow? Using the linear regression model discussed during the lecture (the one on the last slide of the previous video), find the number of runs we expect the team to allow.

# RA = -837.38 + 2913.60 * OOBP + 1514.29 * OSLG

# Given values
OOBP <- 0.267
OSLG <- 0.392

# Calculate expected runs allowed
RA <- -837.38 + 2913.60 * OOBP + 1514.29 * OSLG
print(paste("Expected Runs Allowed:", round(RA, 2)))
## [1] "Expected Runs Allowed: 534.15"