I have a data sets that has potential of being enormous with each Meter data i add. For now, i am only using 5 meters for example purpose. Here is what my data structure looks like:
str(Data1)
'data.frame': 43800 obs. of 7 variables:
$ METER: Factor w/ 5 levels "10443720001539305",..: 1 1 1 1 1 1 1 1 1 1
$ LOAD : num 87.7 101.5 96.5 92 185.6 ...
$ TEMP : num 30.5 34 39 36.5 24.5 31.5 32.5 18.5 26.5 25.5 ...
$ DAY : chr "WD" "WD" "WE" "WE" ...
$ HDD : num 34.5 31 26 28.5 40.5 33.5 32.5 46.5 38.5 39.5 ...
$ CDD : num 0 0 0 0 0 0 0 0 0 0 ...
$ HOUR : Factor w/ 24 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
For each Meter, i am trying to get the 24 different hourly regression models total of 120 models.
Creating Model List & storing Coefficients.
cat1<-dlply(Data1, c("METER", "HOUR"), function(z) lm(LOAD ~ HDD + CDD + DAY))
cat_COF<-ldply(cat1, coef)
PREDICTING FOR SAME DATA
Predicting for the same data was fairly straight forward.
cat_Pred<-ldply(cat1, predict, type = "response")
PROBLEM WHILE PREDICTING WITH NEW DATA
The real issue is while i try to predict with the new data set that has all the necessary information.
doesn't work
cat_Pred1<-ldply(cat1, predict, type = "response", newdata)
Is there a quick way for me to do the predictions from these list of models?
This is the closest example i came across but this only has one "state" level. It is little confusing to me & I have tried adding c("METER", "HOUR") but never seems to work for me.
Any help will be highly appreciated!!