How to plot/map spatial random effects (Spatial Random Effects) in R?

Asked

Viewed 50 times

0

I am working with visceral leishmaniasis data in census tracts of a Brazilian municipality. I ran a Baysian space model (CAR conditional autoregressible model) BYM from the Carbayes package in the R software. However, I’m unable to visualize and export the spatial random effects (Spatial Random Effects). Could someone help me with this? Very obgda.

modelbym1 <- S.CARbym(formula = eq1, data = spat.data,   
                family = "poisson", W = W2, burnin = 100000,  
                n.sample = 300000, thin = 20) 
  • 1

    Hi Patricia, it is not possible to replicate your error with only this line of code. First you could indicate your packages with library(x) and then generate a database (or use one of the ones that already exist in R, like iris, mtcars, etc), so it is possible to help you.

1 answer

0

The code for exporting random spatial effects is:

pmean = apply(modelbym1$samples$psi,2,mean) 
write.csv(pmean, file = "pmean.csv") 

Then just make a Join with the ". shp" pq values are exported in the same order as the original data.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.