ggmix is a package that fits penalized multivariable linear mixed models with a single random effect to account for population structure in genetic association studies. The penalty allows one to fit high-dimensional models, i.e., where the number of variables is much larger than the number of observations.
This package currently supports the lasso penalty. The group lasso penalty will soon be implemented.

Model

We consider the following linear mixed model with a single random effect: \[\begin{equation} \mathbf{Y} = \mathbf{X} \boldsymbol{\beta} + \mathbf{b} + \mathbf{e} \end{equation}\] where the random effect \(\mathbf{b}\) and the error variance \(\mathbf{e}\) are assigned the distributions \[\begin{equation} \mathbf{b} \sim \mathcal{N}(0, \eta \sigma^2 \boldsymbol{\Phi}) \qquad \mathbf{e} \sim \mathcal{N}(0, (1-\eta)\sigma^2 \mathbf{I}) \end{equation}\] Here, \(\boldsymbol{\Phi}_{N_T \times N_T}\) is a known positive semi-definite and symmetric kinship matrix, \(\mathbf{I}_{N_T \times N_T}\) is the identity matrix and parameters \(\sigma^2\) and \(\eta \in [0,1]\) determine how the variance is divided between \(\mathbf{b}\) and \(\mathbf{e}\). The joint density of \(\mathbf{Y}\) is multivariate normal: \[\begin{equation} \mathbf{Y} | (\boldsymbol{\beta}, \eta, \sigma^2) \sim \mathcal{N}(\mathbf{X} \boldsymbol{\beta}, \eta \sigma^2 \boldsymbol{\Phi} + (1-\eta)\sigma^2 \mathbf{I}) \label{eq:prinen} \end{equation}\] Define the complete parameter vector \(\boldsymbol{\Theta} = \left(\boldsymbol{\beta}, \eta, \sigma^2 \right)\). The negative log-likelihood for~ is given by \[\begin{align} -\ell(\boldsymbol{\Theta}) & \propto \frac{N_T}{2}\log(\sigma^2) + \frac{1}{2}\log\left(\det(\mathbf{V})\right) + \frac{1}{2\sigma^2} \left(\mathbf{Y} - \mathbf{X} \boldsymbol{\beta}\right)^T \mathbf{V}^{-1} \left(\mathbf{Y} - \mathbf{X} \boldsymbol{\beta}\right) \label{eq:LogLike} \end{align}\]

where \(\mathbf{V} = \eta \boldsymbol{\Phi} + (1-\eta) \mathbf{I}\) and \(\det(\mathbf{V})\) is the determinant of \(\mathbf{V}\). Let \(\boldsymbol{\Phi} = \mathbf{U} \mathbf{D} \mathbf{U}^T\) be the eigen (spectral) decomposition of the kinship matrix \(\boldsymbol{\Phi}\), where \(\mathbf{U}_{N_T \times N_T}\) is an orthonormal matrix of eigenvectors (i.e. \(\mathbf{U} \mathbf{U}^T = \mathbf{I}\)) and \(\mathbf{D}_{N_T \times N_T}\) is a diagonal matrix of eigenvalues \(\Lambda_i\). Using some algebraic tricks, this can be simplified to

\[\begin{align} -\ell(\boldsymbol{\Theta}) & = \frac{N_T}{2}\log(\sigma^2) + \frac{1}{2} \sum_{i=1}^{N_T} \log(1 + \eta (\Lambda_i-1)) + \frac{1}{2\sigma^2} \sum_{i=1}^{N_T}\frac{\left( \tilde{Y}_i - \sum_{j=0}^{p}\tilde{X}_{ij+1}\beta_j \right) ^2}{1 + \eta (\Lambda_i-1)} \label{eq:LikeFinal} \end{align}\]

where \(\mathbf{\tilde{Y}} = \mathbf{U}^T \mathbf{Y}\), \(\mathbf{\tilde{X}} = \mathbf{U}^T \mathbf{X}\), \(\tilde{Y}_i\) denotes the \(i^{\textrm{th}}\) element of \(\mathbf{\tilde{Y}}\), \(\tilde{X}_{ij}\) is the \(i,j^{\textrm{th}}\) entry of \(\mathbf{\tilde{X}}\) and \(\mathbf{1}\) is a column vector of \(N_T\) ones.

We define the \(p+3\) length vector of parameters \(\boldsymbol{\Theta} := \left(\Theta_0, \Theta_1, \ldots, \Theta_{p+1}, \Theta_{p+2}, \Theta_{p+3}\right) = \left(\boldsymbol{\beta}, \eta, \sigma^2 \right)\) where \(\boldsymbol{\beta} \in \mathbb{R}^{p+1}, \eta \in [0,1], \sigma^2 >0\). In what follows, \(p+2\) and \(p+3\) are the indices in \(\boldsymbol{\Theta}\) for \(\eta\) and \(\sigma^2\), respectively. Define the objective function: \[\begin{equation} Q_{\lambda}(\boldsymbol{\Theta}) = f(\boldsymbol{\Theta}) + \lambda \sum_{j\neq 0} v_j P_j(\beta_j) \end{equation}\] where \(f(\boldsymbol{\Theta}):=-\ell(\boldsymbol{\Theta})\) is defined above, \(P_j(\cdot)\) is a penalty term on the fixed regression coefficients \(\beta_1, \ldots, \beta_{p+1}\) (we do not penalize the intercept), controlled by the nonnegative regularization parameter \(\lambda\), and \(v_j\) is the penalty factor for \(j\)th covariate. These penalty factors serve as a way of allowing parameters to be penalized differently. Note that we do not penalize \(\eta\) or \(\sigma^2\). The penalty term is a necessary constraint because in our applications, the sample size is much smaller than the number of predictors. An estimate of the regression parameters \(\widehat{\boldsymbol{\Theta}}_{\lambda}\) is obtained by \[\begin{equation} \widehat{\boldsymbol{\Theta}}_{\lambda} = \arg\min_{\boldsymbol{\Theta}} Q_{\lambda}(\boldsymbol{\Theta}) \label{eq:estimator} \end{equation}\]

Installation

The package can be installed from GitHub via

install.packages("pacman")
pacman::p_load_gh('sahirbhatnagar/ggmix')

Quick Start

We give a quick overview of the main functions and go into details in other vignettes. We will use the simulated data which ships with the package and can be loaded via:

library(ggmix)
data("admixed")
names(admixed)
#>  [1] "y"               "x"               "causal"         
#>  [4] "beta"            "kin"             "Xkinship"       
#>  [7] "not_causal"      "causal_positive" "causal_negative"
#> [10] "x_lasso"

For details on how this data was simulated, see help(admixed).

There are three basic inputs that ggmix needs:
1) \(Y\): a continuous response variable
2) \(X\): a matrix of covariates of dimension \(N \times p\) where \(N\) is the sample size and \(p\) is the number of covariates
3) \(\boldsymbol{\Phi}\): a kinship matrix

We can visualize the kinship matrix in the admixed data using the popkin package:

# need to install the package if you don't have it
# pacman::p_load_gh('StoreyLab/popkin')
popkin::plotPopkin(admixed$kin)

Fit the linear mixed model with Lasso Penalty

We will use the most basic call to the main function of this package ggmix. This function by default will fit a \(L_1\) penalized linear mixed model (LMM) for 100 distinct values of the tuning parameter \(\lambda\). It will choose its own sequence:

fit <- ggmix(x = admixed$x, y = admixed$y, kinship = admixed$kin)
names(fit)
#>  [1] "result"       "ggmix_object" "n_design"     "p_design"    
#>  [5] "lambda"       "coef"         "b0"           "beta"        
#>  [9] "df"           "eta"          "sigma2"       "nlambda"     
#> [13] "cov_names"    "call"
class(fit)
#> [1] "lassofullrank" "ggmix_fit"

We can see the solution path for each variable by calling the plot method for objects of class ggmix_fit:

plot(fit)

We can also get the coefficients for given value(s) of lambda using the coef method for objects of class ggmix_fit:

coef(fit, s = c(0.1,0.02))
#> 201 x 2 Matrix of class "dgeMatrix"
#>                      1             2
#> (Intercept) -0.3824525 -3.022775e-02
#> X62          0.0000000  0.000000e+00
#> X185         0.0000000  1.444670e-03
#> X371         0.0000000  9.513604e-03
#> X420         0.0000000  0.000000e+00
#> X487         0.0000000  0.000000e+00
#> X522         0.0000000  4.762820e-02
#> X586         0.0000000  0.000000e+00
#> X590         0.0000000  0.000000e+00
#> X611         0.0000000 -5.815075e-02
#> X628         0.0000000 -2.105724e-02
#> X740         0.0000000  0.000000e+00
#> X823         0.0000000  0.000000e+00
#> X890         0.0000000  0.000000e+00
#> X952         0.0000000  0.000000e+00
#> X1034        0.0000000  4.564401e-05
#> X1082        0.0000000  0.000000e+00
#> X1102        0.0000000  0.000000e+00
#> X1161        0.0000000 -1.129758e-03
#> X1168        0.0000000  0.000000e+00
#> X1223        0.0000000  1.849419e-01
#> X1257        0.0000000  0.000000e+00
#> X1311        0.0000000 -2.115882e-02
#> X1360        0.0000000  0.000000e+00
#> X1373        0.0000000 -4.195054e-02
#> X1416        0.0000000  0.000000e+00
#> X1429        0.0000000  5.241711e-02
#> X1443        0.0000000  0.000000e+00
#> X1483        0.0000000  0.000000e+00
#> X1570        0.0000000  0.000000e+00
#> X1608        0.0000000  0.000000e+00
#> X1649        0.0000000  0.000000e+00
#> X1695        0.0000000  0.000000e+00
#> X1830        0.0000000  2.461352e-02
#> X1832        0.0000000 -2.894939e-04
#> X1842        0.0000000  0.000000e+00
#> X1847        0.0000000  0.000000e+00
#> X1852        0.0000000  0.000000e+00
#> X1880        0.0000000  0.000000e+00
#> X1903        0.0000000  0.000000e+00
#> X1909        0.0000000  0.000000e+00
#> X1911        0.0000000  0.000000e+00
#> X2086        0.0000000  0.000000e+00
#> X2123        0.0000000  0.000000e+00
#> X2137        0.0000000  2.339515e-04
#> X2313        0.0000000  0.000000e+00
#> X2558        0.0000000  0.000000e+00
#> X2667        0.0000000  1.089556e-02
#> X2702        0.0000000  0.000000e+00
#> X2710        0.0000000  0.000000e+00
#> X2727        0.0000000  0.000000e+00
#> X2732        0.0000000  0.000000e+00
#> X2799        0.0000000  0.000000e+00
#> X2808        0.0000000  0.000000e+00
#> X2860        0.0000000 -3.174447e-02
#> X2938        0.0000000  7.740276e-02
#> X3143        0.0000000  0.000000e+00
#> X3155        0.0000000  0.000000e+00
#> X3164        0.0000000 -5.971508e-02
#> X3271        0.0000000  0.000000e+00
#> X3275        0.0000000  0.000000e+00
#> X3303        0.0000000  0.000000e+00
#> X3343        0.0000000  0.000000e+00
#> X3358        0.0000000  9.754440e-03
#> X3427        0.0000000  0.000000e+00
#> X3448        0.0000000  0.000000e+00
#> X3520        0.0000000  5.617475e-02
#> X3557        0.0000000  0.000000e+00
#> X3591        0.0000000  0.000000e+00
#> X3601        0.0000000  1.412592e-03
#> X3665        0.0000000 -9.474808e-03
#> X3674        0.0000000  0.000000e+00
#> X3726        0.0000000  0.000000e+00
#> X3752        0.0000000 -4.885395e-02
#> X3765        0.0000000  0.000000e+00
#> X3878        0.0000000  0.000000e+00
#> X3960        0.0000000  0.000000e+00
#> X3987        0.0000000 -2.543262e-02
#> X4011        0.0000000  0.000000e+00
#> X4022        0.0000000  0.000000e+00
#> X4128        0.0000000  0.000000e+00
#> X4263        0.0000000  0.000000e+00
#> X4271        0.0000000  0.000000e+00
#> X4401        0.0000000  0.000000e+00
#> X4422        0.0000000  0.000000e+00
#> X4442        0.0000000  0.000000e+00
#> X4529        0.0000000  0.000000e+00
#> X4648        0.0000000  2.744219e-02
#> X4712        0.0000000  0.000000e+00
#> X4783        0.0000000 -1.283195e-01
#> X4793        0.0000000  0.000000e+00
#> X4904        0.0000000 -2.785313e-03
#> X4929        0.0000000 -3.320176e-02
#> X4976        0.0000000  0.000000e+00
#> X5016        0.0000000  0.000000e+00
#> X5087        0.0000000  0.000000e+00
#> X5100        0.0000000  0.000000e+00
#> X5241        0.0000000  0.000000e+00
#> X5362        0.0000000  7.636294e-03
#> X5374        0.0000000  0.000000e+00
#> X5419        0.0000000  0.000000e+00
#> X5471        0.0000000 -2.418548e-02
#> X5485        0.0000000  6.155624e-02
#> X5526        0.0000000  0.000000e+00
#> X5527        0.0000000 -2.973285e-02
#> X5536        0.0000000  0.000000e+00
#> X5588        0.0000000  0.000000e+00
#> X5641        0.0000000  0.000000e+00
#> X5653        0.0000000  0.000000e+00
#> X5738        0.0000000  0.000000e+00
#> X5744        0.0000000  0.000000e+00
#> X5774        0.0000000 -2.382197e-04
#> X5779        0.0000000  8.690426e-02
#> X5810        0.0000000  0.000000e+00
#> X5816        0.0000000 -3.544246e-02
#> X5827        0.0000000  0.000000e+00
#> X5865        0.0000000  0.000000e+00
#> X5945        0.0000000  0.000000e+00
#> X5970        0.0000000 -2.861750e-03
#> X6010        0.0000000  0.000000e+00
#> X6039        0.0000000 -1.799509e-04
#> X6082        0.0000000  0.000000e+00
#> X6085        0.0000000  0.000000e+00
#> X6128        0.0000000  0.000000e+00
#> X6231        0.0000000  0.000000e+00
#> X6237        0.0000000  3.101353e-02
#> X6259        0.0000000  0.000000e+00
#> X6277        0.0000000  0.000000e+00
#> X6294        0.0000000  0.000000e+00
#> X6445        0.0000000  7.820992e-02
#> X6503        0.0000000  0.000000e+00
#> X6593        0.0000000  0.000000e+00
#> X6621        0.0000000  0.000000e+00
#> X6636        0.0000000  2.832846e-03
#> X6656        0.0000000  0.000000e+00
#> X6690        0.0000000 -3.812151e-02
#> X6717        0.0000000 -3.392257e-02
#> X6728        0.0000000  0.000000e+00
#> X6737        0.0000000 -3.056001e-02
#> X6771        0.0000000  0.000000e+00
#> X6786        0.0000000  0.000000e+00
#> X6848        0.0000000 -1.424040e-04
#> X6849        0.0000000  0.000000e+00
#> X6899        0.0000000  0.000000e+00
#> X7032        0.0000000  0.000000e+00
#> X7130        0.0000000 -4.399505e-03
#> X7136        0.0000000 -2.595988e-02
#> X7208        0.0000000  0.000000e+00
#> X7326        0.0000000  0.000000e+00
#> X7437        0.0000000 -1.105681e-02
#> X7459        0.0000000  0.000000e+00
#> X7623        0.0000000  0.000000e+00
#> X7650        0.0000000  0.000000e+00
#> X7703        0.0000000  0.000000e+00
#> X7755        0.0000000 -1.078978e-02
#> X7795        0.0000000  0.000000e+00
#> X7824        0.0000000  0.000000e+00
#> X7865        0.0000000 -1.435689e-04
#> X7935        0.0000000  0.000000e+00
#> X8044        0.0000000  0.000000e+00
#> X8141        0.0000000  0.000000e+00
#> X8212        0.0000000  0.000000e+00
#> X8221        0.0000000  4.241038e-02
#> X8274        0.0000000  0.000000e+00
#> X8444        0.0000000  0.000000e+00
#> X8468        0.0000000  0.000000e+00
#> X8494        0.0000000  0.000000e+00
#> X8636        0.0000000  0.000000e+00
#> X8721        0.0000000  0.000000e+00
#> X8762        0.0000000  1.692332e-02
#> X8806        0.0000000  2.326888e-03
#> X8807        0.0000000  7.442365e-03
#> X8860        0.0000000 -2.723558e-04
#> X8991        0.0000000  6.781520e-03
#> X9173        0.0000000 -2.745558e-02
#> X9272        0.0000000  0.000000e+00
#> X9417        0.0000000  0.000000e+00
#> X9523        0.0000000  0.000000e+00
#> X9544        0.0000000  0.000000e+00
#> X9568        0.0000000  0.000000e+00
#> X9590        0.0000000  0.000000e+00
#> X9608        0.0000000  0.000000e+00
#> X9648        0.0000000  0.000000e+00
#> X9657        0.0000000  0.000000e+00
#> X9732        0.0000000  0.000000e+00
#> X9781        0.0000000  2.161324e-02
#> X9841        0.0000000  0.000000e+00
#> X9928        0.0000000  0.000000e+00
#> X10172       0.0000000 -7.567442e-02
#> X10175       0.0000000 -6.859008e-02
#> X10186       0.0000000  8.569396e-02
#> X336        -0.5419773 -8.088787e-01
#> X7638        0.2255876  5.957670e-01
#> X1199        0.0000000  3.060297e-02
#> X1536        0.8190978  1.030792e+00
#> X1968        0.0000000 -4.172890e-01
#> X1943        0.3533220  7.007584e-01
#> X2849       -0.3999047 -7.372429e-01
#> X8087        0.0000000 -4.634478e-02
#> X56          0.0000000 -2.627184e-01
#> X4106       -0.2672208 -4.243800e-01

We can also get predictions (\(X\widehat{\boldsymbol{\beta}}\)) using the predict method for objects of class ggmix_fit:

# need to provide x to the predict function
head(predict(fit, s = 0.01, newx = admixed$x))
#>              1
#> id1 -1.4571074
#> id2  0.3673683
#> id3 -2.8018368
#> id4 -1.1150805
#> id5 -2.2151251
#> id6  0.2051633

Find the Optimal Value of the Tuning Parameter

We use the Generalized Information Criterion (GIC) to select the optimal value for \(\lambda\). The GIC takes the form

\[GIC_{\lambda} = -2 \ell(\widehat{\boldsymbol{\beta}}, \widehat{\sigma}^2, \widehat{\eta}) + a_n \cdot \widehat{df}_{\lambda}\]

where \(\ell(\cdot)\) is the log-likelihood evaluated at the converged values of the parameters, \(\widehat{df}_{\lambda}\) is the number of non-zero elements in \(\widehat{\boldsymbol{\beta}}_{\lambda}\) plus two (representing the variance parameters \(\eta\) and \(\sigma^2\)), and \(a_n\) is a non-negative penalty parameter. The BIC has \(a_n = \log(n)\), and AIC has \(a_n = 2\). The user can specify the value of \(a_n\) that they want. The default is \(a_n = log(log(n)) * log(p)\) which corresponds to a high-dimensional BIC (HDBIC):

# pass the fitted object from ggmix to the gic function:
hdbic <- gic(fit)
class(hdbic)
#> [1] "ggmix_gic"     "lassofullrank" "ggmix_fit"

# we can also fit the BIC by specifying the an argument
bicfit <- gic(fit, an = log(length(admixed$y)))

We can plot the HDBIC values against \(\log(\lambda)\) using the plot method for objects of class ggmix_gic:

plot(hdbic)

The optimal value for lambda according to the HDBIC is (i.e. the \(\lambda\) that leads to the minium HDBIC):

hdbic[["lambda.min"]]
#> [1] 0.05596623

We can also plot the BIC:

plot(bicfit, ylab = "BIC")

bicfit[["lambda.min"]]
#> [1] 0.05596623

Get Coefficients Corresponding to Optimal Model

We can use the object outputted by the gic function to extract the coefficients using the coef method for objects of class ggmix_gic:

coef(hdbic)
#> 201 x 1 sparse Matrix of class "dgCMatrix"
#>                       1
#> (Intercept) -0.26684191
#> X62          .         
#> X185         .         
#> X371         .         
#> X420         .         
#> X487         .         
#> X522         .         
#> X586         .         
#> X590         .         
#> X611         .         
#> X628         .         
#> X740         .         
#> X823         .         
#> X890         .         
#> X952         .         
#> X1034        .         
#> X1082        .         
#> X1102        .         
#> X1161        .         
#> X1168        .         
#> X1223        .         
#> X1257        .         
#> X1311        .         
#> X1360        .         
#> X1373        .         
#> X1416        .         
#> X1429        .         
#> X1443        .         
#> X1483        .         
#> X1570        .         
#> X1608        .         
#> X1649        .         
#> X1695        .         
#> X1830        .         
#> X1832        .         
#> X1842        .         
#> X1847        .         
#> X1852        .         
#> X1880        .         
#> X1903        .         
#> X1909        .         
#> X1911        .         
#> X2086        .         
#> X2123        .         
#> X2137        .         
#> X2313        .         
#> X2558        .         
#> X2667        .         
#> X2702        .         
#> X2710        .         
#> X2727        .         
#> X2732        .         
#> X2799        .         
#> X2808        .         
#> X2860        .         
#> X2938        .         
#> X3143        .         
#> X3155        .         
#> X3164        .         
#> X3271        .         
#> X3275        .         
#> X3303        .         
#> X3343        .         
#> X3358        .         
#> X3427        .         
#> X3448        .         
#> X3520        .         
#> X3557        .         
#> X3591        .         
#> X3601        .         
#> X3665        .         
#> X3674        .         
#> X3726        .         
#> X3752        .         
#> X3765        .         
#> X3878        .         
#> X3960        .         
#> X3987        .         
#> X4011        .         
#> X4022        .         
#> X4128        .         
#> X4263        .         
#> X4271        .         
#> X4401        .         
#> X4422        .         
#> X4442        .         
#> X4529        .         
#> X4648        .         
#> X4712        .         
#> X4783        .         
#> X4793        .         
#> X4904        .         
#> X4929        .         
#> X4976        .         
#> X5016        .         
#> X5087        .         
#> X5100        .         
#> X5241        .         
#> X5362        .         
#> X5374        .         
#> X5419        .         
#> X5471        .         
#> X5485        .         
#> X5526        .         
#> X5527        .         
#> X5536        .         
#> X5588        .         
#> X5641        .         
#> X5653        .         
#> X5738        .         
#> X5744        .         
#> X5774        .         
#> X5779        .         
#> X5810        .         
#> X5816        .         
#> X5827        .         
#> X5865        .         
#> X5945        .         
#> X5970        .         
#> X6010        .         
#> X6039        .         
#> X6082        .         
#> X6085        .         
#> X6128        .         
#> X6231        .         
#> X6237        .         
#> X6259        .         
#> X6277        .         
#> X6294        .         
#> X6445        .         
#> X6503        .         
#> X6593        .         
#> X6621        .         
#> X6636        .         
#> X6656        .         
#> X6690        .         
#> X6717        .         
#> X6728        .         
#> X6737        .         
#> X6771        .         
#> X6786        .         
#> X6848        .         
#> X6849        .         
#> X6899        .         
#> X7032        .         
#> X7130        .         
#> X7136        .         
#> X7208        .         
#> X7326        .         
#> X7437        .         
#> X7459        .         
#> X7623        .         
#> X7650        .         
#> X7703        .         
#> X7755        .         
#> X7795        .         
#> X7824        .         
#> X7865        .         
#> X7935        .         
#> X8044        .         
#> X8141        .         
#> X8212        .         
#> X8221        .         
#> X8274        .         
#> X8444        .         
#> X8468        .         
#> X8494        .         
#> X8636        .         
#> X8721        .         
#> X8762        .         
#> X8806        .         
#> X8807        .         
#> X8860        .         
#> X8991        .         
#> X9173        .         
#> X9272        .         
#> X9417        .         
#> X9523        .         
#> X9544        .         
#> X9568        .         
#> X9590        .         
#> X9608        .         
#> X9648        .         
#> X9657        .         
#> X9732        .         
#> X9781        .         
#> X9841        .         
#> X9928        .         
#> X10172       .         
#> X10175       .         
#> X10186       .         
#> X336        -0.67986393
#> X7638        0.43403365
#> X1199        .         
#> X1536        0.93994982
#> X1968        .         
#> X1943        0.56600730
#> X2849       -0.58157979
#> X8087        .         
#> X56         -0.08244685
#> X4106       -0.35939830

We can also extract just the nonzero coefficients:

coef(hdbic, type = "nonzero")
#>                       1
#> (Intercept) -0.26684191
#> X336        -0.67986393
#> X7638        0.43403365
#> X1536        0.93994982
#> X1943        0.56600730
#> X2849       -0.58157979
#> X56         -0.08244685
#> X4106       -0.35939830
#> eta          0.26746240
#> sigma2       0.98694300

Finally we can also make predictions from the hdbic object, which by default will use the model corresponding to the optimal tuning parameter:

predict(hdbic, newx = admixed$x)
#>                  1
#> id1   -1.306104134
#> id2    0.299165393
#> id3   -2.345366361
#> id4   -0.448601166
#> id5   -1.389579250
#> id6    0.199852988
#> id7   -0.060232904
#> id8   -0.626240203
#> id9   -1.665502431
#> id10  -1.567218288
#> id11  -1.419960765
#> id12  -1.388550989
#> id13  -2.345366361
#> id14  -0.045688677
#> id15  -1.046018241
#> id16  -0.595119042
#> id17  -1.181941987
#> id18  -0.863994183
#> id19  -1.306104134
#> id20  -0.946705837
#> id21  -1.665502431
#> id22  -1.747949285
#> id23  -0.349288761
#> id24  -1.128465096
#> id25  -0.946705837
#> id26   0.199852988
#> id27  -2.345366361
#> id28  -0.985638500
#> id29  -1.626569767
#> id30  -0.971382889
#> id31  -1.528285625
#> id32   0.313709620
#> id33  -0.551604850
#> id34  -0.725552608
#> id35  -1.029152692
#> id36  -0.060232904
#> id37  -0.947734099
#> id38  -0.946705837
#> id39  -0.266841906
#> id40   0.573795512
#> id41  -1.665502431
#> id42  -1.487863393
#> id43  -2.247082218
#> id44   0.673107917
#> id45  -0.128135532
#> id46  -1.388550989
#> id47  -1.306104134
#> id48   0.673107917
#> id49  -0.097014371
#> id50  -0.740096835
#> id51  -0.045688677
#> id52  -1.046018241
#> id53  -0.045688677
#> id54  -0.807999463
#> id55   0.148815910
#> id56   0.117406133
#> id57  -0.274653408
#> id58  -0.252586295
#> id59  -0.626240203
#> id60  -1.887683921
#> id61   0.199852988
#> id62  -2.345366361
#> id63   0.231262765
#> id64  -1.681074919
#> id65  -1.665502431
#> id66  -0.626240203
#> id67  -1.388550989
#> id68  -0.708687058
#> id69  -0.985638500
#> id70  -0.465466715
#> id71   0.747743269
#> id72  -1.420989027
#> id73  -0.822543690
#> id74   0.199852988
#> id75  -1.985968064
#> id76   0.673107917
#> id77  -1.388550989
#> id78   0.505774395
#> id79  -0.962278326
#> id80  -0.626240203
#> id81  -1.231468781
#> id82  -0.448601166
#> id83  -2.345366361
#> id84  -0.725552608
#> id85  -0.349288761
#> id86  -0.060232904
#> id87  -1.388550989
#> id88  -1.747949285
#> id89  -0.740096835
#> id90  -1.307132395
#> id91   0.388344973
#> id92  -1.313915636
#> id93  -0.045688677
#> id94  -0.626240203
#> id95  -1.306104134
#> id96  -0.807999463
#> id97  -0.448601166
#> id98  -0.641812692
#> id99  -0.725552608
#> id100 -0.626240203
#> id101 -1.665502431
#> id102  0.476804430
#> id103 -0.266841906
#> id104  0.879716919
#> id105  0.185308761
#> id106 -0.373965813
#> id107 -1.306104134
#> id108 -0.947734099
#> id109 -0.274653408
#> id110 -0.709715320
#> id111 -0.611984592
#> id112 -0.626240203
#> id113 -1.626569767
#> id114 -1.779359062
#> id115 -3.009393004
#> id116 -1.046018241
#> id117 -0.641812692
#> id118 -0.006756014
#> id119 -0.822543690
#> id120 -0.350317023
#> id121 -0.241992164
#> id122 -0.709715320
#> id123 -0.708687058
#> id124 -0.985638500
#> id125  0.372772484
#> id126 -0.588335802
#> id127 -0.159545309
#> id128 -0.419631201
#> id129 -0.159545309
#> id130 -1.665502431
#> id131 -1.207819991
#> id132 -0.588335802
#> id133 -0.904990544
#> id134  0.223451263
#> id135 -1.306104134
#> id136 -0.373965813
#> id137 -0.985638500
#> id138 -2.345366361
#> id139 -1.779359062
#> id140 -0.551604850
#> id141 -0.947734099
#> id142  0.199852988
#> id143 -1.813048569
#> id144 -0.725552608
#> id145 -0.068044406
#> id146  0.313709620
#> id147  0.231262765
#> id148 -1.791463477
#> id149  1.139802811
#> id150 -1.388550989
#> id151  0.879716919
#> id152 -1.306104134
#> id153  1.274529289
#> id154  1.231303714
#> id155 -1.207819991
#> id156 -0.192206554
#> id157 -1.231468781
#> id158 -1.634381270
#> id159 -0.060232904
#> id160 -1.830396140
#> id161 -0.807999463
#> id162 -0.266841906
#> id163 -1.618543981
#> id164 -0.694431447
#> id165  0.313709620
#> id166 -0.791133913
#> id167  0.231262765
#> id168 -0.708687058
#> id169 -1.405416538
#> id170 -0.985638500
#> id171 -1.405416538
#> id172 -2.551710564
#> id173  0.313709620
#> id174 -0.807999463
#> id175 -0.551604850
#> id176 -0.626240203
#> id177 -0.142679759
#> id178  0.214397215
#> id179 -0.872070484
#> id180 -0.306063185
#> id181 -0.422199546
#> id182  0.747743269
#> id183 -0.708687058
#> id184 -1.404123477
#> id185 -0.128135532
#> id186 -1.207819991
#> id187 -1.030180953
#> id188 -0.159545309
#> id189  0.231262765
#> id190 -1.306104134
#> id191 -0.373965813
#> id192  0.245518376
#> id193 -0.128135532
#> id194 -0.291518958
#> id195 -0.773786341
#> id196 -0.716498560
#> id197 -1.313915636
#> id198  0.388056357
#> id199 -0.725552608
#> id200 -2.649994707
#> id201 -0.626240203
#> id202 -0.502078056
#> id203 -0.099454183
#> id204 -1.970130776
#> id205 -0.551893466
#> id206 -0.366154311
#> id207  0.437871767
#> id208 -0.366154311
#> id209 -0.366154311
#> id210 -0.954517339
#> id211  0.819337177
#> id212  0.298137131
#> id213 -1.405416538
#> id214 -0.192206554
#> id215 -0.512672187
#> id216 -0.740096835
#> id217  0.807834395
#> id218 -1.665502431
#> id219  0.313709620
#> id220  1.239115216
#> id221 -0.872070484
#> id222 -0.634051705
#> id223 -1.046018241
#> id224 -0.985638500
#> id225  0.811814291
#> id226 -1.307132395
#> id227  0.091528129
#> id228 -1.665502431
#> id229  0.747743269
#> id230 -0.626240203
#> id231 -0.192206554
#> id232  0.231262765
#> id233  0.673107917
#> id234  2.047091389
#> id235 -0.060232904
#> id236 -1.747949285
#> id237  0.313709620
#> id238 -0.366154311
#> id239  0.199852988
#> id240 -0.089202869
#> id241 -0.241992164
#> id242 -0.006756014
#> id243 -0.192206554
#> id244  0.520318622
#> id245 -0.596147304
#> id246  0.879716919
#> id247  0.313709620
#> id248  0.241827096
#> id249  1.107141566
#> id250 -1.665502431
#> id251 -0.366154311
#> id252 -0.872070484
#> id253 -1.030180953
#> id254  0.373800745
#> id255 -0.626240203
#> id256 -0.266841906
#> id257  0.879716919
#> id258 -1.207819991
#> id259 -0.274653408
#> id260 -1.068085355
#> id261  0.747743269
#> id262 -0.627268465
#> id263 -0.192206554
#> id264  2.047091389
#> id265  0.903026578
#> id266 -0.274653408
#> id267  1.107141566
#> id268  1.253659443
#> id269 -1.094251975
#> id270 -0.291518958
#> id271 -1.068085355
#> id272  0.067879339
#> id273 -0.381726800
#> id274  0.780404514
#> id275 -0.366154311
#> id276 -0.848421694
#> id277  0.313709620
#> id278 -1.970130776
#> id279  0.313709620
#> id280 -0.045688677
#> id281  0.732170781
#> id282  0.313709620
#> id283 -0.930868549
#> id284  0.313709620
#> id285  0.879716919
#> id286  0.305898118
#> id287 -0.291518958
#> id288  1.328294795
#> id289 -0.963306587
#> id290  0.274488341
#> id291  0.406461990
#> id292  1.879757867
#> id293  1.171212588
#> id294  1.106113305
#> id295 -1.567218288
#> id296 -0.725552608
#> id297  1.819666742
#> id298 -0.512672187
#> id299 -1.665502431
#> id300 -0.128135532
#> id301 -0.709715320
#> id302 -0.192206554
#> id303  0.780404514
#> id304 -0.006756014
#> id305  0.291353891
#> id306 -0.985638500
#> id307 -1.150532210
#> id308 -0.626240203
#> id309 -0.045688677
#> id310 -0.283442657
#> id311 -0.626240203
#> id312  1.202333749
#> id313  0.313709620
#> id314  0.313709620
#> id315 -0.708687058
#> id316 -1.306104134
#> id317  0.879716919
#> id318  0.778864431
#> id319 -0.414388044
#> id320  1.024694712
#> id321  0.673107917
#> id322 -2.150861774
#> id323  1.253659443
#> id324  0.067879339
#> id325 -0.045688677
#> id326  0.091528129
#> id327 -0.267870168
#> id328  0.404921906
#> id329 -0.725552608
#> id330  0.747743269
#> id331  0.933193809
#> id332 -0.985638500
#> id333  0.697957659
#> id334 -1.133184638
#> id335  0.520318622
#> id336  0.746715008
#> id337 -0.626240203
#> id338  0.167191743
#> id339  0.083716627
#> id340 -0.686619945
#> id341  0.388344973
#> id342 -0.266841906
#> id343 -0.089202869
#> id344 -0.985638500
#> id345  0.672079655
#> id346 -1.192536118
#> id347 -1.181941987
#> id348  1.441862811
#> id349  0.313709620
#> id350 -0.725552608
#> id351  1.253659443
#> id352  0.052306850
#> id353 -1.306104134
#> id354 -1.567218288
#> id355  0.672079655
#> id356 -0.626240203
#> id357  0.313709620
#> id358  1.253659443
#> id359  1.613057740
#> id360 -1.887683921
#> id361 -0.366154311
#> id362 -1.888712183
#> id363 -0.267870168
#> id364 -1.290266846
#> id365 -0.725552608
#> id366  1.155640099
#> id367 -0.985638500
#> id368 -0.060232904
#> id369  0.351614021
#> id370  0.166163482
#> id371 -1.207819991
#> id372 -0.725552608
#> id373 -1.887683921
#> id374 -0.627268465
#> id375  0.066851077
#> id376 -0.985638500
#> id377 -1.307132395
#> id378 -0.045688677
#> id379  0.091528129
#> id380 -1.887683921
#> id381  0.091528129
#> id382 -0.725552608
#> id383 -0.045688677
#> id384 -0.193234815
#> id385 -0.045688677
#> id386 -0.627268465
#> id387 -1.207819991
#> id388 -0.061261166
#> id389  0.427277636
#> id390  1.819666742
#> id391 -0.192206554
#> id392  0.214397215
#> id393  0.313709620
#> id394  0.573795512
#> id395 -0.366154311
#> id396  1.125258584
#> id397  1.460268445
#> id398  0.672079655
#> id399 -1.099495132
#> id400 -0.490051659
#> id401 -0.849449956
#> id402  0.313709620
#> id403 -1.231468781
#> id404  0.313709620
#> id405 -0.849449956
#> id406 -0.045688677
#> id407 -0.985638500
#> id408 -1.389579250
#> id409  0.672079655
#> id410 -0.627268465
#> id411 -0.985638500
#> id412 -0.947734099
#> id413 -0.725552608
#> id414 -0.627268465
#> id415  0.067879339
#> id416  0.313709620
#> id417  0.672079655
#> id418 -0.626240203
#> id419 -1.665502431
#> id420 -1.207819991
#> id421 -0.627268465
#> id422 -1.208848252
#> id423 -0.007784276
#> id424 -1.207819991
#> id425  0.819337177
#> id426 -1.887683921
#> id427 -2.247082218
#> id428 -0.267870168
#> id429 -1.307132395
#> id430 -0.627268465
#> id431 -0.725552608
#> id432 -1.306104134
#> id433 -1.047046503
#> id434 -1.649665142
#> id435 -2.394628357
#> id436 -0.381726800
#> id437 -0.665461482
#> id438 -1.208848252
#> id439 -0.985638500
#> id440 -0.006756014
#> id441  0.559251285
#> id442 -0.117571201
#> id443 -0.159545309
#> id444 -0.551604850
#> id445 -1.567218288
#> id446 -0.366154311
#> id447 -1.231468781
#> id448  0.520318622
#> id449 -1.307132395
#> id450 -1.665502431
#> id451 -0.045688677
#> id452 -0.193234815
#> id453 -0.588335802
#> id454  0.313709620
#> id455 -0.725552608
#> id456 -1.307132395
#> id457 -1.582790776
#> id458 -1.207819991
#> id459  1.687693092
#> id460 -1.887683921
#> id461 -0.366154311
#> id462 -0.985638500
#> id463 -1.665502431
#> id464  0.214397215
#> id465 -0.627268465
#> id466 -0.626240203
#> id467 -1.665502431
#> id468  0.313709620
#> id469 -1.567218288
#> id470 -2.247082218
#> id471 -0.985638500
#> id472 -2.148798075
#> id473  0.312681358
#> id474 -0.513700449
#> id475 -1.307132395
#> id476 -1.887683921
#> id477 -0.849449956
#> id478 -0.725552608
#> id479 -0.626240203
#> id480  0.313709620
#> id481  0.372772484
#> id482  0.573795512
#> id483 -0.985638500
#> id484 -2.567547852
#> id485 -0.626240203
#> id486 -0.366154311
#> id487  0.214397215
#> id488 -1.627598029
#> id489 -1.986996326
#> id490 -1.887683921
#> id491 -0.985638500
#> id492 -1.665502431
#> id493 -2.926946149
#> id494  1.015905463
#> id495 -0.872070484
#> id496 -2.469263709
#> id497 -1.567218288
#> id498 -0.627268465
#> id499 -0.366154311
#> id500 -0.947734099

Diagnostic Plots

We can also plot some standard diagnotic plots such as the observed vs. predicted response, QQ-plots of the residuals and random effects and the Tukey-Anscombe plot. These can be plotted using the plot method on a ggmix_gic object as shown below.

Observed vs. Predicted Response

plot(hdbic, type = "predicted", newx = admixed$x, newy = admixed$y)

QQ-plots for Residuals and Random Effects

plot(hdbic, type = "QQranef", newx = admixed$x, newy = admixed$y)

plot(hdbic, type = "QQresid", newx = admixed$x, newy = admixed$y)

Tukey-Anscombe Plot

plot(hdbic, type = "Tukey", newx = admixed$x, newy = admixed$y)