Learn R Programming

glmmGS (version 0.5-1)

glmmGS.CovarianceModel: Construct covariance models for the glmmGS function

Description

Construct a list defining a covariance model for the glmmGS function.

Usage

glmmGS.CovarianceModel(type, ...)

Arguments

type
a string specifying the type of the covariance model. Current valid types are: identity, precision. The covariance components of the identity and precision models represent the global precision parameters.
...
optional arguments containing information about the precision or covariance structure. If the type is identity, no optional arguments are required; if the type is precision, the optional argument is a precision matrix

Value

  • A list of parameters specifying a covariance model for the glmmGS function.

See Also

glmmGS, glmmGS.SparseMatrix

Examples

Run this code
# Set number of columns
	ncols <- 100;

# Identity covariance model (no need to specify matrix dimensions)
 	# Define dense-precision model
 	I <- glmmGS.CovarianceModel("identity");

# Dense-precision model

	# Dense precision matrix
	R <- as.matrix(rnorm(ncols * ncols), nrow = ncols, ncol = ncols);
	R <- R %*% t(R);
	
 	# Define dense-precision model
 	T.dense <- glmmGS.CovarianceModel("precision", R);

# Sparse-precision model

	# Sparse precision matrix
	R <- diag(rep(1, ncols));
	for (i in 2:ncols)
	{
		R[i - 1, i] <- 0.5;
		R[i, i - 1] <- 0.5;
	}
	
	# Create sparse matrix from R
	R.sparse = glmmGS.SparseMatrix(R);
	
 	# Define sparse-precision model
 	T.sparse <- glmmGS.CovarianceModel("precision", R.sparse);

Run the code above in your browser using DataLab