Description Usage Arguments Value References Examples
Functions for creating precision matricies and observations of a proper CAR(pCAR) process as defined in MacNab 2011. The matrix defines the precision of estimates when observations share connections which are conditionally auto-regressive(CAR).
1 2 3 |
graph |
matrix, square matrix indicating where two observations are connected (and therefore conditionally auto-regressive). |
sigma |
float > 0, process standard derviation see MacNab 2011. |
rho |
float >= 0 & < 1, how correlated neighbors are. The function will still run with values outside of the range [0,1) however the stability of the simulation results are not gaurunteed. see MacNab 2011. |
sparse |
bool Should the matrix be of class 'dsCMatrix' |
vcov |
bool If the vcov matrix should be returned instead of the precision matrix. |
n |
int > 0, number of observations to simulate from the GMRF. |
Q.pCAR returns either a precision or variance-covariance function with a pCAR structure.
r.pCAR retrurns a matrix with n rows which are the n observations of a Gaussian Markov random field pCAR process.
Y.C. MacNab On Gaussian Markov random fields and Bayesian disease mapping. Statistical Methods in Medical Research. 2011.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | require("leaflet")
require("sp")
# simulate pCAR data and attach to spatial polygons data frame
US.df@data$data <- c(r.pCAR(1, graph=US.graph, sigma=1, rho=.99))
# color palette of data
pal <- colorNumeric(palette="YlGnBu", domain=US.df@data$data)
# see map
map1<-leaflet() %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data=US.df, fillColor=~pal(data), color="#b2aeae",
fillOpacity=0.7, weight=0.3, smoothFactor=0.2) %>%
addLegend("bottomright", pal=pal, values=US.df$data, title="", opacity=1)
map1
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.