Warning: package 'AER' was built under R version 4.3.3
Loading required package: car
Warning: package 'car' was built under R version 4.3.3
Loading required package: carData
Warning: package 'carData' was built under R version 4.3.3
Loading required package: lmtest
Warning: package 'lmtest' was built under R version 4.3.3
Loading required package: zoo
Warning: package 'zoo' was built under R version 4.3.3
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
Loading required package: sandwich
Warning: package 'sandwich' was built under R version 4.3.3
Loading required package: survival
data("CPSSW8")
plot(CPSSW8$age, CPSSW8$learnings, xlab="Age", ylab= "Average Hourly Earnings")
model <- lm(course_eval ~ beauty, data = TeachingRatings)
intercept <- coef(model)[1]
slope <- coef(model)[2]
cat("Estimated Intercept:", intercept, "\n")
Estimated Intercept: 3.998272
cat("Estimated Slope:", slope, "\n")
Estimated Slope: 0.1330014
mean_beauty <- mean(TeachingRatings$beauty)
sd_beauty <- sd(TeachingRatings$beauty)
hawthorne_beauty <- mean_beauty
winger_beauty <- mean_beauty + sd_beauty
hawthorne_eval <- intercept + slope * hawthorne_beauty
winger_eval <- intercept + slope * winger_beauty
cat("Predicted course evaluation for Professor Hawthorne:", hawthorne_eval, "\n")
Predicted course evaluation for Professor Hawthorne: 3.998272
cat("Predicted course evaluation for Professor Winger", winger_eval, "\n")
Predicted course evaluation for Professor Winger 4.103163