[R-sig-Geo] precision matrix

Isa-May Kennes isa_may_kennes at hotmail.com
Mon Aug 1 20:23:55 CEST 2016


Hi


I have a dataset containing insurance data of about 300 000 policies. One attribute is CODPOSS containing postal codes of the policies. 
I also have a shapefile "Belgium" containing spatial information on the Belgian districts. One of the attributes is again CODPOSS giving the postal codes. There are about 600 districts. For 6 of those we have no insurance policy information. 

Now I want to fit a respons (e.g. claims frequency) by a spatial smoother, more precisely a Markov Random Field. 


My code so far:

library("gamlss.spatial")
library("spdep")
library("rgdal")

# the neigbors and polygons of the shapefile Belgium
BE.nb=poly2nb(Belgium)
BE.polys=Belgium at polygons
# transformation in order to apply the functions of gamlss.spatial
new.polys <- polys2polys(BE.polys,BE.nb)
new.nb <- nb2nb(BE.nb)


# the precision matrix
prec=nb2prec(new.nb, x=as.factor(row.names(BE.df)))
 

This last line gives an error message:
    "Error in nb2prec(new.nb, x =  as.factor(Belgium at data$CODPOSS)) :"
    " mismatch between neighbour/polys supplied area names and data area names"

Furthermore, I would like to use the functions mrf or gamlss.gmrf to fit the model. But the respons variable has length about 300 000 while there are only about 600 districts, some of which do not occur in the dataset. 


Is someone of you familiar with this MRF smoothing?

Thanks in advance!
Isa-May Kennes 




    


More information about the R-sig-Geo mailing list