Hello all,
I have a dataset where I have applied groupedData:
> My.Data<-groupedData(Y~G1/G2,data=My.Data)
then I fit the same model to all groups using lmList
Grp.fit<-lmList(Y~X1+X2+X3,data=My.Data)
then I have a new dataset which is built inside a function. The dataset
varies depending on some selection criteria, but always looks something
like:
New.Data<-data.frame(X1=x1, X2=x2, X3=x3, G1=g1, G2=g2,
Y=rep(1,length(x1))
New.Data<-groupedData(Y~G1/G2,data=New.Data)
then I use
Yhat<-predict.lmList(Grp.fit,New.Data)
and I get the following error:
Problem in getGroups.data.frame: No data to interpret as logical value:
if(nlevel == 1) return(value[, 1])
Use traceback() to see the call stack
and traceback() gives:
8: eval(action, sys.parent())
7: doErrorAction("Problem in getGroups.data.frame: No data to interpret as
logical value: if(nlevel == 1) return(value[, 1])", 1000)
6: getGroups.data.frame(newdata, getGroupsFormula(object, asList = TRUE),
level = attr(object, "level"))
5: predict.lmList(Grp.fit, Ktest)
I have tried this with and without groupedData(New.Data) with no luck.
It works fine when the grouping is 1|G1 with and without
groupedData(New.Data)
I have several thousand records I am trying to predict and hope to not
have to develop a loop to do this - It'll take forever since I have
several runs of New.Data as well.
I could combine G1/G2 into a single variable and fit with 1 level of
nesting, but would really like to know if there is a fix for the
multi-level grouping.
Any idea what is going on and how to work around this?
John Kershaw
|