emmreml function

Solver for Gaussian mixed model with known covariance structure.

Solver for Gaussian mixed model with known covariance structure.

This function estimates the parameters of the model [REMOVE_ME]y=Xβ+Zu+e[REMOVEME2] y=X\beta+Z u+ e [REMOVE_ME_2] where yy is the nn vector of response variable, XX is a nxqn x q known design matrix of fixed effects, ZZ is a nxln x l known design matrix of random effects, β\beta is qx1q x 1 vector of fixed effects coefficients and uu and ee are independent variables with Nl(0,σu2K)N_l(0, \sigma^2_u K) and Nn(0,σe2In)N_n(0, \sigma^2_e I_n) correspondingly. It also produces the BLUPs and some other useful statistics like large sample estimates of variances and PEV.

Description

This function estimates the parameters of the model

y=Xβ+Zu+e y=X\beta+Z u+ e

where yy is the nn vector of response variable, XX is a nxqn x q known design matrix of fixed effects, ZZ is a nxln x l known design matrix of random effects, β\beta is qx1q x 1 vector of fixed effects coefficients and uu and ee are independent variables with Nl(0,σu2K)N_l(0, \sigma^2_u K) and Nn(0,σe2In)N_n(0, \sigma^2_e I_n) correspondingly. It also produces the BLUPs and some other useful statistics like large sample estimates of variances and PEV.

emmreml(y, X, Z, K,varbetahat=FALSE,varuhat=FALSE, PEVuhat=FALSE, test=FALSE)

Arguments

  • y: nx1n x 1 numeric vector
  • X: nxqn x q matrix
  • Z: nxln x l matrix
  • K: lxll x l matrix of known relationships
  • varbetahat: TRUE or FALSE
  • varuhat: TRUE or FALSE
  • PEVuhat: TRUE or FALSE
  • test: TRUE or FALSE

Returns

  • Vu: Estimate of σu2\sigma^2_u

  • Ve: Estimate of σe2\sigma^2_e

  • betahat: BLUEs for β\beta

  • uhat: BLUPs for uu

  • Xsqtestbeta: χ2\chi^2 test statistics for testing whether the fixed effect coefficients are equal to zero.

  • pvalbeta: pvalues obtained from large sample theory for the fixed effects. We report the pvalues adjusted by the "padjust" function for all fixed effect coefficients.

  • Xsqtestu: χ2\chi^2 test statistic values for testing whether the BLUPs are equal to zero.

  • pvalu: pvalues obtained from large sample theory for the BLUPs. We report the pvalues adjusted by the "padjust" function.

  • varuhat: Large sample variance for the BLUPs.

  • varbetahat: Large sample variance for the β\beta's.

  • PEVuhat: Prediction error variance estimates for the BLUPs.

  • loglik: loglikelihood for the model.

Examples

n=200 M1<-matrix(rnorm(n*300), nrow=n) K1<-cov(t(M1)) K1=K1/mean(diag(K1)) covY<-2*K1+1*diag(n) Y<-10+crossprod(chol(covY),rnorm(n)) #training set Trainset<-sample(1:n, 150) funout<-emmreml(y=Y[Trainset], X=matrix(rep(1, n)[Trainset], ncol=1), Z=diag(n)[Trainset,], K=K1) cor(Y[-Trainset], funout$uhat[-Trainset])
  • Maintainer: Deniz Akdemir
  • License: GPL-2
  • Last published: 2015-07-22

Useful links