Error in.checkFormula(formula, categories, labels) when trying to run lulcc package

library(lulcc)
data(pie)
obs <- ObsLulcRasterStack(x=pie, pattern="lu", categories=c(1,2,3), labels=c("forest", "built", "other"), t=c(0,6,14))
obs <- ObsLulcRasterStack(x=pie, pattern="lu", categories=c(1, 2, 3), labels=c("forest", "built", "other"), t=c(0, 6, 14))
plot(obs)
crossTabulate(obs, times=c(0,6))
forest built other
forest 46672 1926 415
built 0 37085 37
other 359 1339 25730
crossTabulate(obs, times=c(0,14))
forest built other
forest 44107 4250 656
built 11 36957 154
other 1259 2248 23921
install.packages("gsubfn")
install.packages("caret")
ef <- ExpVarRasterList(x=pie, pattern="ef")
part <- partition(x=obs[[1]], size=0.1, spatial=TRUE)
train.data <- getPredictiveModelInputData(obs=obs, ef=ef, cells=part[["train"]], t=0)
test.data <- getPredictiveModelInputData(obs=obs, ef=ef, cells=part[["test"]])
forms <- list(Built~ef_001+ef_002+ef_003, Forest~ef_001+ef_002, Other~ef_001+ef_002)
glm.models <- glmModels(formula=forms, family=binomial, data=train.data, obs=obs)
Error in .checkFormula(formula, categories, labels) :
a formula must be supplied for each land use type

I have copied the code pretty much directly from the literature (found here: GMD - An open and extensible framework for spatially explicit land use change modelling: the lulcc R package (copernicus.org)
and also used the GIthub forum to help as well: GitHub - simonmoulds/lulcc at e57b7a51b535c5ffff41e8c18e36d8a57df4aeed
but I keep getting the error message as highlighted in red and there is no mention of this anywhere that I can see.

1 Like

Hello, I have the same problem. Is there any solution?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.