#' Generate AR coefficient matrix
#'
#' @description Generate a tridiagonal matrix. To be used for generating blockly correlated VAR series, \code{XgenCorr}.
#'
#' @param dimension a number. Size of the matrix, should agree with the number of AR series
#' @param ondiag a number. Value of main diagonal, this represents AR coefficient within each one series
#' @param offdiag a number. Value of first diagonal above and below the main diagonal, this specifies the cross-correlation with the next neighbor series
#'
#' @return a tridiagonal matrix.
#' @export
#'
#' @examples
#' A11 <- coefmat(dimension = 3, ondiag = 0.4, offdiag = 0.15)
coefmat <- function(dimension, ondiag, offdiag){
coefmat <- diag(ondiag, dimension)
diag(coefmat[-1,])<-rep(offdiag, (dimension-1))
diag(coefmat[,-1])<-rep(offdiag, (dimension-1))
return(coefmat = coefmat)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.