# Generate data
set.seed(123)
x <- 1:100
y <- 2*x + rnorm(100, mean = 0, sd = 10)
# Fit linear regression model
model <- lm(y ~ x)
summary(model)
##
## Call:
## lm(formula = y ~ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -24.5356 -5.5236 -0.3462 6.4850 20.9487
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.36404 1.84287 -0.198 0.844
## x 2.02511 0.03168 63.920 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 9.145 on 98 degrees of freedom
## Multiple R-squared: 0.9766, Adjusted R-squared: 0.9763
## F-statistic: 4086 on 1 and 98 DF, p-value: < 2.2e-16
# Plot a Q-Q plot of residuals
qqnorm(model$residuals)
qqline(model$residuals)
The points in the QQ plot approximately follow a straight line, indicating that the residuals are normally distributed.