Q.RW2: Precision matrix for an RW2 process

Description Usage Arguments Value Examples

View source: R/Q.RW2.R

Description

Functions for creating precision matricies and observations of an RW2 process

Usage

1
2
3
Q.RW2(M, sigma, sparse=TRUE)

r.RW2(n, M, sigma)

Arguments

M

int > 0, number of elements in the RW2 process.

sigma

float > 0, pairwise observation standard deviation.

sparse

bool Should the matrix be of class 'dsCMatrix'

n

int > 0, number of observations to simulate from the GMRF.

Value

Q.RW2 returns a precision matrix with a RW2 structure.

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
require("ggplot2")
# simulate RW2 GMRF
obs <- r.RW2(100, M=30, sigma=1)
# resulting matrix is n x M
dim(obs)
# move objects to a data frame
RW2_df <- data.frame(obs=c(t(obs)), realization=rep(1:100, each=30),
                     time=rep(1:30, 100))
# plot each realization
ggplot(data=RW2_df, aes(time, obs, group=realization, color=realization)) +
    geom_line()

nmmarquez/ar.matrix documentation built on May 23, 2019, 9:28 p.m.