I am trying to model a point process with an image covariate using the ppm() function in the spatstat package in R. I convert my raster to an im objectfor use with spatstat, and I run into a problem using the im as a covariate in the model. The pixel values are numeric, but these are actually just codesfor different landscape zones so the crux of the problem is getting the model to read the pixel values as factor rather than numeric. I have tried the followingtwo approaches (R code and data are presented below). The first consists of converting the raster values from numeric to factor prior to converting the raster object to the im object. Using the as.factor() function this seems to have the desired effect of converting the values to factor. However, when Irun the ppm model with this covariate, the ppm() function does not include a parameter for each factor level in the model (compared to a reference level). Rather it treats the covariate as numeric with just the one parameter for the one covariate. The second approach was to runt the ppm model with factor(covariate)used to specify the covariate in the formula argument, rather than just the covariate itself. This actually works in fitting the model, giving me a parameterfor each factor level compared to the reference. However, when I run predict.ppm() to get my predictions it fails because I used factor() in the formulaargument. The qustion is, how can I run the ppm model such that it recognizes the values of the covariate image as factor and, thus, fitting a model with a parameter estimate for each factor level (minus the reference) and allowing prediction with predict.ppm.
The point process data is in csv format here: https://www.dropbox.com/s/tp1opzsmc14e2hb/EbolaData_AnalyticSet_8.8.14.csv?dl=0
The tiff file for the covariate is here:https://www.dropbox.com/s/0fyt0jflokrpp5z/anthrome2000_global_5min.tif?dl=0
And the R code is as follows:
library(raster)library(spatstat)library(geostatsp)# First set the geographic extent we'll be usinge
The point process data is in csv format here: https://www.dropbox.com/s/tp1opzsmc14e2hb/EbolaData_AnalyticSet_8.8.14.csv?dl=0
The tiff file for the covariate is here:https://www.dropbox.com/s/0fyt0jflokrpp5z/anthrome2000_global_5min.tif?dl=0
And the R code is as follows:
library(raster)library(spatstat)library(geostatsp)# First set the geographic extent we'll be usinge