NorRanGen: Generate a vector of random effects with specific correlation...

Description Usage Arguments Value Examples

View source: R/functions.R

Description

Generate a vector of random effects that follow AR(1) correlation structure with rho=exp(-1/m) and variances sigmaj being given or andomly generated from uniform distribution on (1.2, 1.4).

Usage

1
NorRanGen(m, sigmaj = stats::runif(m, 1.2, 1.4))

Arguments

m

the length of the vector of the random effects

sigmaj

standard deviations for the random effect vector. Default is a vector from U(1.2, 1.4).

Value

the random effect vector of length m

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
   m=50;  raneff=NorRanGen(m)
# Note: If X ~ N(0, I), then tran X ~ N(0, A) with
# A being the cov matrix of AR(1), which contains the standard deviations sigma and the
# correlation coeff rho=exp(-1/m).
# i.e. corr= (1  rho  rho^2 ... rho^(m-1)
#             rho 1   rho   ... rho^(m-2)
#                 ...................
#             rho^(m-1) rho^(m-2) ... rho )
#
# To see the correlation values, run the following example
# j1=seq(25); cv=numeric()
# for (j in 1:25){
#  lag=abs(j1-j)/25; cv=rbind(cv, exp(-lag))
#}
# row.names(cv)=j1;  colnames(cv)=j1;  cv[1,]

HeterFunctionalData documentation built on Aug. 20, 2020, 9:06 a.m.