# Overview of Mixed Linear Models¶

Mixed linear models incorporate both “fixed effects” and “random effects” (that is, “mixed effects”). The independent variables in a linear regression may be thought of as fixed effects. To solve for the random effects in a mixed model, something should be known about the variances and covariances of these random effects.

## The Mixed Model Equation¶

Suppose there are measurements of a phenotype which is influenced by fixed effects and instances of one random effect. The mixed linear model may be written as

where is an vector of observed phenotypes, is an matrix of fixed effects, and is a vector representing the coefficients of the fixed effects. is an matrix relating the instances of the random effect to the phenotypes. We assume

and

so that

Examples of “fixed effects” may include the mean, one or more genotypic markers, and other additional covariates that may be analyzed.

Examples of a “random effect” are:

- Polygenic effects from each of subgroupings, where the measurements have been grouped into subgroupings such as inbred strains. is then an incidence matrix relating subgroupings/strains to measurements, and should be a matrix showing the pairwise genetic relationship among the strains.
- Polygenic effects from each of the samples, where there is just one measurement per sample. is then just the identity matrix , and should be a pairwise genetic relationship or kinship matrix among the samples.

Note

At this time, neither of the SVS Mixed Linear Model Analysis tools supports organizing measurements into subgroupings such as inbred strains.

The parameters and are called the “variance components”, and are assumed to be unknown. To solve the mixed model equation, the variance components must first be estimated. Once this is done, a generalized least squares (GLS) procedure may be used to estimate .

## Finding the Variance Components¶

The SVS Mixed Linear Model Analysis tools use an approach called EMMA (Efficient Mixed-Model Association) [Kang2008] to directly estimate the variance components and , reducing the problem to a maximization search in just one dimension.

Either the full likelihood or the restricted likelihood may be maximized. The restricted likelihood is defined as the full likelihood with the fixed effects integrated out. As stated in [Kang2008], “The restricted likelihood avoids a downward bias of maximum-likelihood estimates of variance components by taking into account the loss in degrees of freedom associated with fixed effects.”

Note

The SVS Mixed Linear Model Analysis tools always maximize the restricted likelihood rather than the full likelihood except when the Bayes Information Criterion (for the MLMM feature) is computed.

Suppose , , and , which is a function of . Under the null hypothesis, the full log-likelihood function can be formulated as

and the restricted log-likelihood function can be formulated as

The full-likelihood function is maximized when is , and the optimal variance component is for full likelihood and for restricted likelihood, where is a function of as well.

Using spectral decomposition, it is possible to find and such that

and

where , is , and is an eigenvector matrix corresponding to the nonzero eigenvalues. is an matrix corresponding to the zero eigenvalues. and are independent of .

Let . Then, finding the maximum-likelihood (ML) estimate is equivalent to optimizing

with respect to , and finding the restricted maximum-likelihood (REML) estimate is equivalent to optimizing

with respect to . (See the Appendix of [Kang2008] for the mathematical details, except that , not “” as that Appendix states.) These functions are continuous for if and only if all the eigenvalues are nonnegative (and, for , the eigenvalues are nonnegative). Otherwise, if the kinship matrix is not positive semidefinite, the likelihood will be ill-defined for a certain range of .

The derivatives of these functions, which may be used to find the local maxima for the functions themselves, are

and

The ML or REML may be searched for by subdividing the values of into 100 intervals, evenly in log space from to , and applying a method such as the Newton-Raphson algorithm or the secant method on or to all the intervals where the sign of the derivative function changes, then taking the optimal among all the stationary points and endpoints.

Note

The secant method is used by the SVS Mixed Linear Model Analysis tools.

Notice that evaluating or does not require a large number of matrix multiplications or inverses at each iteration as other methods typically do – instead, the EMMA technique computes spectral decomposition only once. Thus, using the grid search indicated above, the likelihood may be optimized globally with high confidence using much less computation.

## Estimating the Variance of Heritability¶

The formula for the estimate of the variance of heritability is derived as follows using a Taylor series expansion:

Now, using the fact that the pseudo-heritability (or narrow-sense heritability) is:

We can obtain the formula for the estimate of the variance of heritability:

Note that

So:

The formulas and methods for calculating the variance components can be found in
*Finding the Variance Components*. is
the covariance between the estimated random effect components and
; and
so .

## Solving the Mixed Model Equation¶

The generalized least squares (GLS) solution to

may now be obtained. Note that the variance of is

If we can find a matrix such that

we can substitute , , and to get

(The Cholesky decomposition of is one way to obtain such a matrix .) This equation can be solved for through ordinary least squares (OLS), because we have

The value of the residual sum of squares (RSS) from solving the transformed equation is the Mahalanobis RSS for the original equation .

Taking advantage of the eigendecomposition of performed in the EMMA algorithm, the computation of a valid can be simplified to

## Using the Mixed Model for Association Studies¶

### The Exact Model¶

Association studies are typically carried out by testing the hypothesis for each of loci, one at a time, on the basis of the model

where is the minor allele count of marker for individual , is a (fixed) effect size of marker , and are other fixed effects such as the mean of the and any fixed covariates. The error term is

If we assume the individuals are unrelated and there is no dependence across the genotypes, the values will be independently and identically distributed (i.i.d.), and thus simple linear regressions will make appropriate inferences for the values of .

However, the variance of the first term of actually comes closer to being proportional to a matrix of the relatedness or kinship between samples. Thus, if we write

we see that the equation for reduces to the mixed-model equation

Note that strictly speaking, to use this equation, we should base not only the kinship, but also the variance components, upon all markers except for marker .

### The EMMAX Approximations and Technique¶

Even using the EMMA technique, finding the kinship matrix for, variance components for and solving for for all would be a daunting task. However, we may make two approximations:

Let

approximate , and let

approximate . Then, we have

To solve this, we need to compute the kinship matrix just once, using all markers. That kinship matrix may then be used to solve this equation for every marker .

Find the variance components once – specifically, for the system of equations

using the kinship matrix which is computed just once for all markers . Then, use these variance components (for the variance of the which is ) and (for the variance of the which is ) to apply the GLS method for solving

for for every marker .

This technique, which is called EMMAX (EMMA eXpedited) and was published in [Kang2010], allows mixed models to be used for genome-wide association testing within a very reasonable amount of computing time.

### Normalizing the Kinship Matrix¶

The actual EMMAX technique, however, before using the kinship matrix , scales it (and thus effectively scales ) by an amount that will make the expectation of the estimated population variance of the (scaled) to be , just as the expectation of the estimated population variance for the is .

This is done by defining a scaling factor as

and dividing by it to get

Here, and is a length vector of ones. is called a “Gower’s centering matrix”–it has the property that when you apply it to a vector to get , it will subtract the mean of the components of from each component of :

The reasoning for using this scaling factor is as follows:

Suppose we have a vector of elements . Estimate the population variance of these elements over all the samples . (This estimate is sometimes called the “sample variance”.) The (unbiased) estimate would be

where is the average of the components of .

However, another way to write this is

since

and

Two other ways to write this are

since is a scalar, and

since for any two matrices and .

We note that

therefore, the estimated population variance may be written as

Looking at as a random variable of dimensions and as a scalar random variable, let us write the expectation of the estimated population variance as:

But defines a relationship matrix among the elements of possible . (Note that the possible instances of themselves might not be “centered” – that is, the components of the may or may not have zero averages.) We now write the expected estimated population variance as

We wish to “normalize to one” – that is, set to one by normalizing appropriately. We do that by defining , where

and noting that

Note that this means that the found in the mixed-model equation that uses the normalized will relate to the in the original equation as .

### Further Optimization When Covariates Are Present¶

The following technique is mentioned in passing in [Segura2012] and is used both in [Vilhjalmsson2012] and in the mixed-model tools of SVS.

If we have a mixed linear model with fixed-effect covariates , one particular “more interesting” fixed-effect covariate and a random-effect covariate for which the normalized relationship matrix is

and we have this model for many and we don’t need to find
the covariate coefficients for any of these
models, and we have a matrix such that (see *Solving the Mixed Model Equation*), we can perform the
following optimization:

Solve the ordinary-least-squares (OLS) “null hypothesis” or reduced-model problem

to find as an estimate for .

Designate the (Mahalanobis) RSS obtained from solving this equation as

Perform the QR algorithm on to get

where and are the “thin”, “reduced”, or “economic” versions of and .

Define

giving us

Transform the original equation by pre-multiplying it by to get

But

because the columns of are “orthogonal” and of “unit length” and so and . Thus, we have

may be re-written as

because and .

Thus,

This is equivalent to the ordinary-least-squares (OLS) problem

where the variance of is proportional to . This is because if we pre-multiply the original problem simply by , we get

which may be solved as an OLS (

*Solving the Mixed Model Equation*), and becausewhich is proportional to .

The ordinary-least-squares (OLS) problem

may now be solved for all .

Note

For optimization, SVS pre-computes the matrix product and uses this product as one matrix to help perform all of the regressions involving .

Note

The matrix is the “annihilator matrix” for the null hypothesis problem

Designate the Mahalanobis Root Sum of Squares (Mahalanobis RSS) for marker as

which is optimized to

This is the Root Sum of Squares (RSS) value for the regression as transformed by pre-multiplying it by .

Note

If we have a (completely fixed-effect) linear model with covariates and one particular “more interesting” covariate ,

and we have this model for many and we don’t need to find the covariate coefficients for any of these models, we can perform the same kind of optimization.

Solve the ordinary-least-squares (OLS) “null hypothesis” or reduced-model problem

to find as an estimate for .

Perform the QR algorithm on to get

where and are the “thin”, “reduced”, or “economic” versions of and .

Define

Transform the original equation by pre-multiplying it by to get

But

because the columns of are “orthogonal” and of “unit length” and so and . Thus, we have

may be re-written as

because and .

Thus,

This is equivalent to the ordinary-least-squares (OLS) problem

where the variance of is proportional to . This is because

which we assume to be proportional to .

Note that the matrix is the “annihilator matrix” for the null hypothesis problem

### Optimization when Gene-Environment Interaction Terms Are Included¶

If we have the full mixed linear model

and we have

as the corresponding reduced mixed linear model, where are
fixed covariates, are fixed terms that will later be used
to create gene-environment interaction terms, is the
current “more interesting” covariate or predictor variable, and
are interaction terms created by multiplying the
element-by-element with , and it *is* desired
to determine all of the full-model beta’s, we must compute the entire
linear full-model regression

where the term is assumed
to be an error term proportional to the identity matrix, to obtain
these beta terms, even while we may still optimize computing the
reduced-model (Mahalanobis) RSS using the technique shown above in
*Further Optimization When Covariates Are Present*, where Step 1 consists of solving the “further-reduced” model

Note

For the similar linear-model problem with full model

and reduced model

where it *is* desired to determine all of the full-model beta’s, we
must compute the entire full-model regression itself. However, we
may still optimize computing the reduced-model RSS using the
technique shown above in the linear-model note to
*Further Optimization When Covariates Are Present*, where Step 1 consists of solving the
“further-reduced” model

## The Multi-Locus Mixed Model (MLMM)¶

For complex traits controlled by several large-effect loci, a single-locus test may not be appropriate, especially in the presence of population structure.

Therefore, [Segura2012] has proposed a simple stepwise mixed-model regression with forward inclusion and backward elimination of genotypic markers as fixed effect covariates. This method, called the Multi-Locus Mixed Model (MLMM), proceeds as follows:

- Begin with an initial model that includes, as its fixed effects, only the intercept and any additional covariates you may have specified.
- Using this model, perform an EMMAX scan through all markers (that you have not specified as additional covariates).
- From the markers scanned above, select the most significant marker and add it to the model as a fixed effect, creating a new model.
- Repeat (2) and (3) (forward inclusion) until either the pseudo-heritability estimate is close to zero or a pre-specified maximum number of forward steps is reached.
- For each selected marker in the current model, temporarily remove it from the fixed effects and perform an EMMAX scan over only that marker.
- Eliminate, from the current model, the marker that came out as least significant using the above test. A new smaller model is created.
- Repeat (5) and (6) (backward elimination) until only one selected marker is left.

The variance components are re-estimated between each forward and backward step, while the same kinship matrix is used throughout the calculations.

### Model Criteria¶

The result of this stepwise regression is a series of models. Several model criteria have been explored by the authors of [Segura2012] for how appropriate any of the models are:

Bayes Information Criteria (BIC). This is calculated as , where is the full-model log-likelihood, is the number of model parameters (one for the intercept, one for , one for each marker covariate used in the particular MLMM model, and finally one for each additional covariate used in all of the models), and is the sample size/number of individuals.

Given any two estimated models, the model with the lower value of BIC is the preferred choice.

However, the authors of [Segura2012] believe this model is “too tolerant in the context of GWAS”.

Extended Bayes Information Criteria (Extended BIC). This is the BIC penalized by the model space dimension. Its formula is

where is the initial number of model parameters (one for the intercept, one for , and one for each additional covariate used in all of the models), and is the total number of models which can be formed using marker covariates under the assumption that these will only be selected from the best markers.

Modified Bayes Information Criteria (Modified BIC). This adds a different penalty based not only by the model space dimension, but also by how many overall markers there are to test. Its formula is

where is the total number of markers being tested in the current step.

Bonferroni Criterion. Only defined for models derived from forward selection, this selects the model with the most covariate marker loci for which the best p-value obtained from the preceding EMMAX scan was below the Bonferroni threshold.

Multiple Bonferroni Criterion. This selects the model with the most covariate marker loci all of which have individual p-values below the Bonferroni threshold. Here, “individual p-value” is as explained in the note of

*Outputs from the Multi-Locus Mixed Linear Model (MLMM) Method*. The threshold used is , where is the total number of markers being tested in the current step.Multiple Posterior Probability of Association. This selects the model with the most covariate marker loci all of which have posterior probabilities of association above a PPA threshold. The threshold used is 0.5 . Posterior probabilities of association are based on Bayesian priors of for every marker (and for every step), where is the total number of markers being tested in the current step, and are computed as follows:

Find the Bayes factor for marker as

where and are the values of the Mahalanobis RSS for the base model and for testing with marker , respectively.

Determine the posterior odds and posterior probability as

and

## Genomic Best Linear Unbiased Predictors (GBLUP)¶

### Problem Statement¶

Suppose we have the mixed model equation

over samples, with fixed effects specified by that include the intercept and any additional covariates you may have specified. Also suppose that the random effects are additive genetic merits or genomic breeding values associated with these samples, and that these may be formulated from autosomal markers as

where is an matrix for which
is , , or
, depending upon whether the genotype for the
-th sample at the -th locus is homozygous for
the minor allele, heterozygous, or homozygous for the major allele,
respectively, and is a vector for which
is the allele substitution effect (ASE) for marker
. Here, and are the major and
minor allele frequencies for marker , respectively. (For
inclusion of non-autosomal markers, see *Correcting for Gender*.)

We further assume that (which makes ), and that , where is an (unknown) constant which is the component of variance associated with the ASE.

Our object is to estimate both the genomic breeding value for every sample and the ASE for every marker.

### The GBLUP Genomic Relationship Matrix¶

Under the above assumptions, we have

The sum of would-be variances over all the markers if each had been at Hardy-Weinberg equilibrium is

We can use this to define a normalized variance matrix

to get

where we let .

We can see that the matrix , which we shall call the GBLUP Genomic Relationship Matrix, may be used as a kinship matrix for solving this mixed-model equation, and that may be thought of as the variance component for .

Note

- Because this method uses a kinship matrix based on genotypes rather than on actual ancestry, the results are referred to as “Genomic Best Linear Unbiased Predictors” rather than just “Best Linear Unbiased Predictors”.
- Unlike the other SVS mixed-model analysis tools, SVS GBLUP does not normalize its kinship matrix.
- Because of how it is constructed, the GBLUP Genomic Relationship Matrix is a “centered matrix” and is (thus) singular. However, it is still a positive semidefinite matrix and will work well as a kinship matrix.

### Finding the Genomic Best Linear Unbiased Predictors and ASE¶

Using the EMMA technique (*Finding the Variance Components*), we can
find , , and The second of Henderson’s mixed-model equations, as modified to
accommodate singular , is

This may be rewritten as

This gives us

Noting the following equalities,

we may write

as a solution for the genomic BLUP. If we now define

we find that

which makes a solution for the ASE.

In SVS, this is computationally streamlined by finding

then computing and .

### Correcting for Gender¶

To correct for gender, we take the following steps:

For markers within the X chromosome, we use the following entries for matrix :

- For females, we use , , or for , depending upon whether the genotype for the -th sample at the -th locus is homozygous for the minor allele, heterozygous, or homozygous for the major allele, respectively.
- For males, we use or for , depending upon whether the genotype for the -th sample at the -th locus contains the minor (X-chromosome) allele or the major (X-chromosome) allele, respectively.

The other entries of are left the same.

Note

These frequencies and are computed individually for males and for females.

To compute , we continue to use as the expected-variance term for most markers. For X-chromosome markers, however, we use

where and are the fraction of the samples that are male and female, respectively.

Note

These are the frequencies that are computed invididually by gender.

We still compute

and

as before.

The ASE is computed separately for females and males, although the ASE will only be different between the genders for the X-chromosome markers.

Without loss of generality, we may consider the matrix to be partitioned into

where and are the male and female entries for the X chromosome and and are the male and female entries for the remaining chromosomes, and to be partitioned into

where and are the values of corresponding to male and female samples, respectively. We then compute

The final two results are then

### Normalizing the ASE¶

To normalize the allele substitution effects, each ASE is divided by the SNP Standard Deviation, which is the square root of the component of variance associated with the ASE. is reconstructed by dividing the additive genetic variance by the sum of would-be variances over all the markers if each had been at Hardy-Weinberg equilibrium:

The normalized ASE is then:

### Genomic Prediction¶

Sometimes, it is desired to predict the random effects (genomic merit/genomic breeding values) for samples for which there is genotypic data, but no phenotype data, based on other samples for which phenotype data (as well as genotypic and covariate data) does exist. (If there is covariate data for these missing phenotype values, these values can be predicted based on the random effect predictions.)

Call the samples for which there are phenotype values the “training set”, and the others the “validation set”. Assume all samples have genotypic data, imputed or otherwise, for all markers. Also assume all samples in the training set have valid covariate data, if there are covariates being used.

To predict the random effects and the missing phenotypes, we do the following:

Without loss of generality, imagine the samples of the training set all come first, before any samples of the validation set. Define , where the width and height of is , the width of the zero matrix is , and the height of the zero matrix is . Also partition , , and according to training vs. validation, as

and

Either compute the genomic relationship matrix or import a pre-computed genomic relationship matrix based on all samples (both training and validation sets).

Note

If correcting for gender has been selected, the modifications for computing and remain the same as noted above in

*Correcting for Gender*.Use the EMMA technique (

*Finding the Variance Components*) on the mixed model for the training set(where and ) to determine the proper values for , , and the inverse of , where .

Noting that the form of the second of Henderson’s mixed-model equations, as modified to accommodate singular , is, for ,

we obtain

or

Noting the following equalities,

We may write

as a solution for the genomic BLUP. If we now define

we find that

which makes a solution for the ASE. The computational streamlining becomes computing as

computing as

and finally computing and the ASE as before.

Note

If correcting for gender has been selected, the modifications for partitioning and (both of which involve all samples) and computing the ASE () remain the same as noted above in

*Correcting for Gender*.Finally, noting that the full mixed-model problem is

or

we predict the validation phenotypes

from (the intercept and) any validation covariates and the predicted values . If there are missing validation covariates, the corresponding validation phenotypes are not predicted.

## Bayes C and C-pi¶

### Problem Statement¶

Suppose that we have the following mixed model equation to describe the relationship between the phenotypes of our samples, their genotypes, and fixed and random effects.

over samples, with fixed effects in specified in that include the intercept and any additional covariates you may have specified. Also, the random effects, are additive genetic merits or genomic breeding values associated with each sample.

We can define in terms of the genotypes of each sample over autosomal markers and the allele substitution effects.

where is an x matrix containing the genotypes of each sample. is 0, 1, or 2, depending upon whether the genotype for the -th sample at the -th locus is homozygous for the major allele, heterozygous, or homozygous for the minor allele, respectively. is a vector for which is the allele substitution effect (ASE) for marker .

### Estimating the Model Parameters¶

The two Bayesian methods for fitting this mixed model implemented in SVS are Bayes C and Bayes C [Habier2011]. The only difference between the two methods is the assumptions about .

is the prior probability that a SNP has no effect on the phenotype, the value of is treated as unknown and is estimated in the Bayes C method and is treated as known with a value of 0.9 [Neves2012] in Bayes C.

The Bayesian approach uses prior probabilities, beliefs about the parameters before data is analyzed, and the conditional probabilities, a probability density for a parameter based on the given data, to construct full conditional posterior probabilities. These posterior probabilities are then sampled from to make estimates about the model parameters.

SVS uses a single-site Gibbs sampler.

### Prior and Posterior Distributions¶

There are six parameters that are sampled each iteration of the Gibbs sampler.

The parameters are:

- : the prior probability that a SNP has no effect.
- : the allele substitution effect (ASE) at loci .
- : the component of variance associated with the ASE.
- : the component of variance associated with the error term.
- : the component of the -th fixed effect.
- : whether a marker is included in the current iteration.

The prior distributions for the parameters are as follows [Fernando2009a], [Sorensen2002]:

Parameter |
Prior |
---|---|

Where is the number of iterations for the Gibbs sampler, , , [Fernando2009b] and is defined as [Habier2011]:

where is the initial value of and is defined as [Habier2011]:

where is:

or the sum of would-be variances over all the markers if each had been at Hardy-Weinberg equilibrium. And is the additive-genetic variance explained by SNPs [Habier2011] and we can set it as 0.05 [Fernando2009b].

The prior of is constant and not proper, however the posterior is. The initial value for the first is the mean of the phenotype values and the rest are set to 0.

The posterior distributions for these parameters are [Fernando2009a], [Sorensen2002]:

Parameter |
Posterior |
---|---|

where is the number of markers included in this iteration
(see *Deciding when to include a marker*) and is the scale factor for
the posterior distribution and it is set at 1. And
is [Habier2011]:

and is defined as [Habier2011]:

where is defined as above and is updated each iteration with the new value of .

Note

A prime in the subscript mean “all but this.” For example, when sampling we remove all the fixed effects and their coefficients except for the current one.

The posterior of can be better explained by [Fernando2009a]:

### Deciding when to include a marker¶

Because of the difficulty in sampling directly from the distribution we use the log-likelihoods, find the probability that is 1, and sample from a uniform distribution, , to determine if a marker will be included in the current iteration, if we do not include a marker, then will be set to 0.

The log-likelihoods are defined as [Fernando2009b]:

We can then define the probability that is 1 as [Fernando2009b]:

### Finding the ASE and Genomic Estimated Breeding Values¶

To find the our estimates for and we take the average over all iterations:

for all and .

The ASE values will then be the new values.

To find the genomic estimated breeding values (GEBV) we use the ASE values:

, , and are found in the same way as and , taking the average value over all iterations.

### Gender Correction¶

To correct for gender, we take the following steps:

For markers within the X chromosome, we use the following entries for matrix :

- For females, we encode them the same as non-X-chromosome markers.
- For males, we use 0 or 1 for , depending upon whether the genotype for the -th sample at the -th locus contains the major (X-chromosome) allele or the minor (X-chromosome) allele, respectively.

The other entries of are left the same.

To compute , we continue to use as the expected-variance term for most markers. For X-chromosome markers, however, we use

where and are the fraction of the samples that are male and female, respectively.

We still compute

as before.

During the sampling phase of the Gibbs sampler, the and matrices are split into male and female sections and separate samples are taken.

The non-X-Chromosome ASE values are added (from the males and females) to get the final ASE values.

### Standardizing Phenotype Values¶

Phenotype values will be standardized to prevent from becoming too large and disrupting the results.

Values will be set to their z-score:

The result spreadsheet by marker will have the original phenotypes and the standardized phenotypes, if phenotype prediction is chosen, then there will be a column of predicted phenotypes and transformed back predicted phenotypes.

### Genomic Prediction¶

To predict the phenotype of samples for which there is genotypic data but no phenotypic data (will be known as our validation set) we can run the Gibbs sampler with just the data from the samples with known phenotypic and genotypic data (the training set).

After running the Gibbs sampler with just the training set data we can estimate the GEBVs for all samples with:

where is estimated with just the training samples.

And we can predict the phenotypes for all samples (training and validation) with:

However, if there are missing covariate values the phenotypes cannot be predicted for the sample and it will be dropped from the result spreadsheet.