Title: | Estimating Dynamic Heritability and Twin Model Comparison |
---|---|
Description: | Twin models that are able to estimate the dynamic behaviour of the variance components in the classical twin models with respect to age using B-splines and P-splines. |
Authors: | Liang He |
Maintainer: | Liang He <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.9.0 |
Built: | 2024-11-27 06:51:47 UTC |
Source: | CRAN |
The package implements two novel twin models that are able to estimate dynamic behaviour of the variance components in the classical twin models with respect to age or other covariates such as calendar year.
Package: | ACEt |
Type: | Package |
Version: | 1.8.2 |
Date: | 2022-09-23 |
License: | GPL |
Liang He
Maintainer: Liang He <[email protected]>
He, L., Sillanpää, M.J., Silventoinen, K., Kaprio, J. and Pitkäniemi, J., 2016. Estimating Modifying Effect of Age on Genetic and Environmental Variance Components in Twin Models. Genetics, 202(4), pp.1313-1328.
He, L., Pitkäniemi, J., Silventoinen, K. and Sillanpää, M.J., 2017. ACEt: An R package for estimating dynamic heritability and comparing twin models. Behavior Genetics, 47(6), pp.620-641.
# data(data_ace) # AtCtEt(data_ace$mz, data_ace$dz, mod=c('d','d','c'), knot_a = 5, knot_c = 4) # AtCtEtp(data_ace$mz, data_ace$dz, knot_a = 6, mod=c('d','l','c'))
# data(data_ace) # AtCtEt(data_ace$mz, data_ace$dz, mod=c('d','d','c'), knot_a = 5, knot_c = 4) # AtCtEtp(data_ace$mz, data_ace$dz, knot_a = 6, mod=c('d','l','c'))
Compute the posterior mean and CIs for the ACE(t)-p model using the MCMC methods
acetp_mcmc(acetp, iter_num = 10000, sd = 0.1, burnin = 1000)
acetp_mcmc(acetp, iter_num = 10000, sd = 0.1, burnin = 1000)
acetp |
An object from the 'AtCtEtp' function. |
iter_num |
The number of the iterations in the MCMC procedure. |
sd |
The standard error of the normal proposal distribution in the MCMC algorithm. The default value is 0.1. |
burnin |
The number of burn-in, which must be smaller than the number of iteration. |
beta_a_mc |
The estimates of the spline coefficients for the A component based on the posterior mean from the MCMC method. |
beta_c_mc |
The estimates of the spline coefficients for the C component based on the posterior mean from the MCMC method. |
beta_e_mc |
The estimates of the spline coefficients for the E component based on the posterior mean from the MCMC method. |
cov_mc |
The posterior covariance matrix of the estimates of the spline coefficients. |
knots_a |
A vector of the knot positions for the A component. |
knots_c |
A vector of the knot positions for the C component. |
knots_e |
A vector of the knot positions for the E component. |
Liang He
He, L., Sillanpää, M.J., Silventoinen, K., Kaprio, J. and Pitkäniemi, J., 2016. Estimating Modifying Effect of Age on Genetic and Environmental Variance Components in Twin Models. Genetics, 202(4), pp.1313-1328.
# data(data_ace) # result <- AtCtEp(data_ace$mz, data_ace$dz, knot_a = 7, knot_c = 7) # result_mc <- acetp_mcmc(result, iter_num=10000, burnin = 500)
# data(data_ace) # result <- AtCtEp(data_ace$mz, data_ace$dz, knot_a = 7, knot_c = 7) # result_mc <- acetp_mcmc(result, iter_num=10000, burnin = 500)
The ACE(t) model with the A, C and E variance components as functions with respect to age modelled by B-splines.
AtCtEt(data_m, data_d, mod = c('d','d','d'), knot_a = 5, knot_c = 5, knot_e = 5, loc = c('e','e','e'), boot=FALSE, num_b = 100, init = rep(0,3), robust = 0)
AtCtEt(data_m, data_d, mod = c('d','d','d'), knot_a = 5, knot_c = 5, knot_e = 5, loc = c('e','e','e'), boot=FALSE, num_b = 100, init = rep(0,3), robust = 0)
data_m |
An |
data_d |
An |
mod |
A character vector of length 3. Each element specifies the function for the A, C or E component respectively. The A and C components can be 'd'(dynamic), 'c'(constant) or 'n'(NA). The E component can only be 'd' or 'c'. Thus, |
knot_a |
The number of interior knots of the B-spline for the A component, which must be no less than 3. The default value is 5. |
knot_c |
The number of interior knots of the B-spline for the C component, which must be no less than 3. The default value is 5. |
knot_e |
The number of interior knots of the B-spline for the E component, which must be no less than 3. The default value is 5. |
loc |
A 1x3 character vector indicating how to place knots for each component: evenly ("e") or quantile-based ("q"). The default value is "e". |
boot |
A logical indicator of whether to use the bootstrap method to calculate the confidence interval. The default is FALSE. |
num_b |
The number of replicates when the bootstrap method is used (i.e. |
init |
A 3x1 vector of the initial values for the optimization. The default values are 1. |
robust |
An integer indicating the number of different initial values that the function will randomly generate and try in the optimization. The default value is 0. |
If the variance is close to the boundary (0), it is better to use the bootstrap method to get the CIs. The optimization algorithm may sometimes end up with a local minimum. It is recommended to try different random initial values by setting 'robust'.
n_beta_a |
The number of spline coefficients for the A component. |
n_beta_c |
The number of spline coefficients for the C component. |
n_beta_e |
The number of spline coefficients for the E component. |
beta_a |
The estimated spline coefficients (if the model parameter is 'd') or variance (if the model parameter is 'c') of the A component. |
beta_c |
The estimated spline coefficients (if the model parameter is 'd') or variance (if the model parameter is 'c') of the C component. |
beta_e |
The estimated spline coefficients (if the model parameter is 'd') or variance (if the model parameter is 'c') of the E component. |
hessian_ap |
The approximate numerical observed information matrix from the quasi-Newton algorithm. |
hessian |
The expected information matrix calculated analytically. |
con |
An indicator of convergence of the optimization algorithm. An integer code 0 indicates successful completion. See 'optim' for more details. |
lik |
The minus log-likelihood. |
knots_a |
A vector of the knot positions for the A component. |
knots_c |
A vector of the knot positions for the C component. |
knots_e |
A vector of the knot positions for the E component. |
boot |
A list containing pointwise CIs estimated from the bootstrap method when |
Liang He
He, L., Sillanpää, M.J., Silventoinen, K., Kaprio, J. and Pitkäniemi, J., 2016. Estimating Modifying Effect of Age on Genetic and Environmental Variance Components in Twin Models. Genetics, 202(4), pp.1313-1328.
He, L., Pitkäniemi, J., Silventoinen, K. and Sillanpää, M.J., 2017. ACEt: An R package for estimating dynamic heritability and comparing twin models. Behavior Genetics, 47(6), pp.620-641.
data(data_ace) result <- AtCtEt(data_ace$mz, data_ace$dz, mod=c('d','d','c'))
data(data_ace) result <- AtCtEt(data_ace$mz, data_ace$dz, mod=c('d','d','c'))
The ACE(t)-p model with the A, C and E variance components as functions with respect to age modelled by P-splines.
AtCtEtp(data_m, data_d, knot_a = 8, knot_c = 8, knot_e = 8, eps = 0.1, mod=c('d','d','d'), robust = 0)
AtCtEtp(data_m, data_d, knot_a = 8, knot_c = 8, knot_e = 8, eps = 0.1, mod=c('d','d','d'), robust = 0)
data_m |
An |
data_d |
An |
knot_a |
The number of interior knots of the B-spline for the A component. The default value is 8. |
knot_c |
The number of interior knots of the B-spline for the C component. The default value is 8. |
knot_e |
The number of interior knots of the B-spline for the E component. The default value is 8. |
eps |
Tolerance for convergence of the EM algorithm iterations. The default value is 0.1. |
mod |
A character vector of length 3. Each element specifies the function for the A, C or E component respectively. The components can be 'd'(dynamic), 'c'(constant) or 'l'(linear). The default is c('d','d','d'). |
robust |
An integer indicating the number of different initial values that the function will randomly generate and try in the optimization. The default value is 0. |
When the 'mod' argument for a component is 'd'(dynamic), the corresponding 'beta' is the spline coefficients. When the 'mod' argument for a component is 'l'(linear), the corresponding 'beta' is a vector of two values, the exponential of which (exp(beta)) are the variances at the minimum and maximum age (or other covariates) provided in the data. When the 'mod' argument for a component is 'c'(constant), the corresponding 'beta' has only one value and exp(beta) is the variance.
var_b_a |
The estimated variance for the penalized coefficient for the A components. |
var_b_c |
The estimated variance for the penalized coefficient for the C components. |
var_b_e |
The estimated variance for the penalized coefficient for the E components. |
beta_a |
The estimated spline coefficients of the A component. See 'details' for more information. |
beta_c |
The estimated spline coefficients of the C component. See 'details' for more information. |
beta_e |
The estimated spline coefficients of the E component. See 'details' for more information. |
con |
An indicator of convergence of the optimization algorithm. An integer code 0 indicates successful completion. See 'optim' for more details. |
lik |
The minus log marginal likelihood. |
knot_a |
A vector of the knot positions for the A component. |
knot_c |
A vector of the knot positions for the C component. |
knot_e |
A vector of the knot positions for the E component. |
Liang He
He, L., Sillanpää, M.J., Silventoinen, K., Kaprio, J. and Pitkäniemi, J., 2016. Estimating Modifying Effect of Age on Genetic and Environmental Variance Components in Twin Models. Genetics, 202(4), pp.1313-1328.
He, L., Pitkäniemi, J., Silventoinen, K. and Sillanpää, M.J., 2017. ACEt: An R package for estimating dynamic heritability and comparing twin models. Behavior Genetics, 47(6), pp.620-641.
# data(data_ace) # result <- AtCtEtp(data_ace$mz, data_ace$dz, knot_e = 7, knot_c = 5, mod=c('d','d','d'))
# data(data_ace) # result <- AtCtEtp(data_ace$mz, data_ace$dz, knot_e = 7, knot_c = 5, mod=c('d','d','d'))
The ADE(t) model with the A, D and E variance components as functions with respect to age modelled by B-splines.
AtDtEt(data_m, data_d, mod = c('d','d','d'), knot_a = 5, knot_d = 5, knot_e = 5, loc = c('e','e','e'), boot=FALSE, num_b = 100, init = rep(0,3), robust = 0)
AtDtEt(data_m, data_d, mod = c('d','d','d'), knot_a = 5, knot_d = 5, knot_e = 5, loc = c('e','e','e'), boot=FALSE, num_b = 100, init = rep(0,3), robust = 0)
data_m |
An |
data_d |
An |
mod |
A character vector of length 3. Each element specifies the function for the A, D or E component respectively. The A and D components can be 'd'(dynamic), 'c'(constant) or 'n'(NA). The E component can only be 'd' or 'c'. Thus, |
knot_a |
The number of interior knots of the B-spline for the A component, which must be no less than 3. The default value is 5. |
knot_d |
The number of interior knots of the B-spline for the D component, which must be no less than 3. The default value is 5. |
knot_e |
The number of interior knots of the B-spline for the E component, which must be no less than 3. The default value is 5. |
loc |
A 1x3 character vector indicating how to place knots for each component: evenly ("e") or quantile-based ("q"). The default value is "e". |
boot |
A logical indicator of whether to use the bootstrap method to calculate the confidence interval. The default is FALSE. |
num_b |
The number of replicates when the bootstrap method is used (i.e. |
init |
A 3x1 vector of the initial values for the optimization. The default values are 1. |
robust |
An integer indicating the number of different initial values that the function will randomly generate and try in the optimization. The default value is 0. |
If the variance is close to the boundary (0), it is better to use the bootstrap method to get the CIs. The optimization algorithm may sometimes end up with a local minimum. It is recommended to try different random initial values by setting 'robust'.
n_beta_a |
The number of spline coefficients for the A component. |
n_beta_d |
The number of spline coefficients for the D component. |
n_beta_e |
The number of spline coefficients for the E component. |
beta_a |
The estimated spline coefficients (if the model parameter is 'd') or variance (if the model parameter is 'c') of the A component. |
beta_d |
The estimated spline coefficients (if the model parameter is 'd') or variance (if the model parameter is 'c') of the D component. |
beta_e |
The estimated spline coefficients (if the model parameter is 'd') or variance (if the model parameter is 'c') of the E component. |
hessian_ap |
The approximate numerical observed information matrix from the quasi-Newton algorithm. |
hessian |
The expected information matrix calculated analytically. |
con |
An indicator of convergence of the optimization algorithm. An integer code 0 indicates successful completion. See 'optim' for more details. |
lik |
The minus log-likelihood. |
knots_a |
A vector of the knot positions for the A component. |
knots_d |
A vector of the knot positions for the D component. |
knots_e |
A vector of the knot positions for the E component. |
boot |
A list containing pointwise CIs estimated from the bootstrap method when |
Liang He
He, L., Sillanpää, M.J., Silventoinen, K., Kaprio, J. and Pitkäniemi, J., 2016. Estimating Modifying Effect of Age on Genetic and Environmental Variance Components in Twin Models. Genetics, 202(4), pp.1313-1328.
He, L., Pitkäniemi, J., Silventoinen, K. and Sillanpää, M.J., 2017. ACEt: An R package for estimating dynamic heritability and comparing twin models. Behavior Genetics, 47(6), pp.620-641.
data(data_ace) result <- AtDtEt(data_ace$mz, data_ace$dz, mod=c('d','d','c'))
data(data_ace) result <- AtDtEt(data_ace$mz, data_ace$dz, mod=c('d','d','c'))
This is an example dataset consisting of traits and ages for MZ and DZ twins.
data(data_ace)
data(data_ace)
The format is: mz: a matrix of simulated data for MZ twins. dz: a matrix of simulated data for DZ twins.
data(data_ace)
data(data_ace)
Plot variance curves or a heritability curve (with 95% CIs) of the A, C and E components with respect to age modelled by B-splines or P-splines.
plot_acet(acet, boot = FALSE, heri = FALSE, xlab, ylab, main, col, legend = TRUE)
plot_acet(acet, boot = FALSE, heri = FALSE, xlab, ylab, main, col, legend = TRUE)
acet |
An object obtained from the B-splines or P-splines functions. For the P-splines functions, an object from the MCMC method must be used. |
boot |
An logical indicator of whether the confidence bands estimated from the bootstrap method are plotted. The default is FALSE. Only available for the AtCtEt model. |
heri |
A logical indicator of whether to plot the dynamic heritability curve. The default is FALSE. |
xlab |
The 'xlab' argument in the plot funciton. The default is 'Age'. |
ylab |
The 'ylab' argument in the plot funciton. The default is 'Variance'. |
main |
The 'main' argument in the plot funciton. The default is 'Variance curves of the A, C, and E components' for variances and 'Dynamic heritability' for heritability. |
col |
The 'col' argument in the plot funciton. |
legend |
An logical indicator of whether the default legend is plotted. |
Liang He
He, L., Sillanpää, M.J., Silventoinen, K., Kaprio, J. and Pitkäniemi, J., 2016. Estimating Modifying Effect of Age on Genetic and Environmental Variance Components in Twin Models. Genetics, 202(4), pp.1313-1328.
# data(data_ace) # result <- AtCtEtp(data_ace$mz, data_ace$dz, knot_a = 5, knot_c = 4) # result_mc <- acetp_mcmc(result, iter_num=10000, burnin = 500) # plot_acet(result_mc) # result <- AtCtEt(data_ace$mz, data_ace$dz, mod=c('d','c','c'), knot_a = 9) # plot_acet(result)
# data(data_ace) # result <- AtCtEtp(data_ace$mz, data_ace$dz, knot_a = 5, knot_c = 4) # result_mc <- acetp_mcmc(result, iter_num=10000, burnin = 500) # plot_acet(result_mc) # result <- AtCtEt(data_ace$mz, data_ace$dz, mod=c('d','c','c'), knot_a = 9) # plot_acet(result)
Comparison of different ACE(t)-p models to test a linear or a constant variance component.
test_acetp(acetp, comp, sim = 100, robust = 0, pe = TRUE, verbose = TRUE)
test_acetp(acetp, comp, sim = 100, robust = 0, pe = TRUE, verbose = TRUE)
acetp |
An object from the AtCtEtp function. |
comp |
The component for which linearity or constancy is tested. This component must be specified as splines or linear in the AtCtEtp function. |
sim |
The number of the bootstrap resampling for approximating the null distribution when testing linearity. |
robust |
An integer indicating the number of different initial values that the function will randomly generate and try in the optimization. The default value is 0. |
pe |
A logical argument indicating whether to use penalized spline model to test linearity. The default value is TRUE. |
verbose |
A logical argument indicating whether to print testing information and results. The default value is TRUE. |
When pe=TRUE, the linearity is tested under a p-spline framework in which an LRT is performed. Otherwise, a test is performed for linearity under a spline framework without penalty on smoothness.
p |
The p-value for the test. |
llr |
The LRT statistic for testing linearity. |
llr_sim |
The simulated null distribution of the LRT statistic for testing linearity. |
chisq |
The chisq statistic for testing a constant or linearity. |
Liang He
He, L., Sillanpää, M.J., Silventoinen, K., Kaprio, J. and Pitkäniemi, J., 2016. Estimating Modifying Effect of Age on Genetic and Environmental Variance Components in Twin Models. Genetics, 202(4), pp.1313-1328.
He, L., Pitkäniemi, J., Silventoinen, K. and Sillanpää, M.J., 2017. ACEt: An R package for estimating dynamic heritability and comparing twin models. Behavior Genetics, 47(6), pp.620-641.
# data(data_ace) # result <- AtCtEtp(data_ace$mz, data_ace$dz, knot_e = 7, knot_c = 5, mod=c('d','d','l')) # re <- test_acetp(result, comp='e')
# data(data_ace) # result <- AtCtEtp(data_ace$mz, data_ace$dz, knot_e = 7, knot_c = 5, mod=c('d','d','l')) # re <- test_acetp(result, comp='e')