Browse Source

Early attempt at combining weather and kwh models

Petra Lamborn 5 years ago
parent
commit
66d259f7e6
1 changed files with 35 additions and 1 deletions
  1. 35
    1
      R/clusterviz.R

+ 35
- 1
R/clusterviz.R View File

33
 str(aggdf)
33
 str(aggdf)
34
 clusters = levels(aggdf$cluster)
34
 clusters = levels(aggdf$cluster)
35
 
35
 
36
+mtempdf <- read.csv("../data/weatherharm.csv", stringsAsFactors = FALSE) %>% mutate(x = as.POSIXct(x, tz = "UTC"))
37
+
36
 ggplot(aggdf, aes(y = kwh_tot_mean, x = cluster)) + geom_boxplot()
38
 ggplot(aggdf, aes(y = kwh_tot_mean, x = cluster)) + geom_boxplot()
37
 
39
 
38
 facall <- ggplot(aggdf, aes(x = read_time, y = kwh_tot_mean, color = cluster, fill = cluster)) + 
40
 facall <- ggplot(aggdf, aes(x = read_time, y = kwh_tot_mean, color = cluster, fill = cluster)) + 
260
 qqnorm(resid(cmodi))
262
 qqnorm(resid(cmodi))
261
 
263
 
262
 
264
 
263
-clust = "9"
265
+clust = "5"
264
 
266
 
265
 cts <- filter(aggdf, cluster == clust)$kwh_tot_mean
267
 cts <- filter(aggdf, cluster == clust)$kwh_tot_mean
266
 ctsy <- ts(cts, frequency = floor(48 * 365.25))
268
 ctsy <- ts(cts, frequency = floor(48 * 365.25))
276
     geom_point(aes(y = r), color = "darkgreen") +
278
     geom_point(aes(y = r), color = "darkgreen") +
277
     coord_cartesian(xlim = c(as.POSIXct("2017-01-01", tz = "UTC"), as.POSIXct("2017-12-31", tz = "UTC")))
279
     coord_cartesian(xlim = c(as.POSIXct("2017-01-01", tz = "UTC"), as.POSIXct("2017-12-31", tz = "UTC")))
278
 
280
 
281
+cwcombdf <- left_join(cldf, mtempdf, by = "x")
282
+str(cwcombdf)
283
+
284
+
285
+# A variety of models
286
+plot(f.x ~ f.y, data = cwcombdf)
287
+plot(r.x ~ r.y, data = cwcombdf)
288
+plot(r.x ~ y.y, data = cwcombdf)
289
+plot(y.x ~ r.y, data = cwcombdf)
290
+plot(y.x ~ x, data = cwcombdf)
291
+plot(y.x ~ y.y, data = cwcombdf)
292
+plot(y.x ~ y.y, data = cwcombdf)
293
+plot(y.y ~ r.x, data = cwcombdf)
294
+plot(y.y ~ x, data = cwcombdf)
295
+
296
+
297
+summary(lm(f.x ~ f.y, data = cwcombdf))
298
+summary(lm(r.x ~ r.y, data = cwcombdf))
299
+summary(lm(r.x ~ y.y, data = cwcombdf))
300
+summary(lm(y.x ~ r.y, data = cwcombdf))
301
+summary(lm(y.x ~ x, data = cwcombdf))
302
+summary(lm(y.x ~ y.y, data = cwcombdf))
303
+summary(lm(y.x ~ y.y, data = cwcombdf))
304
+summary(lm(y.y ~ r.x, data = cwcombdf))
305
+summary(lm(y.y ~ x, data = cwcombdf))
306
+
307
+summary(lm(r.x ~ r.y * f.y, data = cwcombdf))
308
+imod <- lm(r.x ~ r.y * f.y, data = cwcombdf)
309
+plot(fitted(imod))
310
+plot(resid(imod))
311
+plot(cwcombdf$r.x)
312
+plot(cwcombdf$r.x ~ resid(imod))