# ferdo R Lab | Lesson 5 v1.0 | Student independent tasks # All records are invented. Keep data/class_synthetic.csv untouched. stopifnot(file.exists("data/class_synthetic.csv")) d <- read.csv("data/class_synthetic.csv", na.strings=c("","NA"),stringsAsFactors=FALSE) ok <- complete.cases(d[,c("study_hours","quiz_score")]) paired <- d[ok, ,drop=FALSE] # TODO 1: Count complete pairs and identify excluded fictional IDs. # TODO 2: Create a scatterplot of paired study hours and quiz score. # TODO 3: Use cor() and explain direction/strength without causal claims. # TODO 4: Fit a simple linear model with lm(); inspect coef(). # What are the units of the slope? # TODO 5: Plot the fitted line on the scatterplot with abline(). # TODO 6: Obtain model R-squared and explain what it DOES NOT prove. # TODO 7: Predict quiz score for 4 study hours. # Then predict for 10 hours: why is extrapolation dangerous? # TODO 8: Calculate residuals and identify which residual is largest # in absolute value; report the corresponding fictional student ID. # TODO 9: In a COPY ONLY, replace S08's quiz score with 50. # Recompute cor() and discuss sensitivity. Do not edit the original CSV. # TODO 10: Write a short English summary: n, correlation direction, # slope in points/hour, and two substantive limitations.