Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.
Running Code
When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
Rows: 120 Columns: 2
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
dbl (2): Y, X
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#head(gpa)# Scatterplotplot(gpa$X, gpa$Y, xlab ="ACT Scores", ylab ="GPA", main ="Scatterplot of GPA vs ACT Scores")
2. Fit a regression model and write down the estimated regression function:
# Fit a linear regression modelmodel<-lm(Y~X,data=gpa)# Print the estimated regression functioncoefficients <-coef(model)cat("Regression function: Y =", round(coefficients[2], 4), "* X +", round(coefficients[1], 4), "\n")
Regression function: Y = 0.0388 * X + 2.114
\[ Y = 0.0388 * X + 2.114\]
3. Plot the estimated regression line and the data
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.11404929 0.32089483 6.587982 1.304450e-09
X 0.03882713 0.01277302 3.039777 2.916604e-03
# Scatterplotplot(gpa$X, gpa$Y, xlab ="ACT Scores", ylab ="GPA", main ="Scatterplot of GPA vs ACT Scores")points(gpa$X,model$fit, type="l", col="red")
4. Point estimate of the change in the mean response when the entrance test score increases by one point \[\beta_1 = 0.0388\] 5. Obtain a 99 percent confidence interval for β1