2025-11-08

cat(”

“)

Relationship Between Temperature and Mood

Interactive Plot: Temperature vs Mood

Linear Regression Model

Formula below shows how relationship between temperature and mood could be represent in a Linear model:

\[ \text{Mood} = \beta_0 + \beta_1 \times \text{Temperature} + \varepsilon \]

Where:

  • \(\beta_0\) is the intercept (baseline mood)
  • \(\beta_1\) represents the change in mood for each 1°F increase in temperature
  • \(\varepsilon\) is the random error term

Correlation Between Temperature and Mood

To measure the strength of the relationship, we can compute the correlation coefficient:

\[ r = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})} {\sqrt{\sum (x_i - \bar{x})^2 \sum (y_i - \bar{y})^2}} \]

If \(r\) is close to \(1\) means a strong positive relationship. If \(r\) is close to \(-1\) means a strong negative relationship.

R Code Example: Linear Regression in R

R code below shows the relationship between temperature and mood using linear model.

ggplot(data, aes(x = temperature, y = mood)) +
  geom_point(color = "#1A237E", alpha = 0.6, size = 3) +
  geom_smooth(method = "lm", se = TRUE, color = "#D32F2F") +
  labs(
    title = "Mood Levels vs Temperature",
    x = "Temperature (°F)",
    y = "Mood Level (1–10)"
  ) +
  theme_minimal(base_family = "Verdana") +
  theme(
    plot.title = element_text(face = "bold", hjust = 0.5, size = 18, color = "#1A237E")
  )

Residual Analysis

Nonlinear (Quadratic) Model

The linear model provides a basic trend, however the residual pattern appears to be a curved (nonlinear) relationship. Below shows quadratic model. Mood rises as the temperature increase, peaks around 70 degree, and decreases as it gets hotter.

Conclusion

  • Mood rates show a clear relationship with temperature — temperatures around 70°F are associated with the best mood.
  • The linear model provides a pattern but more factors could affect the mood change and once temperature reaches a certain point the mood starts to decline.
  • The quadratic model is more accurate, reflecting how extreme temperature lowers mood.
  • This analysis shows how linear regression concepts can be applied to observe patterns in situation we experience everyday, such as how environment affects emotions. However, it is important to remember that other factors could play a big part of the resultas well.