Learn R Programming

NAM (version 1.1.2)

BGS: Bayesian Gibbs Sampler

Description

Univariate mixed model solver through Gibbs Sampling.

Usage

gibbs(y,Z=NULL,X=NULL,iK=NULL,Iter=1500,Burn=500,Thin=4,DF=5,S=NULL)

Arguments

y
Numeric vector of observations ($n$) describing the trait to be analyzed. NA is allowed.
Z
Right-hand side formula or list of numeric matrices ($n$ by $p$) with incidence matrices for random effect. NA is not allowed.
X
Right-hand side formula or incidence matrices ($n$ by $p$) for fixed effect. NA is not allowed.
iK
Numeric matrix or list of numeric matrices ($p$ by $p$) corresponding to the the inverse kinship matrix of each random effect with $p$ parameters.
Iter
Integer. Number of iterations or samples to be generated.
Burn
Integer. Number of iterations or samples to be discarted.
Thin
Integer. Thinning parameter, used to save memory by storing only one every 'Thin' samples.
DF
Integer. Hyperprior degrees of freedom of variance components.
S
Integer of NULL. Hyperprior shape of variance components. If NULL, the hyperprior solution for the scale parameter is calculated as proposed by de los Campos et al. (2013).

Value

  • The function gibbs returns a list with variance components distribution a posteriori (Posterior.VC) and mode estimated (VC.mode), a list with the posterior distribution of regression coefficients (Posterior.Coef) and the posterior mode (Coef.mode) and mean (Coef.mean), and the fitted values using the mean (Fit.mean) and mode (Fit.mode) of posterior coefficients.

Details

Solve Gaussian mixed models in the Bayesian framework as described by Garcia-Cortes and Sorensen (1996) and Sorensen and Gianola, D. (2002) with conjugated priors.

References

de los Campos, G., Hickey, J. M., Pong-Wong, R., Daetwyler, H. D., and Calus, M. P. (2013). Whole-genome regression and prediction methods applied to plant and animal breeding. Genetics, 193(2), 327-345.

Garcia-Cortes, L. A., and Sorensen, D. (1996). On a multivariate implementation of the Gibbs sampler. Genetics Selection Evolution, 28(1), 121-126.

Sorensen, D., & Gianola, D. (2002). Likelihood, Bayesian, and MCMC methods in quantitative genetics. Springer Science & Business Media.

Examples

Run this code
# Fitting Mixed Model
data(tpod)
S = seq(1,350,50)
test1=gibbs(y,X=~factor(fam),Z=gen[,S],S=0.5)
plot(test1$Fit.mean,y)

# Fitting GBLUP
K = tcrossprod(gen)
K = K/mean(diag(K))
iK = chol2inv(K)
test2=gibbs(y,iK=iK)
plot(test2$Fit.mean,y)

Run the code above in your browser using DataLab