Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- test_ds <- read.csv("test.csv", header = TRUE, stringsAsFactors = FALSE)
- test_ds$Date <- as.Date(test_ds$Date, format=c("%Y-%m-%d"))
- head(test_ds)
- Date West.Counts West.Demands X X2.Day.West.Counts.Avg
- 1 2005-01-01 452 67797 NA NaN
- 2 2005-02-01 333 56151 NA 392.5
- 3 2005-03-01 262 40801 NA 297.5
- 4 2005-11-01 222 18694 NA 242.0
- 5 2005-12-01 523 48155 NA 372.5
- 6 2006-01-01 339 52230 NA 431.0
- ccf(x=test_ds$West.Counts, y=test_ds$West.Demands)
- wc_ts <- ts(test_ds$West.Counts, frequency=5)
- ll <- nrow(test_ds)-1
- west_counts_lag <- c(NA, test_ds$West.Counts[1:ll])
- dummy_seas <- factor(cycle(wc_ts))
- lm_res <- lm(West.Demands ~ West.Counts + west_counts_lag + dummy_seas, data= test_ds)
- summary(lm_res)
- Call:
- lm(formula = West.Demands ~ West.Counts + west_counts_lag + dummy_seas,
- data = test_ds)
- Residuals:
- Min 1Q Median 3Q Max
- -40817 -3166 535 3322 13837
- Coefficients:
- Estimate Std. Error t value Pr(>|t|)
- (Intercept) 13437.78 7098.42 1.893 0.063175 .
- West.Counts 62.57 12.31 5.084 3.88e-06 ***
- west_counts_lag 41.72 12.24 3.407 0.001176 **
- dummy_seas2 -3471.68 3570.92 -0.972 0.334851
- dummy_seas3 -4192.77 4525.39 -0.926 0.357899
- dummy_seas4 -16984.64 4601.65 -3.691 0.000484 ***
- dummy_seas5 -2614.11 3886.59 -0.673 0.503785
- ---
- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
- Residual standard error: 7349 on 60 degrees of freedom
- (1 observation deleted due to missingness)
- Multiple R-squared: 0.8566, Adjusted R-squared: 0.8422
- F-statistic: 59.71 on 6 and 60 DF, p-value: < 2.2e-16
Add Comment
Please, Sign In to add comment