# getVarCov: Extract variance-covariance matrix In nlme: Linear and Nonlinear Mixed Effects Models

## Description

Extract the variance-covariance matrix from a fitted model, such as a mixed-effects model.

## Usage

 ```1 2 3 4 5 6``` ```getVarCov(obj, ...) ## S3 method for class 'lme' getVarCov(obj, individuals, type = c("random.effects", "conditional", "marginal"), ...) ## S3 method for class 'gls' getVarCov(obj, individual = 1, ...) ```

## Arguments

 `obj` A fitted model. Methods are available for models fit by `lme` and by `gls` `individuals` For models fit by `lme` a vector of levels of the grouping factor can be specified for the conditional or marginal variance-covariance matrices. `individual` For models fit by `gls` the only type of variance-covariance matrix provided is the marginal variance-covariance of the responses by group. The optional argument `individual` specifies the group of responses. `type` For models fit by `lme` the `type` argument specifies the type of variance-covariance matrix, either `"random.effects"` for the random-effects variance-covariance (the default), or `"conditional"` for the conditional. variance-covariance of the responses or `"marginal"` for the the marginal variance-covariance of the responses. `...` Optional arguments for some methods, as described above

## Value

A variance-covariance matrix or a list of variance-covariance matrices.

## Author(s)

Mary Lindstrom [email protected]

`lme`, `gls`

## Examples

 ```1 2 3 4 5 6 7``` ```fm1 <- lme(distance ~ age, data = Orthodont, subset = Sex == "Female") getVarCov(fm1) getVarCov(fm1, individual = "F01", type = "marginal") getVarCov(fm1, type = "conditional") fm2 <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), Ovary, correlation = corAR1(form = ~ 1 | Mare)) getVarCov(fm2) ```

### Example output

```Random effects variance covariance matrix
(Intercept)       age
(Intercept)     3.55020 -0.107490
age            -0.10749  0.025898
Standard Deviations: 1.8842 0.16093
Subject F01
Marginal variance covariance matrix
1      2      3      4
1 3.9344 3.6872 3.8866 4.0860
2 3.6872 4.4368 4.2931 4.5961
3 3.8866 4.2931 5.1463 5.1063
4 4.0860 4.5961 5.1063 6.0630
Standard Deviations: 1.9835 2.1064 2.2685 2.4623
Subject F01
Conditional variance covariance matrix
1       2       3       4
1 0.44659 0.00000 0.00000 0.00000
2 0.00000 0.44659 0.00000 0.00000
3 0.00000 0.00000 0.44659 0.00000
4 0.00000 0.00000 0.00000 0.44659
Standard Deviations: 0.66827 0.66827 0.66827 0.66827
Marginal variance covariance matrix
[,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]
[1,] 21.3090000 16.050000 12.089000  9.105600  6.858400  5.165800  3.890900
[2,] 16.0500000 21.309000 16.050000 12.089000  9.105600  6.858400  5.165800
[3,] 12.0890000 16.050000 21.309000 16.050000 12.089000  9.105600  6.858400
[4,]  9.1056000 12.089000 16.050000 21.309000 16.050000 12.089000  9.105600
[5,]  6.8584000  9.105600 12.089000 16.050000 21.309000 16.050000 12.089000
[6,]  5.1658000  6.858400  9.105600 12.089000 16.050000 21.309000 16.050000
[7,]  3.8909000  5.165800  6.858400  9.105600 12.089000 16.050000 21.309000
[8,]  2.9307000  3.890900  5.165800  6.858400  9.105600 12.089000 16.050000
[9,]  2.2074000  2.930700  3.890900  5.165800  6.858400  9.105600 12.089000
[10,]  1.6626000  2.207400  2.930700  3.890900  5.165800  6.858400  9.105600
[11,]  1.2523000  1.662600  2.207400  2.930700  3.890900  5.165800  6.858400
[12,]  0.9432500  1.252300  1.662600  2.207400  2.930700  3.890900  5.165800
[13,]  0.7104600  0.943250  1.252300  1.662600  2.207400  2.930700  3.890900
[14,]  0.5351300  0.710460  0.943250  1.252300  1.662600  2.207400  2.930700
[15,]  0.4030600  0.535130  0.710460  0.943250  1.252300  1.662600  2.207400
[16,]  0.3035900  0.403060  0.535130  0.710460  0.943250  1.252300  1.662600
[17,]  0.2286700  0.303590  0.403060  0.535130  0.710460  0.943250  1.252300
[18,]  0.1722300  0.228670  0.303590  0.403060  0.535130  0.710460  0.943250
[19,]  0.1297300  0.172230  0.228670  0.303590  0.403060  0.535130  0.710460
[20,]  0.0977120  0.129730  0.172230  0.228670  0.303590  0.403060  0.535130
[21,]  0.0735970  0.097712  0.129730  0.172230  0.228670  0.303590  0.403060
[22,]  0.0554340  0.073597  0.097712  0.129730  0.172230  0.228670  0.303590
[23,]  0.0417530  0.055434  0.073597  0.097712  0.129730  0.172230  0.228670
[24,]  0.0314490  0.041753  0.055434  0.073597  0.097712  0.129730  0.172230
[25,]  0.0236880  0.031449  0.041753  0.055434  0.073597  0.097712  0.129730
[26,]  0.0178420  0.023688  0.031449  0.041753  0.055434  0.073597  0.097712
[27,]  0.0134380  0.017842  0.023688  0.031449  0.041753  0.055434  0.073597
[28,]  0.0101220  0.013438  0.017842  0.023688  0.031449  0.041753  0.055434
[29,]  0.0076239  0.010122  0.013438  0.017842  0.023688  0.031449  0.041753
[,8]      [,9]     [,10]    [,11]    [,12]    [,13]    [,14]
[1,]  2.930700  2.207400  1.662600  1.25230  0.94325  0.71046  0.53513
[2,]  3.890900  2.930700  2.207400  1.66260  1.25230  0.94325  0.71046
[3,]  5.165800  3.890900  2.930700  2.20740  1.66260  1.25230  0.94325
[4,]  6.858400  5.165800  3.890900  2.93070  2.20740  1.66260  1.25230
[5,]  9.105600  6.858400  5.165800  3.89090  2.93070  2.20740  1.66260
[6,] 12.089000  9.105600  6.858400  5.16580  3.89090  2.93070  2.20740
[7,] 16.050000 12.089000  9.105600  6.85840  5.16580  3.89090  2.93070
[8,] 21.309000 16.050000 12.089000  9.10560  6.85840  5.16580  3.89090
[9,] 16.050000 21.309000 16.050000 12.08900  9.10560  6.85840  5.16580
[10,] 12.089000 16.050000 21.309000 16.05000 12.08900  9.10560  6.85840
[11,]  9.105600 12.089000 16.050000 21.30900 16.05000 12.08900  9.10560
[12,]  6.858400  9.105600 12.089000 16.05000 21.30900 16.05000 12.08900
[13,]  5.165800  6.858400  9.105600 12.08900 16.05000 21.30900 16.05000
[14,]  3.890900  5.165800  6.858400  9.10560 12.08900 16.05000 21.30900
[15,]  2.930700  3.890900  5.165800  6.85840  9.10560 12.08900 16.05000
[16,]  2.207400  2.930700  3.890900  5.16580  6.85840  9.10560 12.08900
[17,]  1.662600  2.207400  2.930700  3.89090  5.16580  6.85840  9.10560
[18,]  1.252300  1.662600  2.207400  2.93070  3.89090  5.16580  6.85840
[19,]  0.943250  1.252300  1.662600  2.20740  2.93070  3.89090  5.16580
[20,]  0.710460  0.943250  1.252300  1.66260  2.20740  2.93070  3.89090
[21,]  0.535130  0.710460  0.943250  1.25230  1.66260  2.20740  2.93070
[22,]  0.403060  0.535130  0.710460  0.94325  1.25230  1.66260  2.20740
[23,]  0.303590  0.403060  0.535130  0.71046  0.94325  1.25230  1.66260
[24,]  0.228670  0.303590  0.403060  0.53513  0.71046  0.94325  1.25230
[25,]  0.172230  0.228670  0.303590  0.40306  0.53513  0.71046  0.94325
[26,]  0.129730  0.172230  0.228670  0.30359  0.40306  0.53513  0.71046
[27,]  0.097712  0.129730  0.172230  0.22867  0.30359  0.40306  0.53513
[28,]  0.073597  0.097712  0.129730  0.17223  0.22867  0.30359  0.40306
[29,]  0.055434  0.073597  0.097712  0.12973  0.17223  0.22867  0.30359
[,15]    [,16]    [,17]    [,18]    [,19]     [,20]     [,21]
[1,]  0.40306  0.30359  0.22867  0.17223  0.12973  0.097712  0.073597
[2,]  0.53513  0.40306  0.30359  0.22867  0.17223  0.129730  0.097712
[3,]  0.71046  0.53513  0.40306  0.30359  0.22867  0.172230  0.129730
[4,]  0.94325  0.71046  0.53513  0.40306  0.30359  0.228670  0.172230
[5,]  1.25230  0.94325  0.71046  0.53513  0.40306  0.303590  0.228670
[6,]  1.66260  1.25230  0.94325  0.71046  0.53513  0.403060  0.303590
[7,]  2.20740  1.66260  1.25230  0.94325  0.71046  0.535130  0.403060
[8,]  2.93070  2.20740  1.66260  1.25230  0.94325  0.710460  0.535130
[9,]  3.89090  2.93070  2.20740  1.66260  1.25230  0.943250  0.710460
[10,]  5.16580  3.89090  2.93070  2.20740  1.66260  1.252300  0.943250
[11,]  6.85840  5.16580  3.89090  2.93070  2.20740  1.662600  1.252300
[12,]  9.10560  6.85840  5.16580  3.89090  2.93070  2.207400  1.662600
[13,] 12.08900  9.10560  6.85840  5.16580  3.89090  2.930700  2.207400
[14,] 16.05000 12.08900  9.10560  6.85840  5.16580  3.890900  2.930700
[15,] 21.30900 16.05000 12.08900  9.10560  6.85840  5.165800  3.890900
[16,] 16.05000 21.30900 16.05000 12.08900  9.10560  6.858400  5.165800
[17,] 12.08900 16.05000 21.30900 16.05000 12.08900  9.105600  6.858400
[18,]  9.10560 12.08900 16.05000 21.30900 16.05000 12.089000  9.105600
[19,]  6.85840  9.10560 12.08900 16.05000 21.30900 16.050000 12.089000
[20,]  5.16580  6.85840  9.10560 12.08900 16.05000 21.309000 16.050000
[21,]  3.89090  5.16580  6.85840  9.10560 12.08900 16.050000 21.309000
[22,]  2.93070  3.89090  5.16580  6.85840  9.10560 12.089000 16.050000
[23,]  2.20740  2.93070  3.89090  5.16580  6.85840  9.105600 12.089000
[24,]  1.66260  2.20740  2.93070  3.89090  5.16580  6.858400  9.105600
[25,]  1.25230  1.66260  2.20740  2.93070  3.89090  5.165800  6.858400
[26,]  0.94325  1.25230  1.66260  2.20740  2.93070  3.890900  5.165800
[27,]  0.71046  0.94325  1.25230  1.66260  2.20740  2.930700  3.890900
[28,]  0.53513  0.71046  0.94325  1.25230  1.66260  2.207400  2.930700
[29,]  0.40306  0.53513  0.71046  0.94325  1.25230  1.662600  2.207400
[,22]     [,23]     [,24]     [,25]     [,26]     [,27]     [,28]
[1,]  0.055434  0.041753  0.031449  0.023688  0.017842  0.013438  0.010122
[2,]  0.073597  0.055434  0.041753  0.031449  0.023688  0.017842  0.013438
[3,]  0.097712  0.073597  0.055434  0.041753  0.031449  0.023688  0.017842
[4,]  0.129730  0.097712  0.073597  0.055434  0.041753  0.031449  0.023688
[5,]  0.172230  0.129730  0.097712  0.073597  0.055434  0.041753  0.031449
[6,]  0.228670  0.172230  0.129730  0.097712  0.073597  0.055434  0.041753
[7,]  0.303590  0.228670  0.172230  0.129730  0.097712  0.073597  0.055434
[8,]  0.403060  0.303590  0.228670  0.172230  0.129730  0.097712  0.073597
[9,]  0.535130  0.403060  0.303590  0.228670  0.172230  0.129730  0.097712
[10,]  0.710460  0.535130  0.403060  0.303590  0.228670  0.172230  0.129730
[11,]  0.943250  0.710460  0.535130  0.403060  0.303590  0.228670  0.172230
[12,]  1.252300  0.943250  0.710460  0.535130  0.403060  0.303590  0.228670
[13,]  1.662600  1.252300  0.943250  0.710460  0.535130  0.403060  0.303590
[14,]  2.207400  1.662600  1.252300  0.943250  0.710460  0.535130  0.403060
[15,]  2.930700  2.207400  1.662600  1.252300  0.943250  0.710460  0.535130
[16,]  3.890900  2.930700  2.207400  1.662600  1.252300  0.943250  0.710460
[17,]  5.165800  3.890900  2.930700  2.207400  1.662600  1.252300  0.943250
[18,]  6.858400  5.165800  3.890900  2.930700  2.207400  1.662600  1.252300
[19,]  9.105600  6.858400  5.165800  3.890900  2.930700  2.207400  1.662600
[20,] 12.089000  9.105600  6.858400  5.165800  3.890900  2.930700  2.207400
[21,] 16.050000 12.089000  9.105600  6.858400  5.165800  3.890900  2.930700
[22,] 21.309000 16.050000 12.089000  9.105600  6.858400  5.165800  3.890900
[23,] 16.050000 21.309000 16.050000 12.089000  9.105600  6.858400  5.165800
[24,] 12.089000 16.050000 21.309000 16.050000 12.089000  9.105600  6.858400
[25,]  9.105600 12.089000 16.050000 21.309000 16.050000 12.089000  9.105600
[26,]  6.858400  9.105600 12.089000 16.050000 21.309000 16.050000 12.089000
[27,]  5.165800  6.858400  9.105600 12.089000 16.050000 21.309000 16.050000
[28,]  3.890900  5.165800  6.858400  9.105600 12.089000 16.050000 21.309000
[29,]  2.930700  3.890900  5.165800  6.858400  9.105600 12.089000 16.050000
[,29]
[1,]  0.0076239
[2,]  0.0101220
[3,]  0.0134380
[4,]  0.0178420
[5,]  0.0236880
[6,]  0.0314490
[7,]  0.0417530
[8,]  0.0554340
[9,]  0.0735970
[10,]  0.0977120
[11,]  0.1297300
[12,]  0.1722300
[13,]  0.2286700
[14,]  0.3035900
[15,]  0.4030600
[16,]  0.5351300
[17,]  0.7104600
[18,]  0.9432500
[19,]  1.2523000
[20,]  1.6626000
[21,]  2.2074000
[22,]  2.9307000
[23,]  3.8909000
[24,]  5.1658000
[25,]  6.8584000
[26,]  9.1056000
[27,] 12.0890000
[28,] 16.0500000
[29,] 21.3090000
Standard Deviations: 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162 4.6162
```

nlme documentation built on April 7, 2018, 5:03 p.m.