Q.RW1: Precision matrix for an RW1 process

Description Usage Arguments Value Examples

View source: R/Q.RW1.R

Description

Functions for creating precision matricies and observations of an RW1 process

Usage

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

r.RW1(n, M, sigma)

Arguments

M

int > 0, number of elements in the RW1 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.RW1 returns a precision matrix with a RW1 structure.

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
require("ggplot2")
# simulate RW1 GMRF
obs <- r.RW1(100, M=30, sigma=1)
# resulting matrix is n x M
dim(obs)
# subtract off the first time point to more easily observe correlation
obs_adj <- obs - obs[,1]
# move objects to a data frame
rw1_df <- data.frame(obs=c(t(obs_adj)), realization=rep(1:100, each=30),
                     time=rep(1:30, 100))
# plot each realization
ggplot(data=rw1_df, aes(time, obs, group=realization, color=realization)) +
    geom_line()

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