Q.iid: Precision matrix for a IID process

Description Usage Arguments Value Examples

View source: R/Q.iid.R

Description

Functions for creating precision matricies and observations of a independent identically distributed GMRF process.

Usage

1
2
3
Q.iid(M, sigma, sparse=FALSE,  vcov=FALSE)

r.iid(n, M, sigma)

Arguments

M

int > 0, number of elements in the process.

sigma

float > 0, standard deviat

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.

Value

Q.iid returns either a precision or variance-covariance function with iid structure.

r.iid retrurns a matrix with n rows which are the n observations of a Gaussian Markov random field iid process.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
require("leaflet")
require("sp")

# simulate iid data and attach to spatial polygons data frame
US.df@data$data <- c(r.iid(1, M=nrow(US.graph), sigma=1))

# 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

ar.matrix documentation built on May 1, 2019, 11:31 p.m.