Learn R Programming

amen (version 1.0)

simZ: Simulate Z given its expectation and covariance

Description

Simulate Z given its expectation and covariance

Usage

simZ(EZ, rho, s2 = 1)

Arguments

EZ
expected value of Z
rho
dyadic correlation
s2
dyadic variance

Value

  • a simulated value of Z

Examples

Run this code
## The function is currently defined as
function (EZ, rho, s2 = 1)
{
    w1 <- sqrt((1 + sqrt(1 - rho^2))/2)
    w2 <- sign(rho) * sqrt(1 - w1^2)
    EC <- matrix(rnorm(length(EZ)), nrow(EZ), nrow(EZ))
    EC <- sqrt(s2) * (w1 * EC + w2 * t(EC))
    EZ + EC
  }

Run the code above in your browser using DataLab