# sim.AR: Simulate correlated data from a precision matrix. In ar.matrix: Simulate Auto Regressive Data from Precision Matricies

## Description

Takes in a square precision matrix, which ideally should be sparse and using Choleski factorization simulates data from a mean 0 process where the inverse of the precision matrix represents the variance-covariance of the points in the process. The resulting simulants represent samples of a Gaussian Markov random field (GMRF).

## Usage

 `1` ```sim.AR(n, Q) ```

## Arguments

 `n` int > 0, number of observations to simulate from the GMRF. `Q` matrix, a square precision matrix.

## Value

Matrix object, matrix where each row is a single obsrevation from a GMRF with covariance structure Q^-1.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21``` ```require("ggplot2") # simulate 2D ar1 process # pairwise correlation rho <- .95 # pairwise variance sigma <- .5 # 2 dimensions of simulations years <- 20 ages <- 10 # kronnecker product to get joint covariance Q2D <- kronecker(Q.AR1(M=years, sigma, rho), Q.AR1(M=ages, sigma, rho)) # simulate the data and place it in a data frame Q2D.df <- data.frame(obs=c(sim.AR(1, Q2D)), age=rep(1:ages, years), year=rep(1:years, each=ages)) # graph results ggplot(data=Q2D.df, aes(year, obs, group=age, color=age)) + geom_line() ```

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