spass (version 1.2)

gen_cov_cor: 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.

Value

gen_cov_cor returns a covariance or correlation matrix.

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) ]]

Examples

Run this code
# NOT RUN {
#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
# }

Run the code above in your browser using DataLab