library(tidyverse)
library(magrittr)
options(tibble.width = Inf)
ti <- read_csv("~/GitHub/MatrixTSA/data/soenderborg_2day.csv")
ti_winter <- filter(
ti,
as.POSIXlt("2011-06-01")$yday < as.POSIXlt(ti$t)$yday &
as.POSIXlt(ti$t)$yday <= as.POSIXlt("2011-10-01")$yday
)
ti_winter
Get the data from house 3 during the winter in year 2011.
lm_winter_3 <- lm(P3 ~ Te, ti_winter)
summary(lm_winter_3)
Call:
lm(formula = P3 ~ Te, data = ti_winter)
Residuals:
Min 1Q Median 3Q Max
-203.19 -110.55 -44.61 64.59 643.97
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1166.733 118.136 9.876 1.06e-13 ***
Te -53.936 7.419 -7.270 1.50e-09 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 165.3 on 54 degrees of freedom
(5 observations deleted due to missingness)
Multiple R-squared: 0.4946, Adjusted R-squared: 0.4852
F-statistic: 52.85 on 1 and 54 DF, p-value: 1.503e-09
par(mfrow = c(2, 2))
plot(lm_winter_3)
The P-values of coefficients for intercept and Te are sufficiently small, so it’s a good model. However, from the top-left diagram, we can say the residuals are not iid.
lm_3 <- lm(P3 ~ Te, ti)
summary(lm_3)
Call:
lm(formula = P3 ~ Te, data = ti)
Residuals:
Min 1Q Median 3Q Max
-930.1 -342.0 -31.5 249.1 1611.2
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3624.50 53.65 67.56 <2e-16 ***
Te -210.26 4.82 -43.62 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 452.5 on 141 degrees of freedom
(9 observations deleted due to missingness)
Multiple R-squared: 0.931, Adjusted R-squared: 0.9305
F-statistic: 1903 on 1 and 141 DF, p-value: < 2.2e-16
par(mfrow = c(2, 2))
plot(lm_3)
When including the entire period, the span of the data is extended. There are more large residuals.
par(mfrow = c(1, 1))
acf(
lm_winter_3$residuals,
main = "ACF of Residuals from Linear Reg Model `lm_winter_3`"
)
acf(
lm_3$residuals,
main = "ACF of Residuals from Linear Reg Model `lm_3`"
)
The residuals from lm_winter_3 are more correlated with each other than those from lm_3. The heating loads in summer may cause the difference.