0

I'm using the predict function in raster library to predict my glm model over set of raster stack predictors. Some of the factor levels were missing in my model, so I turned those layers to NA in order to run the predict function. Now my output map has missing values and I'm searching for a way to fulfill this problem. Is there any way to predict those regions using other continuous variables?

These are my sample codes:

m1 <- glm(loc ~ factor(var1) + var2 + var3 , data= data)

var1 <- raster(raster1)
var2 <- raster(raster2)
var3 <- raster(raster3)

id <- which(!(var1[] %in% data$var1))
var1[id] <- NA


predictors <- stack (var1, var2, var3)

prd_data <- predict(predictors, m1, type= "response", na.action="na.pass")
Geo-sp
  • 1,704
  • 3
  • 19
  • 42
  • 2
    This is a coding website. You are expected to post some sample code so we can all be talking about the same starting point. – IRTFM Jul 01 '13 at 22:48
  • Thanks, I added some sample codes. – Geo-sp Jul 01 '13 at 23:42
  • If there are sample datasets in the raster library, you should point out a suitable test case; otherwise it will remain your responsibility to post code that creates as dataset to plug in for `data`. – IRTFM Jul 01 '13 at 23:44

0 Answers0