gen_cov_cor {spass}R Documentation

Generation of a covariance or a correlation matrix

Description

Generate a covariance or correlation matrix given parameters var, rho, theta for the covariance structure, Time for the observed timepoints and cov=TRUE if a covariance or cov=FALSE if a correlation-matrix is generated.

Usage

gen_cov_cor(var = 1, rho, theta, Time, cov = TRUE)

Arguments

var

variance at each timepoint

rho

correlation between two adjacent timepoints 1 timeunit appart

theta

variable specifying the type of the correlation structure: see 'Details'

Time

list with time measures which are used to generate the covariance- or correlation-structure: see 'Details'

cov

TRUE/FALSE statement which determines if a covariance- or a correlation-matrix is generated.

Details

gen_cov_cor is used to generate either a covariance or a correlation matrix. Given vector Time and parameters var, rho and theta the following two equations are used to calculate the covariance and the correlation between two timepoints, respectively: cov(Time[i],Time[j])=var*(rho^(abs(Time[i]-Time[j])^theta)) corr(Time[i],Time[j])=rho^(abs(Time[i]-Time[j])^theta) ]]

Value

gen_cov_cor returns a covariance or correlation matrix.

Source

gen_cov_cor uses code contributed by Roland Gerard Gera

@seealso r.gee.1subgroup for information on the generated longitudinal data and n.gee.1subgroup for the calculation of initial sample sizes for longitudinal GEE-models and bssr.gee.1subgroup for blinded sample size re-estimation within a trial. See estimcov for more information on the used minimization algorithms.

Examples

#Generate a covariance-matrix with measurements at Baseline and at times c(1,1.5,2,5)

covar<-gen_cov_cor(var=3,rho=0.25,theta=1,Time=c(0,1,1.5,2,5),cov=TRUE)
covar

#Generate a correlation-matrix with the same values

corr<-gen_cov_cor(rho=0.25,theta=1,Time=c(0,1,1.5,2,5),cov=FALSE)
corr

[Package spass version 1.3 Index]