R/autocorr.mat.R

Defines functions autocorr.mat

Documented in autocorr.mat

#' Create auto-correlation matrix
#'
#' Create auto-correlation matrix
#'
#' @param p dimension of matrix
#' @param rho autocorrelation value
#'
#' @return auto-matrix of size p with parameter rho
#'
#' @examples
#' # Create 4x4 matrix with correlation between adjacent enties is 0.9
#' autocorr.mat(4, .9)
#'
#' @export
autocorr.mat <- function(p, rho) {
  mat <- diag(p)
  rho^abs(row(mat) - col(mat))
}

Try the decorrelate package in your browser

Any scripts or data that you put into this service are public.

decorrelate documentation built on Aug. 8, 2025, 7:55 p.m.