#help(faithful)

# summary
summary(faithful)
##    eruptions        waiting    
##  Min.   :1.600   Min.   :43.0  
##  1st Qu.:2.163   1st Qu.:58.0  
##  Median :4.000   Median :76.0  
##  Mean   :3.488   Mean   :70.9  
##  3rd Qu.:4.454   3rd Qu.:82.0  
##  Max.   :5.100   Max.   :96.0
head(faithful)
##   eruptions waiting
## 1     3.600      79
## 2     1.800      54
## 3     3.333      74
## 4     2.283      62
## 5     4.533      85
## 6     2.883      55
# number of rows
nrow(faithful)
## [1] 272

Linear regression

faithful_linear <- lm(eruptions ~ waiting, data = faithful)
summary(faithful_linear)
## 
## Call:
## lm(formula = eruptions ~ waiting, data = faithful)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.29917 -0.37689  0.03508  0.34909  1.19329 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -1.874016   0.160143  -11.70   <2e-16 ***
## waiting      0.075628   0.002219   34.09   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4965 on 270 degrees of freedom
## Multiple R-squared:  0.8115, Adjusted R-squared:  0.8108 
## F-statistic:  1162 on 1 and 270 DF,  p-value: < 2.2e-16

explanation: Estimate for waiting is positive p-value for waiting is extremely small R-squared is high

The linear relation between eruptions and waiting shows a statically significant.

The coefficient for waiting is positive, meaning longer waiting times are associated with longer eruption duration.

The p-value for waiting variable is far below 0.05, indicating that the relationship is statistically significant.
The R-squared is **very high, showing that waiting explains a large proportion of the variation* in eruption duration.

Scatter plot

plot(faithful$waiting, faithful$eruptions, col = "blue",
     xlab = "Waiting time",
     ylab = "Eruption duration",
     main = "Waiting time vs Eruption Duration")

explanation: The scatter plot of waiting times vs eruption duration shows a clear positive relationship. As the waiting time increases, the eruption duration tends to increase.

The points form an upward trend rather than being randomly scattered, which indicates a strong linear association between the two variables.

There are no distinct clusters or separate groups; instead, the data follows one main pattern showing that longer waiting times are associated with longer eruption duration.

regression line

plot(faithful$waiting, faithful$eruptions, col = "darkred",
     xlab = "Waiting time",
     ylab = "Eruption duration",
     main = "Waiting time vs Eruption Duration")
abline(faithful_linear, col = 'green', lwd = 2)

explanation: The regression line aligns very will with the data points.

The scatter plot shows a clear positive upward trend, the green regression line follows this pattern closely.

This visual alignment matches the statistical results from the model summary, where the slope for waiting variable is statistically significant (p-value < 0.05) and the R-squared is very high.

These statistics indicate that waiting time is a strong predictor of eruption duration, which is why the regression line fits the data so well.