Description Usage Arguments Value Examples

Functions for creating precision matricies and observations of an AR1 process

1 2 3 |

`M` |
int > 0, number of elements in the AR1 process. |

`sigma` |
float > 0, pairwise observation standard deviation. |

`rho` |
float >= 0 & < 1, how correlated pairwise observations are. The function will still run with values outside of the range [0,1) however the stability of the simulation results are not gaurunteed. |

`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.AR1 returns either a precision or variance-covariance function with a AR1 structure.

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

1 2 3 4 5 6 7 8 9 10 11 12 13 | ```
require("ggplot2")
# simulate AR1 GMRF
obs <- r.AR1(100, M=30, sigma=1, rho=.98)
# 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
ar1_df <- data.frame(obs=c(t(obs_adj)), realization=rep(1:100, each=30),
time=rep(1:30, 100))
# plot each realization
ggplot(data=ar1_df, aes(time, obs, group=realization, color=realization)) +
geom_line()
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.