construct_covmat {LTFHPlus} | R Documentation |
Constructing a covariance matrix for a variable number of phenotypes
Description
construct_covmat
returns the covariance matrix for an
underlying target individual and a variable number of its family members
for a variable number of phenotypes. It is a wrapper around
construct_covmat_single
and construct_covmat_multi
.
Usage
construct_covmat(
fam_vec = c("m", "f", "s1", "mgm", "mgf", "pgm", "pgf"),
n_fam = NULL,
add_ind = TRUE,
h2 = 0.5,
genetic_corrmat = NULL,
full_corrmat = NULL,
phen_names = NULL
)
Arguments
fam_vec |
A vector of strings holding the different family members. All family members must be represented by strings from the following list:
|
n_fam |
A named vector holding the desired number of family members.
See |
add_ind |
A logical scalar indicating whether the genetic component of the full liability as well as the full liability for the underlying individual should be included in the covariance matrix. Defaults to TRUE. |
h2 |
Either a number representing the heritability on liability scale for one single phenotype or a numeric vector representing the liability-scale heritabilities for a positive number of phenotypes. All entries in h2 must be non-negative and at most 1. |
genetic_corrmat |
Either |
full_corrmat |
Either |
phen_names |
Either |
Details
This function can be used to construct a covariance matrix for
a given number of family members. If h2
is a number,
each entry in this covariance matrix equals the percentage
of shared DNA between the corresponding individuals times
the liability-scale heritability
h^2
. However, if h2
is a numeric vector,
and genetic_corrmat and full_corrmat are two symmetric correlation matrices,
each entry equals either the percentage of shared DNA between the corresponding
individuals times the liability-scale heritability
h^2
or the percentage of shared DNA between the corresponding individuals times the correlation between the corresponding phenotypes. The family members can be specified using one of two possible formats.
Value
If either fam_vec
or n_fam
is used as the argument, if it is of
the required format, if add_ind
is a logical scalar and h2
is a
number satisfying
0 \leq h2 \leq 1
, then the function construct_covmat
will return a named covariance matrix, which row- and column-number
corresponds to the length of fam_vec
or n_fam
(+ 2 if add_ind=TRUE
).
However, if h2
is a numeric vector satisfying
0 \leq h2_i \leq 1
for all
i \in \{1,...,n_pheno\}
and if
genetic_corrmat
and full_corrmat
are two numeric and symmetric matrices
satisfying that all diagonal entries are one and that all off-diagonal
entries are between -1 and 1, then construct_covmat
will return
a named covariance matrix, which number of rows and columns corresponds to the number
of phenotypes times the length of fam_vec
or n_fam
(+ 2 if add_ind=TRUE
).
If both fam_vec
and n_fam
are equal to c()
or NULL
,
the function returns either a 2 \times 2
matrix holding only the correlation
between the genetic component of the full liability and the full liability for the
individual under consideration, or a
(2 \times n_pheno) \times (2\times n_pheno)
matrix holding the correlation between the genetic component of the full
liability and the full liability for the underlying individual for all
phenotypes.
If both fam_vec
and n_fam
are specified, the user is asked to
decide on which of the two vectors to use.
Note that the returned object has different attributes, such as
fam_vec
, n_fam
, add_ind
and h2
.
See Also
get_relatedness
, construct_covmat_single
,
construct_covmat_multi
Examples
construct_covmat()
construct_covmat(fam_vec = c("m","mgm","mgf","mhs1","mhs2","mau1"),
n_fam = NULL,
add_ind = TRUE,
h2 = 0.5)
construct_covmat(fam_vec = NULL,
n_fam = stats::setNames(c(1,1,1,2,2), c("m","mgm","mgf","s","mhs")),
add_ind = FALSE,
h2 = 0.3)
construct_covmat(h2 = c(0.5,0.5), genetic_corrmat = matrix(c(1,0.4,0.4,1), nrow = 2),
full_corrmat = matrix(c(1,0.6,0.6,1), nrow = 2))