Guest User

Untitled

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