Difference between revisions of "PowerExtrapolation.R"

From Organic Design wiki
(Adding plot in years)
(lowess non parametric fit to trend)
Line 33: Line 33:
 
# Plot in years
 
# Plot in years
 
plot(x,y)
 
plot(x,y)
lm(y~x)
+
lines(lowess(y~x))

Revision as of 20:24, 11 February 2007

library(chron)

dset <- scan(what="") 11/1/00 10.70 60 5/1/02 11.81 33.26 1/1/02 12.36 34.8 4/1/02 11.84 33.67 10/1/02 11.82 33.64 3/1/03 11.82 33.33 10/1/03 13.84 33.33 10/1/04 13.77 33.33 11/1/04 15.26 33.33 12/1/04 14.07 59.59 4/1/05 14.528 60.55 10/1/05 15.7 64.68 3/1/06 16.4 66.02 6/1/06 14.78 33.33 ""

dim(dset) <- c(3, length(dset)/3) dset <- as.data.frame(t(dset)) colnames(dset) <- c("Date", "kwh", "dailyCharge")

dset$Date <- dates(levels(dset$Date)[unclass(dset$Date)])


plot(dset$Date, as.numeric(as.vector(dset$kwh)))


y <- as.numeric(as.vector(dset$kwh)) x <- (dset$Date - dates("11/01/00")) / 365.25

  1. Plot in years

plot(x,y) lines(lowess(y~x))