Learn R Programming

AirScreen (version 0.1.0)

rnormAR1: Generate normal samples (Autoregressive AR(1) correlation)

Description

rnormAR1 efficiently generates samples from a multivariate normal distribution with AR(1) correlation \(cor(x_i, x_j) = \rho^{\lvert i-j \rvert}\).

Usage

rnormAR1(n, p, rho = 0.5, means = 0, variances = 1)

Value

A numeric \(n \times p\) matrix with the specified correlation, means, and variances.

Arguments

n

Number of observations.

p

Number of variables.

rho

Autoregressive correlation coefficient.

means

Numeric vector of feature means (length \(1\) or \(p\)).

variances

Numeric vector of feature variances (length \(1\) or \(p\)).

Examples

Run this code
X1 <- rnormAR1(10, 5)
X2 <- rnormAR1(10, 5, rho = 0.3, means = 2, variances = 4)
X3 <- rnormAR1(10, 5, rho = 0.4, means = 1:5, variances = 3:7)

Run the code above in your browser using DataLab