Dear List,
I have trouble with the predict function (raster package) when using a gnls model (nonlinear model fit using generalized least squares, from the nlme package).
I'm using R version 3.3.1 (2016-06-21), Platform: x86_64-w64-mingw32/x64 (64-bit), and raster package version 2.5-8.
I want to make predictions based on three continuous variables and one categorical variable. The predictors are layers in a RasterStack object (see description below: s20, s20_excludefactor). Using other models than gnls works. I tested three models (my_nls, my_lm, my_gnls, see description below):
1) Using nonlinear least squares (nls) fit excluding the factor as predictor works fine:
v20 <- predict(object=s20_excludefactor, model=my_nls)
2) Using linear model (lm) including the factor as predictor works as well, except the warning:
?not sure if the correct factor levels are used here?.
v20 <- predict(object=s20, model=my_lm) # or
v20 <- predict(object=s20, model=my_lm, na.rm=T, factors=list(Gruppe=c("1","2","3")))
3) Using the glns model produces error:
?Error in p %*% beta[pmap[[nm]]] : non-conformable arguments?
v20 <- predict(object=s20, model=my_gnls) # or
v20 <- predict(object=s20, model=my_gnls, na.rm=T, factors=list(Gruppe=c("1","2","3")))
I don't know what to do about the error in 3). Any help is highly appreciated!
Best regards,
Johannes