View source: R/make_VCV_matrix.R
make_VCV_matrix | R Documentation |
Function for generating simple covariance and correlation matrices based on a clustered variable
make_VCV_matrix(
data,
matrix = NULL,
V,
m,
sd,
n,
cluster,
obs,
type = c("vcv", "cor"),
vcal = c("none", "lnOR", "ROM"),
rho = 0.5
)
data |
Dataframe object containing effect sizes, their variance, unique IDs and clustering variable |
matrix |
Sometimes clustering can get quite complicated. Here you can 'daisy' chain matrices for different levels of clustering to build a combined matrix. Just add in the matrix with an existing cluster and set up a new cluster. |
V |
Name of the variable (as a string – e.g, "V1") containing effect size variances variances |
m |
Mean of the control group that is shared. Only used when vcal does not equal "none". |
sd |
Standard deviation of the control group that is shared. Only used when vcal does not equal "none". |
n |
Sample size of the control group that is shared.Only used when vcal does not equal "none". |
cluster |
Name of the variable (as a string – e.g, "V1") indicating which effects belong to the same cluster. Same value of 'cluster' are assumed to be nonindependent (correlated). |
obs |
Name of the variable (as a string – e.g, "V1") containing individual IDs for each value in the V (Vector of variances). If this parameter is missing, label will be labelled with consecutive integers starting from 1. |
type |
Optional logical parameter indicating whether a full variance-covariance matrix (default or "vcv") is needed or a correlation matrix ("cor") for the non-independent blocks of variance values. |
vcal |
The calculation of the covariance. Defaults to "none" in which case rho is used. Otherwise, "ROM" (log response ratio) or "LOR" (log odds ratios) can be calculated based on large-sample approximations. |
rho |
Known or assumed correlation value among effect sizes sharing same 'cluster' value. Default value is 0.5. |
{
data(sparrows)
# Add sampling variance
sparrows$v <- 1 / (sparrows$SampleSize - 3)
# Fake grouping
sparrows$group1 <- rep(1:2, length.out = nrow(sparrows))
# Calculate V based on Place grouping, just for demonstration purposes.
V <- make_VCV_matrix(data = sparrows, V = "v", cluster = "Place", type = "vcv", vcal = "none", rho = 0.5)
# Now we an add the second level of clustering
V <- make_VCV_matrix(data = sparrows, matrix = V, V = "v", cluster = "group1", type = "vcv", vcal = "none", rho = 0.5)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.