| Title: | Linear Mixed Models: An Introduction with Applications in Veterinary Research |
|---|---|
| Description: | Data sets and analyses of Duchateau, Janssen and Rowlands (1998, ISBN:92-9146-038-9) "Linear Mixed Models: An Introduction with Applications in Veterinary Research", with an own engine for linear mixed models that gives the results of SAS PROC MIXED and PROC GLM: restricted and full maximum likelihood and Type 3 moment estimation of variance components; random coefficients with variance-component or unstructured covariance; compound-symmetry, first-order autoregressive, spatial power and unstructured residual covariance; the fixed-effects solution in the overparameterised coding; Type 3 and Type 1 tests with containment, residual, between-within, Satterthwaite (1946) <doi:10.2307/3002019> and Kenward and Roger (1997) <doi:10.2307/2533558> degrees of freedom; estimates and contrasts in the broad and narrow inference spaces; least-squares means with multiple comparisons; best linear unbiased predictions; expected mean squares; information criteria and likelihood ratio tests. Every published result of the book is reproduced and checked. With 'ggplot2' graphics, a plain-language interpretation of every result and a built-in 'shiny' application. |
| Authors: | Muhammad Yaseen [aut, cre] (ORCID: <https://orcid.org/0000-0002-5923-1714>), Luc Duchateau [ctb], Paul Janssen [ctb], John Rowlands [ctb] |
| Maintainer: | Muhammad Yaseen <[email protected]> |
| License: | GPL-2 |
| Version: | 2.0.0 |
| Built: | 2026-11-10 19:44:39 UTC |
| Source: | https://github.com/myaseen208/vetresearchlmm |
autoplot() methods for the results of VetResearchLMM; plot() draws the same
figures. A fit shows its residuals (which = "residuals", "qq" or "observed"); least-squares
means and estimates show their confidence limits; predictions of random effects are drawn as a caterpillar plot;
a comparison shows the information criteria.
autoplot.vlm_result(object, which = NULL, ...)autoplot.vlm_result(object, which = NULL, ...)
object |
a result of a function of the package. |
which |
for |
... |
not used. |
A ggplot object.
Muhammad Yaseen ([email protected])
Other VetResearchLMM utilities:
vlm_app(),
vlm_cite(),
vlm_interpret(),
vlm_notation(),
vlm_reference(),
vlm_save(),
vlm_theme()
fs <- vlm_fit( fixed = Ww ~ 1 , data = ex127 , random = ~ sire , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) ggplot2::autoplot( object = vlm_blup( fit = fs , level = 0.95 ) )fs <- vlm_fit( fixed = Ww ~ 1 , data = ex127 , random = ~ sire , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) ggplot2::autoplot( object = vlm_blup( fit = fs , level = 0.95 ) )
Computes estimated marginal means, or pairwise comparisons of them, for a fitted linear mixed model. For a model
fitted by lme4::lmer(), lmerTest::lmer() or nlme::lme() the optional package emmeans
does the work, as in version 1.1.0; for a result of vlm_fit() the least-squares means of
vlm_lsmeans() are returned.
emmeans_mixed_model( model, specs, pairwise = FALSE, method = "pairwise", adjust = "tukey", ... ) ## Default S3 method: emmeans_mixed_model( model, specs, pairwise = FALSE, method = "pairwise", adjust = "tukey", ... ) ## S3 method for class 'vlm_fit' emmeans_mixed_model( model, specs, pairwise = FALSE, method = "pairwise", adjust = "tukey", ... )emmeans_mixed_model( model, specs, pairwise = FALSE, method = "pairwise", adjust = "tukey", ... ) ## Default S3 method: emmeans_mixed_model( model, specs, pairwise = FALSE, method = "pairwise", adjust = "tukey", ... ) ## S3 method for class 'vlm_fit' emmeans_mixed_model( model, specs, pairwise = FALSE, method = "pairwise", adjust = "tukey", ... )
model |
a fitted model: a result of |
specs |
specifications of the marginal means, such as |
pairwise |
logical; |
method |
contrast method passed to |
adjust |
multiplicity adjustment (default |
... |
further arguments passed to |
Estimated marginal means (least-squares means) average the model predictions over the levels of the other
factors with equal weights. For a vlm_fit result, specs gives the effect (for example
~ dose | Drug or ~ Drug:dose); pairwise = TRUE adds all pairwise differences with the
adjustment adjust ("tukey", "bonferroni", "sidak" or "none").
For a vlm_fit result, a vlm_lsmeans result (see vlm_lsmeans()); otherwise an
emmGrid object of emmeans.
Muhammad Yaseen ([email protected])
Lenth, R. V. (2024). emmeans: Estimated Marginal Means, aka Least-Squares Means. R package.
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi.
vlm_lsmeans, report_mixed_model
Other VetResearchLMM inference:
report_mixed_model(),
vlm_blup(),
vlm_estimate(),
vlm_lsmeans()
fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) emmeans_mixed_model( model = fm , specs = ~ dose | Drug , pairwise = TRUE , method = "pairwise" , adjust = "tukey" )fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) emmeans_mixed_model( model = fm , specs = ~ dose | Drug , pairwise = TRUE , method = "pairwise" , adjust = "tukey" )
Packed cell volume (PCV, %) of trypanosome-infected animals before and one month after a low, medium or high dose of Berenil: a completely randomised design (Table 1.2.1 and Appendix A of the book).
ex121ex121
A data frame with 14 rows and 5 variables:
animal number within its dose group.
dose: H (high), L (low) or M (medium).
PCV at treatment.
PCV one month after treatment.
change in PCV, PCV2 - PCV1.
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi. Appendix A.
Other VetResearchLMM data:
ex122,
ex123,
ex124,
ex125,
ex126,
ex127,
ex31,
ex32,
ex33
str(ex121) tapply(X = ex121$PCVdiff, INDEX = ex121$dose, FUN = mean)str(ex121) tapply(X = ex121$PCVdiff, INDEX = ex121$dose, FUN = mean)
Change in packed cell volume (PCV, %) one month after a low or high dose of Berenil, five animals per dose in each of three herds; the herds are blocks (Table 1.2.2 and Appendix A of the book). New in version 2.0.0.
ex122ex122
A data frame with 30 rows and 3 variables:
herd (block): 1 to 3.
dose: H (high) or L (low).
change in PCV.
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi. Appendix A.
Other VetResearchLMM data:
ex121,
ex123,
ex124,
ex125,
ex126,
ex127,
ex31,
ex32,
ex33
str(ex122)str(ex122)
Change in packed cell volume (PCV, %) of seven animals in each of four herds; Berenil was given to two herds and Samorin to the other two, so herds are nested in drug (Table 1.2.3 and Appendix A of the book). New in version 2.0.0.
ex123ex123
A data frame with 28 rows and 3 variables:
herd: 1 to 4.
drug: Berenil or Samorin.
change in PCV.
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi. Appendix A.
Other VetResearchLMM data:
ex121,
ex122,
ex124,
ex125,
ex126,
ex127,
ex31,
ex32,
ex33
str(ex123)str(ex123)
Change in packed cell volume (PCV, %) of animals in four herds: the drug is given to whole herds (two herds per drug) and the dose to animals within a herd (Table 1.2.4 and Appendix A of the book).
ex124ex124
A data frame with 40 rows and 4 variables:
herd: 1 to 4 (nested in drug).
drug: Berenil or Samorin.
dose: h (high) or l (low).
change in PCV.
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi. Appendix A.
Other VetResearchLMM data:
ex121,
ex122,
ex123,
ex125,
ex126,
ex127,
ex31,
ex32,
ex33
str(ex124)str(ex124)
Average packed cell volume (PCV, %) of animals in six regions; in each region one herd received Berenil and one Samorin (main plots), and within a herd one group of animals received the high and one the low dose (subplots) (Table 1.2.5 and Appendix A of the book).
ex125ex125
A data frame with 24 rows and 4 variables:
region: 1 to 6.
drug: BERENIL or samorin.
dose: h (high) or l (low).
average PCV.
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi. Appendix A.
Examp2.4.2.2, Examp2.5.1.1, Examp2.6.1
Other VetResearchLMM data:
ex121,
ex122,
ex123,
ex124,
ex126,
ex127,
ex31,
ex32,
ex33
str(ex125)str(ex125)
Optical density (OD) of an ELISA for four untreated animals, measured at 11 times with two blood samples each time: a random effects model for the sources of variation (Table 1.2.6 and Appendix A of the book). New in version 2.0.0.
ex126ex126
A data frame with 88 rows and 4 variables:
time point: 1 to 11.
blood sample at the time point: 1 or 2.
animal: 1 to 4.
optical density.
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi. Appendix A.
Other VetResearchLMM data:
ex121,
ex122,
ex123,
ex124,
ex125,
ex127,
ex31,
ex32,
ex33
str(ex126)str(ex126)
Weaning weight (kg) of lambs, offspring of eight sires, under high helminth challenge (Table 1.2.7 and Appendix A of the book).
ex127ex127
A data frame with 43 rows and 2 variables:
sire: 1 to 8.
weaning weight.
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi. Appendix A.
Other VetResearchLMM data:
ex121,
ex122,
ex123,
ex124,
ex125,
ex126,
ex31,
ex32,
ex33
str(ex127)str(ex127)
Packed cell volume (PCV, %) at treatment and one month later; Berenil (at two doses) and Samorin (one dose) were given to animals in herds nested in drug. The book prints only part of the data (a few animals per herd and dose); these 38 rows are that part, so the analyses of Example 3.1 run but do not reproduce the printed results.
ex31ex31
A data frame with 38 rows and 6 variables:
herd within drug: 1 to 4 (herds with the same number but another drug are different herds).
animal.
PCV at treatment.
PCV one month after treatment.
dose within drug: 1 or 2 (Samorin has dose 1 only).
drug: BERENIL or SAMORIN.
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi. Appendix A.
Other VetResearchLMM data:
ex121,
ex122,
ex123,
ex124,
ex125,
ex126,
ex127,
ex32,
ex33
str(ex31)str(ex31)
Weaning weight (kg) of lambs of six breeds, with sex and age at weaning, for the complete offspring of a few sires per breed. The book prints only this part of the data, so the analyses of Example 3.2 run but do not reproduce the printed results.
ex32ex32
A data frame with 65 rows and 5 variables:
breed: 1 to 6.
sire (nested in breed).
sex: F or M.
age at weaning (days).
weaning weight.
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi. Appendix A.
Other VetResearchLMM data:
ex121,
ex122,
ex123,
ex124,
ex125,
ex126,
ex127,
ex31,
ex33
str(ex32)str(ex32)
Packed cell volume (PCV, %) of six Boran and six N'Dama cattle measured 14 times over 35 days after a trypanosome infection: repeated measures (Example 1.2.8 and Appendix A of the book). Version 2.0.0 corrects three typing errors of version 1.1.0 against the book (two measurement days and one animal identifier).
ex33ex33
A data frame with 168 rows and 4 variables:
animal.
breed: BO (Boran) or ND (N'Dama).
day after infection.
packed cell volume.
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi. Appendix A.
Other VetResearchLMM data:
ex121,
ex122,
ex123,
ex124,
ex125,
ex126,
ex127,
ex31,
ex32
str(ex33)str(ex33)
Drugs are given to whole herds and doses to animals within herds (ex124). With herd random, drug is
tested against herd within drug (Table 1.3.2.2); with one observation deleted the two expected mean squares no
longer match (Table 1.3.2.3: 9.7143 and 9.7222), so the F test is only approximate.
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi.
Other VetResearchLMM examples:
Examp2.2.1.7,
Examp2.3.2,
Examp2.4.2.2,
Examp2.4.3.1,
Examp2.5.1.1,
Examp2.5.2.1,
Examp2.5.3.1,
Examp2.5.4.1,
Examp2.6.1,
Examp3.1,
Examp3.2,
Examp3.3
# SAS program of the book (Appendix B): # proc glm data=ex124; # class herd dose drug; # model PCVdif = drug herd(drug) dose dose*drug; # random herd(drug) / test; # run; em <- vlm_ems( fixed = PCVdif ~ drug + drug:herd + dose + dose:drug , data = ex124 , random = ~ drug:herd , type = 3 , class = "herd" ) em # one observation deleted (Table 1.3.2.3) em1 <- vlm_ems( fixed = PCVdif ~ drug + drug:herd + dose + dose:drug , data = ex124[-1, ] , random = ~ drug:herd , type = 3 , class = "herd" ) em1$coefficients # the mixed model analysis that replaces it fm <- vlm_fit( fixed = PCVdif ~ drug + dose + drug:dose , data = ex124 , random = ~ drug:herd , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = "herd" , bound = TRUE , control = list() ) fm$tests# SAS program of the book (Appendix B): # proc glm data=ex124; # class herd dose drug; # model PCVdif = drug herd(drug) dose dose*drug; # random herd(drug) / test; # run; em <- vlm_ems( fixed = PCVdif ~ drug + drug:herd + dose + dose:drug , data = ex124 , random = ~ drug:herd , type = 3 , class = "herd" ) em # one observation deleted (Table 1.3.2.3) em1 <- vlm_ems( fixed = PCVdif ~ drug + drug:herd + dose + dose:drug , data = ex124[-1, ] , random = ~ drug:herd , type = 3 , class = "herd" ) em1$coefficients # the mixed model analysis that replaces it fm <- vlm_fit( fixed = PCVdif ~ drug + dose + drug:dose , data = ex124 , random = ~ drug:herd , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = "herd" , bound = TRUE , control = list() ) fm$tests
The three doses of ex121 compared by the fixed effects model: F = 14.36 on 2 and 11 df, and the
low dose against the mean of the medium and high doses, -3.68 with standard error 0.937 (F = 15.44).
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi.
Other VetResearchLMM examples:
Examp1.3.2,
Examp2.3.2,
Examp2.4.2.2,
Examp2.4.3.1,
Examp2.5.1.1,
Examp2.5.2.1,
Examp2.5.3.1,
Examp2.5.4.1,
Examp2.6.1,
Examp3.1,
Examp3.2,
Examp3.3
# SAS program of the book (Appendix B): # proc glm data=ex121; # class dose; # model PCVdif = dose; # estimate 'l vs mh' dose -0.5 1 -0.5; # contrast 'l vs mh' dose -0.5 1 -0.5; # run; em <- vlm_ems( fixed = PCVdiff ~ dose , data = ex121 , random = NULL , type = 3 , class = NULL ) em fm <- vlm_fit( fixed = PCVdiff ~ dose , data = ex121 , random = NULL , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) # dose levels: H, L, M vlm_estimate( fit = fm , L = list("l vs mh" = list(dose = c(-0.5, 1, -0.5))) , random = NULL , level = 0.95 ) vlm_contrast( fit = fm , L = list("l vs mh" = list(dose = c(-0.5, 1, -0.5))) )# SAS program of the book (Appendix B): # proc glm data=ex121; # class dose; # model PCVdif = dose; # estimate 'l vs mh' dose -0.5 1 -0.5; # contrast 'l vs mh' dose -0.5 1 -0.5; # run; em <- vlm_ems( fixed = PCVdiff ~ dose , data = ex121 , random = NULL , type = 3 , class = NULL ) em fm <- vlm_fit( fixed = PCVdiff ~ dose , data = ex121 , random = NULL , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) # dose levels: H, L, M vlm_estimate( fit = fm , L = list("l vs mh" = list(dose = c(-0.5, 1, -0.5))) , random = NULL , level = 0.95 ) vlm_contrast( fit = fm , L = list("l vs mh" = list(dose = c(-0.5, 1, -0.5))) )
The models of Section 2.3.2 for the examples of Chapter 1: a randomised block design with random herds
(ex122), herds nested in drug (ex123), two sizes of experimental units
(ex124) and the random effects model of the ELISA data (ex126), in which animals and
times are random and the overall mean is the only fixed effect. New in version 2.0.0.
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi.
Other VetResearchLMM examples:
Examp1.3.2,
Examp2.2.1.7,
Examp2.4.2.2,
Examp2.4.3.1,
Examp2.5.1.1,
Examp2.5.2.1,
Examp2.5.3.1,
Examp2.5.4.1,
Examp2.6.1,
Examp3.1,
Examp3.2,
Examp3.3
# SAS program of the book (Appendix B): # proc mixed data=ex126; # class anim_id time; # model OD = ; # random anim_id time; # run; f122 <- vlm_fit( fixed = PCVdif ~ dose , data = ex122 , random = ~ herd , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) f122$covariance f123 <- vlm_fit( fixed = PCVdif ~ drug , data = ex123 , random = ~ drug:herd , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) f123$tests f126 <- vlm_fit( fixed = OD ~ 1 , data = ex126 , random = ~ anim_id + time , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = "time" , bound = TRUE , control = list() ) f126$covariance vlm_interpret( x = f126 , alpha = 0.05 , top = 3 )# SAS program of the book (Appendix B): # proc mixed data=ex126; # class anim_id time; # model OD = ; # random anim_id time; # run; f122 <- vlm_fit( fixed = PCVdif ~ dose , data = ex122 , random = ~ herd , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) f122$covariance f123 <- vlm_fit( fixed = PCVdif ~ drug , data = ex123 , random = ~ drug:herd , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) f123$tests f126 <- vlm_fit( fixed = OD ~ 1 , data = ex126 , random = ~ anim_id + time , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = "time" , bound = TRUE , control = list() ) f126$covariance vlm_interpret( x = f126 , alpha = 0.05 , top = 3 )
The split-plot data ex125: REML gives 5.151 (region), 0.387 (herd within region) and 2.096
(residual); ML gives the smaller 4.292, 0.322 and 1.747 (Table 2.4.2.1), because it ignores the degrees of
freedom used by the fixed effects. The Type 3 (moment) estimates equal REML here, as the data are balanced.
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi.
Other VetResearchLMM examples:
Examp1.3.2,
Examp2.2.1.7,
Examp2.3.2,
Examp2.4.3.1,
Examp2.5.1.1,
Examp2.5.2.1,
Examp2.5.3.1,
Examp2.5.4.1,
Examp2.6.1,
Examp3.1,
Examp3.2,
Examp3.3
# SAS program of the book (Appendix B): # proc mixed data=ex125 method=ml; * and method=reml; # class drug dose region; # model pcv = drug dose drug*dose; # random region drug*region; # run; ml <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "ML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) reml <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) mom <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "Type3" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) cbind(ML = ml$covariance$estimate, REML = reml$covariance$estimate, Type3 = mom$covariance$estimate) # the same model with lme4 (optional) if (requireNamespace("lme4", quietly = TRUE)) { lm4 <- lme4::lmer( formula = Pcv ~ Drug * dose + (1 | Region / Drug) , data = ex125 , REML = TRUE ) print(lme4::VarCorr(lm4), comp = "Variance") }# SAS program of the book (Appendix B): # proc mixed data=ex125 method=ml; * and method=reml; # class drug dose region; # model pcv = drug dose drug*dose; # random region drug*region; # run; ml <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "ML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) reml <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) mom <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "Type3" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) cbind(ML = ml$covariance$estimate, REML = reml$covariance$estimate, Type3 = mom$covariance$estimate) # the same model with lme4 (optional) if (requireNamespace("lme4", quietly = TRUE)) { lm4 <- lme4::lmer( formula = Pcv ~ Drug * dose + (1 | Region / Drug) , data = ex125 , REML = TRUE ) print(lme4::VarCorr(lm4), comp = "Variance") }
The random sire model of ex127: REML variances 3.685 (sire) and 3.542 (residual), overall mean
13.97, and the prediction 3.16 for sire 4, a shrunken version of its mean deviation 17.63 - 13.97.
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi.
Other VetResearchLMM examples:
Examp1.3.2,
Examp2.2.1.7,
Examp2.3.2,
Examp2.4.2.2,
Examp2.5.1.1,
Examp2.5.2.1,
Examp2.5.3.1,
Examp2.5.4.1,
Examp2.6.1,
Examp3.1,
Examp3.2,
Examp3.3
# SAS program of the book (Appendix B): # proc mixed data=ex127; # class sire; # model ww = ; # random sire / solution; # run; fs <- vlm_fit( fixed = Ww ~ 1 , data = ex127 , random = ~ sire , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) fs$fixed vlm_blup( fit = fs , level = 0.95 ) # the same model with lme4 (optional) if (requireNamespace("lme4", quietly = TRUE)) { lm4 <- lme4::lmer( formula = Ww ~ 1 + (1 | sire) , data = ex127 , REML = TRUE ) print(lme4::VarCorr(lm4), comp = "Variance") }# SAS program of the book (Appendix B): # proc mixed data=ex127; # class sire; # model ww = ; # random sire / solution; # run; fs <- vlm_fit( fixed = Ww ~ 1 , data = ex127 , random = ~ sire , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) fs$fixed vlm_blup( fit = fs , level = 0.95 ) # the same model with lme4 (optional) if (requireNamespace("lme4", quietly = TRUE)) { lm4 <- lme4::lmer( formula = Ww ~ 1 + (1 | sire) , data = ex127 , REML = TRUE ) print(lme4::VarCorr(lm4), comp = "Variance") }
The solution for the fixed effects of ex125 with the last level of each effect set to zero:
17.13, 7.15, 4.35 and -3.18, with the variances 1.27, 0.83, 0.70 and 1.40 of their estimates (the COVB matrix).
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi.
Other VetResearchLMM examples:
Examp1.3.2,
Examp2.2.1.7,
Examp2.3.2,
Examp2.4.2.2,
Examp2.4.3.1,
Examp2.5.2.1,
Examp2.5.3.1,
Examp2.5.4.1,
Examp2.6.1,
Examp3.1,
Examp3.2,
Examp3.3
# SAS program of the book (Appendix B): # proc mixed data=ex125; # class drug dose region; # model pcv = drug dose drug*dose / solution covb; # random region drug*region; # run; fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) fm$fixed fm$fixed$se^2# SAS program of the book (Appendix B): # proc mixed data=ex125; # class drug dose region; # model pcv = drug dose drug*dose / solution covb; # random region drug*region; # run; fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) fm$fixed fm$fixed$se^2
The four drug-by-dose means of ex125 (25.45, 24.28, 21.48 and 17.13) and their variance 1.27,
as least-squares means.
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi.
Other VetResearchLMM examples:
Examp1.3.2,
Examp2.2.1.7,
Examp2.3.2,
Examp2.4.2.2,
Examp2.4.3.1,
Examp2.5.1.1,
Examp2.5.3.1,
Examp2.5.4.1,
Examp2.6.1,
Examp3.1,
Examp3.2,
Examp3.3
# SAS program of the book (Appendix B): # proc mixed data=ex125; # class drug dose region; # model pcv = drug dose drug*dose; # random region drug*region; # lsmeans drug*dose; # run; fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) vlm_lsmeans( fit = fm , specs = ~ Drug:dose , at = NULL , diff = FALSE , adjust = "none" , level = 0.95 )# SAS program of the book (Appendix B): # proc mixed data=ex125; # class drug dose region; # model pcv = drug dose drug*dose; # random region drug*region; # lsmeans drug*dose; # run; fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) vlm_lsmeans( fit = fm , specs = ~ Drug:dose , at = NULL , diff = FALSE , adjust = "none" , level = 0.95 )
Four linear combinations of the fixed effects of ex125: their variances 0.478, 1.0975, 0.698 and
1.272 combine the variance components, and their Satterthwaite degrees of freedom (5, 6.2, 10 and 8.2) the
degrees of freedom of the mean squares of Table 2.5.3.1.
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi.
Other VetResearchLMM examples:
Examp1.3.2,
Examp2.2.1.7,
Examp2.3.2,
Examp2.4.2.2,
Examp2.4.3.1,
Examp2.5.1.1,
Examp2.5.2.1,
Examp2.5.4.1,
Examp2.6.1,
Examp3.1,
Examp3.2,
Examp3.3
# SAS program of the book (Appendix B): # proc mixed data=ex125; # class drug dose region; # model pcv = drug dose drug*dose / ddfm=satterth; # random region drug*region; # estimate 'drug dif' drug -1 1 drug*dose -0.5 -0.5 0.5 0.5; # estimate 'Samorin mean' intercept 1 drug 0 1 dose 0.5 0.5 drug*dose 0 0 0.5 0.5; # estimate 'Samorin HvsL' dose 1 -1 drug*dose 0 0 1 -1; # estimate 'Samorin high' intercept 1 drug 0 1 dose 1 0 drug*dose 0 0 1 0; # run; fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = NULL , bound = TRUE , control = list() ) vlm_estimate( fit = fm , L = list( "drug dif" = list(Drug = c(-1, 1), "Drug:dose" = c(-0.5, -0.5, 0.5, 0.5)) , "Samorin mean" = list(Intercept = 1, Drug = c(0, 1), dose = c(0.5, 0.5), "Drug:dose" = c(0, 0, 0.5, 0.5)) , "Samorin HvsL" = list(dose = c(1, -1), "Drug:dose" = c(0, 0, 1, -1)) , "Samorin high" = list(Intercept = 1, Drug = c(0, 1), dose = c(1, 0), "Drug:dose" = c(0, 0, 1, 0)) ) , random = NULL , level = 0.95 ) # the mean squares and their expectations (Table 2.5.3.1) em <- vlm_ems( fixed = Pcv ~ Region + Drug + Region:Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , type = 3 , class = NULL ) em# SAS program of the book (Appendix B): # proc mixed data=ex125; # class drug dose region; # model pcv = drug dose drug*dose / ddfm=satterth; # random region drug*region; # estimate 'drug dif' drug -1 1 drug*dose -0.5 -0.5 0.5 0.5; # estimate 'Samorin mean' intercept 1 drug 0 1 dose 0.5 0.5 drug*dose 0 0 0.5 0.5; # estimate 'Samorin HvsL' dose 1 -1 drug*dose 0 0 1 -1; # estimate 'Samorin high' intercept 1 drug 0 1 dose 1 0 drug*dose 0 0 1 0; # run; fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = NULL , bound = TRUE , control = list() ) vlm_estimate( fit = fm , L = list( "drug dif" = list(Drug = c(-1, 1), "Drug:dose" = c(-0.5, -0.5, 0.5, 0.5)) , "Samorin mean" = list(Intercept = 1, Drug = c(0, 1), dose = c(0.5, 0.5), "Drug:dose" = c(0, 0, 0.5, 0.5)) , "Samorin HvsL" = list(dose = c(1, -1), "Drug:dose" = c(0, 0, 1, -1)) , "Samorin high" = list(Intercept = 1, Drug = c(0, 1), dose = c(1, 0), "Drug:dose" = c(0, 0, 1, 0)) ) , random = NULL , level = 0.95 ) # the mean squares and their expectations (Table 2.5.3.1) em <- vlm_ems( fixed = Pcv ~ Region + Drug + Region:Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , type = 3 , class = NULL ) em
The mean of Samorin in ex125: its variance is 1.0975 when regions and herds are random (broad
space) and 0.175 for the six regions and herds of the study (narrow space), as in the fixed effects model.
The narrow-space estimate adds the random effects averaged over the observed levels (the part of an ESTIMATE statement after the vertical bar in SAS); the fixed effects model with regions and herds fixed gives the same standard error.
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi.
Other VetResearchLMM examples:
Examp1.3.2,
Examp2.2.1.7,
Examp2.3.2,
Examp2.4.2.2,
Examp2.4.3.1,
Examp2.5.1.1,
Examp2.5.2.1,
Examp2.5.3.1,
Examp2.6.1,
Examp3.1,
Examp3.2,
Examp3.3
# SAS program of the book (Appendix B): # proc mixed data=ex125; # class drug dose region; # model pcv = drug dose drug*dose / ddfm=satterth; # random region drug*region; # estimate 'Samorin mean' intercept 1 drug 0 1 dose 0.5 0.5 drug*dose 0 0 0.5 0.5; # run; # proc glm data=ex125; # class drug dose region; # model pcv = region drug drug*region dose drug*dose; # estimate 'Samorin mean' intercept 1 drug 0 1 dose 0.5 0.5 drug*dose 0 0 0.5 0.5; # run; fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = NULL , bound = TRUE , control = list() ) vlm_estimate( fit = fm , L = list( "broad" = list(Intercept = 1, Drug = c(0, 1), dose = c(0.5, 0.5), "Drug:dose" = c(0, 0, 0.5, 0.5)) , "narrow" = list(Intercept = 1, Drug = c(0, 1), dose = c(0.5, 0.5), "Drug:dose" = c(0, 0, 0.5, 0.5)) ) , random = list( "narrow" = list(Region = rep(1 / 6, 6), "Region:Drug" = rep(c(0, 1 / 6), 6)) ) , level = 0.95 ) # the fixed effects model: regions and herds fixed ff <- vlm_fit( fixed = Pcv ~ Region + Drug + Region:Drug + dose + Drug:dose , data = ex125 , random = NULL , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = "Region" , bound = TRUE , control = list() ) vlm_estimate( fit = ff , L = list( "Samorin mean" = list(Intercept = 1, Region = rep(1 / 6, 6), Drug = c(0, 1), "Region:Drug" = rep(c(0, 1 / 6), 6), dose = c(0.5, 0.5), "Drug:dose" = c(0, 0, 0.5, 0.5)) ) , random = NULL , level = 0.95 )# SAS program of the book (Appendix B): # proc mixed data=ex125; # class drug dose region; # model pcv = drug dose drug*dose / ddfm=satterth; # random region drug*region; # estimate 'Samorin mean' intercept 1 drug 0 1 dose 0.5 0.5 drug*dose 0 0 0.5 0.5; # run; # proc glm data=ex125; # class drug dose region; # model pcv = region drug drug*region dose drug*dose; # estimate 'Samorin mean' intercept 1 drug 0 1 dose 0.5 0.5 drug*dose 0 0 0.5 0.5; # run; fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = NULL , bound = TRUE , control = list() ) vlm_estimate( fit = fm , L = list( "broad" = list(Intercept = 1, Drug = c(0, 1), dose = c(0.5, 0.5), "Drug:dose" = c(0, 0, 0.5, 0.5)) , "narrow" = list(Intercept = 1, Drug = c(0, 1), dose = c(0.5, 0.5), "Drug:dose" = c(0, 0, 0.5, 0.5)) ) , random = list( "narrow" = list(Region = rep(1 / 6, 6), "Region:Drug" = rep(c(0, 1 / 6), 6)) ) , level = 0.95 ) # the fixed effects model: regions and herds fixed ff <- vlm_fit( fixed = Pcv ~ Region + Drug + Region:Drug + dose + Drug:dose , data = ex125 , random = NULL , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = "Region" , bound = TRUE , control = list() ) vlm_estimate( fit = ff , L = list( "Samorin mean" = list(Intercept = 1, Region = rep(1 / 6, 6), Drug = c(0, 1), "Region:Drug" = rep(c(0, 1 / 6), 6), dose = c(0.5, 0.5), "Drug:dose" = c(0, 0, 0.5, 0.5)) ) , random = NULL , level = 0.95 )
The drug difference of ex125 (estimate -5.56, variance 0.478, F on 1 and 5 df) and the joint test
that the four cell means are equal: F = 31.2 on 3 and 7.14 df, p = 0.0002.
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi.
Other VetResearchLMM examples:
Examp1.3.2,
Examp2.2.1.7,
Examp2.3.2,
Examp2.4.2.2,
Examp2.4.3.1,
Examp2.5.1.1,
Examp2.5.2.1,
Examp2.5.3.1,
Examp2.5.4.1,
Examp3.1,
Examp3.2,
Examp3.3
# SAS program of the book (Appendix B): # proc mixed data=ex125; # class drug dose region; # model pcv = drug dose drug*dose / ddfm=satterth; # random region drug*region; # contrast 'drug dif' drug -1 1 drug*dose -0.5 -0.5 0.5 0.5; # contrast 'all' drug 1 -1 dose 0 0 drug*dose 0.5 0.5 -0.5 -0.5, # drug 0 0 dose 1 -1 drug*dose 0.5 -0.5 0.5 -0.5, # drug 0 0 dose 0 0 drug*dose 0.5 -0.5 -0.5 0.5; # run; fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = NULL , bound = TRUE , control = list() ) vlm_contrast( fit = fm , L = list( "drug dif" = list(Drug = c(-1, 1), "Drug:dose" = c(-0.5, -0.5, 0.5, 0.5)) , "all" = list( list(Drug = c(1, -1), "Drug:dose" = c(0.5, 0.5, -0.5, -0.5)) , list(dose = c(1, -1), "Drug:dose" = c(0.5, -0.5, 0.5, -0.5)) , list("Drug:dose" = c(0.5, -0.5, -0.5, 0.5)) ) ) )# SAS program of the book (Appendix B): # proc mixed data=ex125; # class drug dose region; # model pcv = drug dose drug*dose / ddfm=satterth; # random region drug*region; # contrast 'drug dif' drug -1 1 drug*dose -0.5 -0.5 0.5 0.5; # contrast 'all' drug 1 -1 dose 0 0 drug*dose 0.5 0.5 -0.5 -0.5, # drug 0 0 dose 1 -1 drug*dose 0.5 -0.5 0.5 -0.5, # drug 0 0 dose 0 0 drug*dose 0.5 -0.5 -0.5 0.5; # run; fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = NULL , bound = TRUE , control = list() ) vlm_contrast( fit = fm , L = list( "drug dif" = list(Drug = c(-1, 1), "Drug:dose" = c(-0.5, -0.5, 0.5, 0.5)) , "all" = list( list(Drug = c(1, -1), "Drug:dose" = c(0.5, 0.5, -0.5, -0.5)) , list(dose = c(1, -1), "Drug:dose" = c(0.5, -0.5, 0.5, -0.5)) , list("Drug:dose" = c(0.5, -0.5, -0.5, 0.5)) ) ) )
Berenil at two doses and Samorin at one dose, given to animals in herds nested in drug (ex31).
Model 1 compares the three treatments; Model 2 adds the PCV at treatment as a covariate with a common slope;
Model 3 allows a slope per treatment and compares the treatments at PCV1 = 18. The book prints only part of the
data, so the numbers differ from those of the book.
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi.
Other VetResearchLMM examples:
Examp1.3.2,
Examp2.2.1.7,
Examp2.3.2,
Examp2.4.2.2,
Examp2.4.3.1,
Examp2.5.1.1,
Examp2.5.2.1,
Examp2.5.3.1,
Examp2.5.4.1,
Examp2.6.1,
Examp3.2,
Examp3.3
# SAS program of the book (Appendix B): # proc mixed data=ex31; # class drug dose herd; # model PCV2 = drug dose(drug) / solution ddfm=satterth; # random herd(drug); # estimate 'Mean Samorin' intercept 1 drug 0 1 dose(drug) 0 0 1; # estimate 'Berenil 2 doses' dose(drug) 1 -1 0; # estimate 'Ber vs Sam at dose 1' drug 1 -1 dose(drug) 1 0 -1; # contrast 'some difference' drug 1 -1 dose(drug) 0.5 0.5 -1, drug 0 0 dose(drug) 1 -1 0; # lsmeans dose(drug); # run; # * Model 3: model PCV2 = drug dose(drug) PCV1*dose(drug); lsmeans dose(drug) / at PCV1=18; m1 <- vlm_fit( fixed = PCV2 ~ drug + drug:dose , data = ex31 , random = ~ drug:herd , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = c("herd", "dose") , bound = TRUE , control = list() ) m1$tests vlm_estimate( fit = m1 , L = list( "Mean Samorin" = list(Intercept = 1, drug = c(0, 1), "drug:dose" = c(0, 0, 1)) , "Berenil 2 doses" = list("drug:dose" = c(1, -1, 0)) , "Ber vs Sam at dose 1" = list(drug = c(1, -1), "drug:dose" = c(1, 0, -1)) ) , random = NULL , level = 0.95 ) vlm_contrast( fit = m1 , L = list( "some difference" = list( list(drug = c(1, -1), "drug:dose" = c(0.5, 0.5, -1)) , list("drug:dose" = c(1, -1, 0)) ) ) ) vlm_lsmeans( fit = m1 , specs = ~ drug:dose , at = NULL , diff = FALSE , adjust = "none" , level = 0.95 ) m2 <- vlm_fit( fixed = PCV2 ~ PCV1 + drug + drug:dose , data = ex31 , random = ~ drug:herd , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = c("herd", "dose") , bound = TRUE , control = list() ) m2$fixed m3 <- vlm_fit( fixed = PCV2 ~ drug + drug:dose + PCV1:drug:dose , data = ex31 , random = ~ drug:herd , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = c("herd", "dose") , bound = TRUE , control = list() ) vlm_lsmeans( fit = m3 , specs = ~ drug:dose , at = list(PCV1 = 18) , diff = FALSE , adjust = "none" , level = 0.95 )# SAS program of the book (Appendix B): # proc mixed data=ex31; # class drug dose herd; # model PCV2 = drug dose(drug) / solution ddfm=satterth; # random herd(drug); # estimate 'Mean Samorin' intercept 1 drug 0 1 dose(drug) 0 0 1; # estimate 'Berenil 2 doses' dose(drug) 1 -1 0; # estimate 'Ber vs Sam at dose 1' drug 1 -1 dose(drug) 1 0 -1; # contrast 'some difference' drug 1 -1 dose(drug) 0.5 0.5 -1, drug 0 0 dose(drug) 1 -1 0; # lsmeans dose(drug); # run; # * Model 3: model PCV2 = drug dose(drug) PCV1*dose(drug); lsmeans dose(drug) / at PCV1=18; m1 <- vlm_fit( fixed = PCV2 ~ drug + drug:dose , data = ex31 , random = ~ drug:herd , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = c("herd", "dose") , bound = TRUE , control = list() ) m1$tests vlm_estimate( fit = m1 , L = list( "Mean Samorin" = list(Intercept = 1, drug = c(0, 1), "drug:dose" = c(0, 0, 1)) , "Berenil 2 doses" = list("drug:dose" = c(1, -1, 0)) , "Ber vs Sam at dose 1" = list(drug = c(1, -1), "drug:dose" = c(1, 0, -1)) ) , random = NULL , level = 0.95 ) vlm_contrast( fit = m1 , L = list( "some difference" = list( list(drug = c(1, -1), "drug:dose" = c(0.5, 0.5, -1)) , list("drug:dose" = c(1, -1, 0)) ) ) ) vlm_lsmeans( fit = m1 , specs = ~ drug:dose , at = NULL , diff = FALSE , adjust = "none" , level = 0.95 ) m2 <- vlm_fit( fixed = PCV2 ~ PCV1 + drug + drug:dose , data = ex31 , random = ~ drug:herd , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = c("herd", "dose") , bound = TRUE , control = list() ) m2$fixed m3 <- vlm_fit( fixed = PCV2 ~ drug + drug:dose + PCV1:drug:dose , data = ex31 , random = ~ drug:herd , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = c("herd", "dose") , bound = TRUE , control = list() ) vlm_lsmeans( fit = m3 , specs = ~ drug:dose , at = list(PCV1 = 18) , diff = FALSE , adjust = "none" , level = 0.95 )
Weaning weights of lambs (ex32) with sex, age and breed fixed and sires within breed random: the
heritability , Tukey-Kramer comparisons of the breeds and the
predicted breeding values of the sires. The book prints only part of the data, so the numbers differ from those
of the book (for this part the sire variance is estimated as zero).
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi.
Other VetResearchLMM examples:
Examp1.3.2,
Examp2.2.1.7,
Examp2.3.2,
Examp2.4.2.2,
Examp2.4.3.1,
Examp2.5.1.1,
Examp2.5.2.1,
Examp2.5.3.1,
Examp2.5.4.1,
Examp2.6.1,
Examp3.1,
Examp3.3
# SAS program of the book (Appendix B): # proc mixed data=ex32; # class sex sire_id breed; # model ww = sex agew breed / solution ddfm=satterth; # random sire_id(breed) / solution; # lsmeans breed / adjust=tukey; # run; fm <- vlm_fit( fixed = Ww ~ sex + agew + breed , data = ex32 , random = ~ breed:sire_id , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = "breed" , bound = TRUE , control = list() ) v <- fm$covariance$estimate h2 <- 4 * v[1] / sum(v) h2 vlm_lsmeans( fit = fm , specs = ~ breed , at = NULL , diff = TRUE , adjust = "tukey" , level = 0.95 ) vlm_blup( fit = fm , level = 0.95 )# SAS program of the book (Appendix B): # proc mixed data=ex32; # class sex sire_id breed; # model ww = sex agew breed / solution ddfm=satterth; # random sire_id(breed) / solution; # lsmeans breed / adjust=tukey; # run; fm <- vlm_fit( fixed = Ww ~ sex + agew + breed , data = ex32 , random = ~ breed:sire_id , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = "breed" , bound = TRUE , control = list() ) v <- fm$covariance$estimate h2 <- 4 * v[1] / sum(v) h2 vlm_lsmeans( fit = fm , specs = ~ breed , at = NULL , diff = TRUE , adjust = "tukey" , level = 0.95 ) vlm_blup( fit = fm , level = 0.95 )
PCV of 12 animals of two breeds measured 14 times (ex33). Model 1 has a random animal effect,
equivalent to compound symmetry (variances 5.478 and 4.965; -2 restricted log-likelihood 783.451); Model 2 has
first-order autoregressive errors (rho = 0.621, residual 10.191; 793.139); Model 3 has a random intercept and
slope per animal with an unstructured covariance (12.46, -0.2551, 0.005758 and residual 4.353).
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi.
vlm_random, vlm_repeated, vlm_compare, ex33
Other VetResearchLMM examples:
Examp1.3.2,
Examp2.2.1.7,
Examp2.3.2,
Examp2.4.2.2,
Examp2.4.3.1,
Examp2.5.1.1,
Examp2.5.2.1,
Examp2.5.3.1,
Examp2.5.4.1,
Examp2.6.1,
Examp3.1,
Examp3.2
# SAS program of the book (Appendix B): # proc mixed data=ex33; class breed anim_id; model pcv = breed breed*time / solution; # random anim_id(breed) / solution; * Model 1; # repeated / type=cs sub=anim_id(breed) r; * Model 1, second form; # repeated / type=ar(1) sub=anim_id(breed) r; * Model 2; # random intercept time / type=un sub=anim_id(breed) solution; * Model 3; # run; m1 <- vlm_fit( fixed = PCV ~ breed + breed:time , data = ex33 , random = ~ animal_id:breed , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) m1$fixed vlm_blup( fit = m1 , level = 0.95 ) cs <- vlm_fit( fixed = PCV ~ breed + breed:time , data = ex33 , random = NULL , repeated = vlm_repeated( type = c("vc", "cs", "ar1", "sp_pow", "un")[2] , subject = ~ animal_id:breed , order = NULL ) , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) cs$fit m1c <- vlm_fit( fixed = PCV ~ time + breed + breed:time , data = ex33 , random = ~ animal_id:breed , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) m1c$tests ar <- vlm_fit( fixed = PCV ~ breed + breed:time , data = ex33 , random = NULL , repeated = vlm_repeated( type = c("vc", "cs", "ar1", "sp_pow", "un")[3] , subject = ~ animal_id:breed , order = ~ time ) , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) ar$covariance rc <- vlm_fit( fixed = PCV ~ breed + breed:time , data = ex33 , random = vlm_random( effects = ~ 1 + time , subject = ~ animal_id:breed , type = c("vc", "un")[2] ) , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) rc$covariance vlm_compare( CS = cs , AR1 = ar , RC = rc , test = TRUE ) # the same model with lme4 (optional) if (requireNamespace("lme4", quietly = TRUE)) { lm4 <- lme4::lmer( formula = PCV ~ breed + breed:time + (1 | animal_id) , data = ex33 , REML = TRUE ) print(lme4::VarCorr(lm4), comp = "Variance") }# SAS program of the book (Appendix B): # proc mixed data=ex33; class breed anim_id; model pcv = breed breed*time / solution; # random anim_id(breed) / solution; * Model 1; # repeated / type=cs sub=anim_id(breed) r; * Model 1, second form; # repeated / type=ar(1) sub=anim_id(breed) r; * Model 2; # random intercept time / type=un sub=anim_id(breed) solution; * Model 3; # run; m1 <- vlm_fit( fixed = PCV ~ breed + breed:time , data = ex33 , random = ~ animal_id:breed , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) m1$fixed vlm_blup( fit = m1 , level = 0.95 ) cs <- vlm_fit( fixed = PCV ~ breed + breed:time , data = ex33 , random = NULL , repeated = vlm_repeated( type = c("vc", "cs", "ar1", "sp_pow", "un")[2] , subject = ~ animal_id:breed , order = NULL ) , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) cs$fit m1c <- vlm_fit( fixed = PCV ~ time + breed + breed:time , data = ex33 , random = ~ animal_id:breed , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) m1c$tests ar <- vlm_fit( fixed = PCV ~ breed + breed:time , data = ex33 , random = NULL , repeated = vlm_repeated( type = c("vc", "cs", "ar1", "sp_pow", "un")[3] , subject = ~ animal_id:breed , order = ~ time ) , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) ar$covariance rc <- vlm_fit( fixed = PCV ~ breed + breed:time , data = ex33 , random = vlm_random( effects = ~ 1 + time , subject = ~ animal_id:breed , type = c("vc", "un")[2] ) , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) rc$covariance vlm_compare( CS = cs , AR1 = ar , RC = rc , test = TRUE ) # the same model with lme4 (optional) if (requireNamespace("lme4", quietly = TRUE)) { lm4 <- lme4::lmer( formula = PCV ~ breed + breed:time + (1 | animal_id) , data = ex33 , REML = TRUE ) print(lme4::VarCorr(lm4), comp = "Variance") }
Gives a narrative report of a fitted model. For a result of vlm_fit() it is the plain-language
interpretation of vlm_interpret(); for other models the optional package report writes the
report, as in version 1.1.0.
report_mixed_model(model, ...) ## Default S3 method: report_mixed_model(model, ...) ## S3 method for class 'vlm_fit' report_mixed_model(model, ...)report_mixed_model(model, ...) ## Default S3 method: report_mixed_model(model, ...) ## S3 method for class 'vlm_fit' report_mixed_model(model, ...)
model |
a fitted model: a result of |
... |
further arguments passed to |
A vlm_interpretation object for a vlm_fit result; otherwise the object returned by
report::report().
Muhammad Yaseen ([email protected])
Makowski, D., Ben-Shachar, M. S., Patil, I. and Luedecke, D. (2023). Automated results reporting as a practical tool to improve reproducibility and methodological best practices adoption. R package report.
vlm_interpret, emmeans_mixed_model
Other VetResearchLMM inference:
emmeans_mixed_model(),
vlm_blup(),
vlm_estimate(),
vlm_lsmeans()
fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) report_mixed_model( model = fm )fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) report_mixed_model( model = fm )
vlm_app() starts the application of VetResearchLMM: choose a data set of the book (or upload a CSV
file), fit a linear mixed model with random effects and a residual covariance structure, and obtain least-squares
means, estimates and contrasts, predictions of random effects, the analysis of variance with expected mean
squares, and a comparison of covariance structures. Every example of the book can be loaded with one click. Each
result page shows an interpretation computed from the results (vlm_interpret()), the output as R
prints it, formatted tables, plots and the R code that repeats the analysis, each with a Copy button.
vlm_app(launch.browser = interactive(), ...) vlm_app_object()vlm_app(launch.browser = interactive(), ...) vlm_app_object()
launch.browser |
passed to |
... |
further arguments to |
The application needs the suggested packages shiny, bslib and DT. Plots are sent to the browser
as WebP images when magick is installed (PNG otherwise) and can be downloaded as PNG, PDF or WebP. Estimates
and contrasts are typed as in SAS: label: effect coefficients effect coefficients, one per line, with rows
of a contrast separated by commas.
vlm_app() is called for its side effect and returns the value of shiny::runApp() when the
application is closed; vlm_app_object() returns the application object (for shiny::runApp(),
shiny::testServer() or deployment on a server).
Muhammad Yaseen ([email protected])
Other VetResearchLMM utilities:
autoplot.vlm_result(),
vlm_cite(),
vlm_interpret(),
vlm_notation(),
vlm_reference(),
vlm_save(),
vlm_theme()
if (interactive()) { vlm_app( launch.browser = TRUE ) }if (interactive()) { vlm_app( launch.browser = TRUE ) }
The predictions of the random effects of a fitted model, with the standard
errors of prediction , t tests and prediction limits: the solution
for random effects of SAS PROC MIXED.
vlm_blup(fit, level = 0.95) ## Default S3 method: vlm_blup(fit, level = 0.95)vlm_blup(fit, level = 0.95) ## Default S3 method: vlm_blup(fit, level = 0.95)
fit |
a result of |
level |
confidence level of the prediction limits (default 0.95). |
For a single random factor with observations on level , the prediction reduces to
a shrinkage of the level mean towards the overall mean (Example 2.4.3.1 of the book). The degrees of freedom are
the residual ones, or Satterthwaite ones (numerical derivatives of the prediction-error variance) with
ddfm = "satterth" or "kr".
A list of class c("vlm_blup", "vlm_result", "list") with blup (effect, subject, level,
prediction, standard error of prediction, df, t, p and limits).
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi. Section 2.4.3.
Henderson, C. R. (1975). Best linear unbiased estimation and prediction under a selection model. Biometrics, 31, 423-447.
Other VetResearchLMM inference:
emmeans_mixed_model(),
report_mixed_model(),
vlm_estimate(),
vlm_lsmeans()
# Example 2.4.3.1: PROC MIXED; CLASS sire; MODEL ww = ; RANDOM sire / SOLUTION; fs <- vlm_fit( fixed = Ww ~ 1 , data = ex127 , random = ~ sire , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) bl <- vlm_blup( fit = fs , level = 0.95 ) bl# Example 2.4.3.1: PROC MIXED; CLASS sire; MODEL ww = ; RANDOM sire / SOLUTION; fs <- vlm_fit( fixed = Ww ~ 1 , data = ex127 , random = ~ sire , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) bl <- vlm_blup( fit = fs , level = 0.95 ) bl
vlm_cite() gives the references of the methods behind a result of the package, or every reference of the
package, as text or BibTeX. citation("VetResearchLMM") cites the package and the book.
vlm_cite(x = NULL, style = c("text", "bibtex")) ## Default S3 method: vlm_cite(x = NULL, style = c("text", "bibtex"))vlm_cite(x = NULL, style = c("text", "bibtex")) ## Default S3 method: vlm_cite(x = NULL, style = c("text", "bibtex"))
x |
a result of a function of the package, or |
style |
|
An object of class bibentry (printed in the chosen style).
Muhammad Yaseen ([email protected])
Other VetResearchLMM utilities:
autoplot.vlm_result(),
vlm_app(),
vlm_interpret(),
vlm_notation(),
vlm_reference(),
vlm_save(),
vlm_theme()
vlm_cite( x = NULL , style = "text" )vlm_cite( x = NULL , style = "text" )
Compares several fits of vlm_fit() by their (restricted) log-likelihoods and information criteria,
and tests each model against the one before it by a likelihood ratio test: the comparison of covariance
structures of Example 3.3 of the book (compound symmetry, first-order autoregressive, random coefficients).
vlm_compare(..., test = TRUE) ## Default S3 method: vlm_compare(..., test = TRUE)vlm_compare(..., test = TRUE) ## Default S3 method: vlm_compare(..., test = TRUE)
... |
two or more results of |
test |
logical; add likelihood ratio tests of each model against the previous one (default |
With the maximised (restricted) log-likelihood and the number of covariance parameters (plus
the rank of for ML), , and
, where for REML ( for ML) and
is the number of subjects. The likelihood ratio statistic of two nested models is
, referred to ; when the larger model adds one variance
component, the null value lies on the boundary and p_boundary gives the p-value of the 50:50 mixture of
and (Self and Liang 1987). REML likelihoods are comparable only between models with
the same fixed effects; the test is then left out.
A list of class c("vlm_compare", "vlm_result", "list") with models (one row per model:
method, number of covariance parameters, -2 log-likelihood, AIC, AICC, BIC and the test against the previous
model).
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi. Section 3.4.
Self, S. G. and Liang, K.-Y. (1987). Asymptotic properties of maximum likelihood estimators and likelihood ratio tests under nonstandard conditions. Journal of the American Statistical Association, 82, 605-610.
Other VetResearchLMM models:
vlm_ems(),
vlm_fit(),
vlm_random()
cs <- vlm_fit( fixed = PCV ~ breed + breed:time , data = ex33 , random = NULL , repeated = vlm_repeated( type = c("vc", "cs", "ar1", "sp_pow", "un")[2] , subject = ~ animal_id:breed , order = NULL ) , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) ar <- vlm_fit( fixed = PCV ~ breed + breed:time , data = ex33 , random = NULL , repeated = vlm_repeated( type = c("vc", "cs", "ar1", "sp_pow", "un")[3] , subject = ~ animal_id:breed , order = NULL ) , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) rc <- vlm_fit( fixed = PCV ~ breed + breed:time , data = ex33 , random = vlm_random( effects = ~ 1 + time , subject = ~ animal_id:breed , type = c("vc", "un")[2] ) , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) vlm_compare( CS = cs , AR1 = ar , RC = rc , test = TRUE )cs <- vlm_fit( fixed = PCV ~ breed + breed:time , data = ex33 , random = NULL , repeated = vlm_repeated( type = c("vc", "cs", "ar1", "sp_pow", "un")[2] , subject = ~ animal_id:breed , order = NULL ) , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) ar <- vlm_fit( fixed = PCV ~ breed + breed:time , data = ex33 , random = NULL , repeated = vlm_repeated( type = c("vc", "cs", "ar1", "sp_pow", "un")[3] , subject = ~ animal_id:breed , order = NULL ) , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) rc <- vlm_fit( fixed = PCV ~ breed + breed:time , data = ex33 , random = vlm_random( effects = ~ 1 + time , subject = ~ animal_id:breed , type = c("vc", "un")[2] ) , repeated = NULL , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) vlm_compare( CS = cs , AR1 = ar , RC = rc , test = TRUE )
The analysis of variance of a linear model fitted by ordinary least squares, with the expected mean squares of each source when some effects are random, F tests built from the appropriate (synthesised) error terms with Satterthwaite degrees of freedom, and the method-of-moments (Type 3) estimates of the variance components. This is SAS PROC GLM with a RANDOM statement and the TEST option (Examples 1.3.2 and 2.5.3.1 of the book).
vlm_ems(fixed, data, random = NULL, type = 3, class = NULL) ## Default S3 method: vlm_ems(fixed, data, random = NULL, type = 3, class = NULL)vlm_ems(fixed, data, random = NULL, type = 3, class = NULL) ## Default S3 method: vlm_ems(fixed, data, random = NULL, type = 3, class = NULL)
fixed |
two-sided formula with every effect of the model, random effects included, in SAS MODEL order
(for example |
data |
a data frame with the variables. |
random |
one-sided formula of the effects of |
type |
type of sums of squares: 3 (default) or 1. |
class |
optional character vector of numeric variables to treat as classification variables. |
The sum of squares of a source is a quadratic form : for Type 3,
with in the sum-to-zero coding
and selecting the columns of the source; for Type 1, the projection on the columns added by the
source. With random effects of design
,
The error term of a source is the combination of mean squares of other random sources and
the residual whose expectation equals that of the source under the null hypothesis; its degrees of freedom are
(Satterthwaite 1946). Equating the mean squares of the
random sources and the error to their expectations gives the Type 3 estimates of the variance components.
A list of class c("vlm_ems", "vlm_result", "list") with anova (source, df, sum of
squares, mean square, expected mean square, F, error degrees of freedom and p-value),
coefficients (the coefficients of the variance components in each expected mean square),
error_terms (the combination of mean squares used as the error of each test) and
components (Type 3 estimates of the variance components).
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi. Section 1.3.2 and Appendix G.
Satterthwaite, F. E. (1946). An approximate distribution of estimates of variance components. Biometrics Bulletin, 2, 110-114.
Other VetResearchLMM models:
vlm_compare(),
vlm_fit(),
vlm_random()
# Example 1.3.2: PROC GLM; CLASS herd dose drug; MODEL PCVdif = drug herd(drug) dose dose*drug; # RANDOM herd(drug) / TEST; em <- vlm_ems( fixed = PCVdif ~ drug + drug:herd + dose + dose:drug , data = ex124 , random = ~ drug:herd , type = 3 , class = "herd" ) em # one observation deleted: the expected mean squares of drug and herd(drug) no longer match # (Table 1.3.2.3) em1 <- vlm_ems( fixed = PCVdif ~ drug + drug:herd + dose + dose:drug , data = ex124[-1, ] , random = ~ drug:herd , type = 3 , class = "herd" ) em1$coefficients# Example 1.3.2: PROC GLM; CLASS herd dose drug; MODEL PCVdif = drug herd(drug) dose dose*drug; # RANDOM herd(drug) / TEST; em <- vlm_ems( fixed = PCVdif ~ drug + drug:herd + dose + dose:drug , data = ex124 , random = ~ drug:herd , type = 3 , class = "herd" ) em # one observation deleted: the expected mean squares of drug and herd(drug) no longer match # (Table 1.3.2.3) em1 <- vlm_ems( fixed = PCVdif ~ drug + drug:herd + dose + dose:drug , data = ex124[-1, ] , random = ~ drug:herd , type = 3 , class = "herd" ) em1$coefficients
vlm_estimate() gives estimates of linear combinations (the
ESTIMATE statement of SAS PROC MIXED), optionally including random effects
(the narrow or intermediate inference space). vlm_contrast() gives F tests of sets of linear combinations
(the CONTRAST statement).
vlm_estimate(fit, L, random = NULL, level = 0.95) ## Default S3 method: vlm_estimate(fit, L, random = NULL, level = 0.95) vlm_contrast(fit, L) ## Default S3 method: vlm_contrast(fit, L)vlm_estimate(fit, L, random = NULL, level = 0.95) ## Default S3 method: vlm_estimate(fit, L, random = NULL, level = 0.95) vlm_contrast(fit, L) ## Default S3 method: vlm_contrast(fit, L)
fit |
a result of |
L |
for |
random |
optional named list (names as in |
level |
confidence level (default 0.95). |
Coefficients are given per effect as in SAS, in the order of the levels in the solution table
(fit$fixed); missing trailing coefficients are zero. The variance of an estimate is
, where ,
and (Henderson's
mixed model equations). The F statistic of a contrast is
with the denominator degrees of freedom of the fit. Rows that are not estimable give NA.
A list of class c("vlm_estimate", "vlm_result", "list") with estimates (label, estimate,
standard error, df, t, p, confidence limits and inference space) and L; or of class
c("vlm_contrast", "vlm_result", "list") with contrasts (label, numerator and denominator df,
F and p).
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi. Sections 2.5 and 2.6.
McLean, R. A., Sanders, W. L. and Stroup, W. W. (1991). A unified approach to mixed linear models. The American Statistician, 45, 54-64.
Other VetResearchLMM inference:
emmeans_mixed_model(),
report_mixed_model(),
vlm_blup(),
vlm_lsmeans()
fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = NULL , bound = TRUE , control = list() ) # Example 2.5.3.1: ESTIMATE statements (levels: Drug BERENIL samorin, dose h l) es <- vlm_estimate( fit = fm , L = list( "drug dif" = list(Drug = c(-1, 1), "Drug:dose" = c(-0.5, -0.5, 0.5, 0.5)) , "Samorin mean" = list(Intercept = 1, Drug = c(0, 1), dose = c(0.5, 0.5), "Drug:dose" = c(0, 0, 0.5, 0.5)) , "Samorin HvsL" = list(dose = c(1, -1), "Drug:dose" = c(0, 0, 1, -1)) , "Samorin high" = list(Intercept = 1, Drug = c(0, 1), dose = c(1, 0), "Drug:dose" = c(0, 0, 1, 0)) ) , random = NULL , level = 0.95 ) es # Example 2.6.1: CONTRAST statements ct <- vlm_contrast( fit = fm , L = list( "drug dif" = list(Drug = c(-1, 1), "Drug:dose" = c(-0.5, -0.5, 0.5, 0.5)) , "all" = list( list(Drug = c(1, -1), "Drug:dose" = c(0.5, 0.5, -0.5, -0.5)) , list(dose = c(1, -1), "Drug:dose" = c(0.5, -0.5, 0.5, -0.5)) , list("Drug:dose" = c(0.5, -0.5, -0.5, 0.5)) ) ) ) ctfm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = NULL , bound = TRUE , control = list() ) # Example 2.5.3.1: ESTIMATE statements (levels: Drug BERENIL samorin, dose h l) es <- vlm_estimate( fit = fm , L = list( "drug dif" = list(Drug = c(-1, 1), "Drug:dose" = c(-0.5, -0.5, 0.5, 0.5)) , "Samorin mean" = list(Intercept = 1, Drug = c(0, 1), dose = c(0.5, 0.5), "Drug:dose" = c(0, 0, 0.5, 0.5)) , "Samorin HvsL" = list(dose = c(1, -1), "Drug:dose" = c(0, 0, 1, -1)) , "Samorin high" = list(Intercept = 1, Drug = c(0, 1), dose = c(1, 0), "Drug:dose" = c(0, 0, 1, 0)) ) , random = NULL , level = 0.95 ) es # Example 2.6.1: CONTRAST statements ct <- vlm_contrast( fit = fm , L = list( "drug dif" = list(Drug = c(-1, 1), "Drug:dose" = c(-0.5, -0.5, 0.5, 0.5)) , "all" = list( list(Drug = c(1, -1), "Drug:dose" = c(0.5, 0.5, -0.5, -0.5)) , list(dose = c(1, -1), "Drug:dose" = c(0.5, -0.5, 0.5, -0.5)) , list("Drug:dose" = c(0.5, -0.5, -0.5, 0.5)) ) ) ) ct
Fits the linear mixed model by restricted maximum likelihood (REML), maximum likelihood (ML) or the method of moments on Type 3
mean squares, and gives the results of SAS PROC MIXED: covariance parameter estimates with standard errors, the
solution for the fixed effects in the overparameterised coding, Type 3 (or Type 1) tests with containment,
residual, between-within, Satterthwaite or Kenward-Roger denominator degrees of freedom, and fit statistics. It is
the engine behind every analysis of the book of Duchateau, Janssen and Rowlands (1998).
vlm_fit( fixed, data, random = NULL, repeated = NULL, method = c("REML", "ML", "Type3"), ddfm = c("default", "contain", "residual", "betwithin", "satterth", "kr"), type = 3, class = NULL, bound = TRUE, control = list() ) ## Default S3 method: vlm_fit( fixed, data, random = NULL, repeated = NULL, method = c("REML", "ML", "Type3"), ddfm = c("default", "contain", "residual", "betwithin", "satterth", "kr"), type = 3, class = NULL, bound = TRUE, control = list() )vlm_fit( fixed, data, random = NULL, repeated = NULL, method = c("REML", "ML", "Type3"), ddfm = c("default", "contain", "residual", "betwithin", "satterth", "kr"), type = 3, class = NULL, bound = TRUE, control = list() ) ## Default S3 method: vlm_fit( fixed, data, random = NULL, repeated = NULL, method = c("REML", "ML", "Type3"), ddfm = c("default", "contain", "residual", "betwithin", "satterth", "kr"), type = 3, class = NULL, bound = TRUE, control = list() )
fixed |
two-sided formula of the response and the fixed effects, such as |
data |
a data frame (or |
random |
|
repeated |
|
method |
|
ddfm |
denominator degrees of freedom: |
type |
type of the tests of fixed effects: 3 (default) or 1 (sequential). |
class |
optional character vector of numeric variables to treat as classification variables (factors), like the SAS CLASS statement. Non-numeric variables and the variables of random effects and subjects are always classification variables. |
bound |
logical; keep variance estimates non-negative (default |
control |
list with |
With and
independent, depends on the covariance
parameters . With and observations, the
REML log-likelihood is
with ; the ML log-likelihood drops the
third term and uses in the first. It is maximised by Newton steps with the average-information matrix
, where
and ,
with step halving and variances kept non-negative (unless bound = FALSE). The fixed effects are the
generalised least-squares solution
in the overparameterised coding (one column per level), with the generalised inverse that sets aliased levels to zero, as SAS does. Standard errors of the covariance parameters come from the observed information.
Type 3 tests use the sum-to-zero coding of each effect (the SAS Type 3 hypothesis when every cell is observed).
The denominator degrees of freedom (ddfm) are: "contain", the rank contribution of the random
effects that contain the fixed effect, or if none does;
"residual", ; "betwithin", the between- and
within-subject parts of the residual degrees of freedom; "satterth",
, with
the gradient of in and
the asymptotic covariance of (Giesbrecht and Burns 1985;
Fai and Cornelius 1996 for several rows); "kr", the adjusted covariance and scaled F of Kenward
and Roger (1997). "default" chooses as SAS: containment with random effects, between-within with a
residual structure only, residual otherwise.
Method "Type3" (random variance components only) equates the Type 3 mean squares of the random effects to
their expectations (vlm_ems()); negative solutions are set to zero.
A list of class c("vlm_fit", "vlm_result", "list") with covariance (covariance
parameter estimates, standard errors and Wald Z tests), fixed (solution for the fixed effects),
tests (tests of the fixed effects), fit (fit statistics) and dimensions; the call is kept
in attr(, "call"). Further analyses of the fit: vlm_lsmeans(),
vlm_estimate(), vlm_contrast(), vlm_blup(),
vlm_compare() and vlm_interpret().
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi.
Patterson, H. D. and Thompson, R. (1971). Recovery of inter-block information when block sizes are unequal. Biometrika, 58, 545-554.
Kenward, M. G. and Roger, J. H. (1997). Small sample inference for fixed effects from restricted maximum likelihood. Biometrics, 53, 983-997.
vlm_random, vlm_lsmeans, vlm_estimate,
vlm_ems
Other VetResearchLMM models:
vlm_compare(),
vlm_ems(),
vlm_random()
# Example 2.5.1.1: PROC MIXED; CLASS drug dose region; MODEL pcv = drug dose drug*dose / SOLUTION; # RANDOM region drug*region; fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = NULL , bound = TRUE , control = list() ) fm fm$covariance fm$fixed # Example 3.3, Model 2: first-order autoregressive residuals within an animal ar <- vlm_fit( fixed = PCV ~ breed + breed:time , data = ex33 , random = NULL , repeated = vlm_repeated( type = c("vc", "cs", "ar1", "sp_pow", "un")[3] , subject = ~ animal_id:breed , order = ~ time ) , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) ar$covariance ar$fit# Example 2.5.1.1: PROC MIXED; CLASS drug dose region; MODEL pcv = drug dose drug*dose / SOLUTION; # RANDOM region drug*region; fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = NULL , bound = TRUE , control = list() ) fm fm$covariance fm$fixed # Example 3.3, Model 2: first-order autoregressive residuals within an animal ar <- vlm_fit( fixed = PCV ~ breed + breed:time , data = ex33 , random = NULL , repeated = vlm_repeated( type = c("vc", "cs", "ar1", "sp_pow", "un")[3] , subject = ~ animal_id:breed , order = ~ time ) , method = "REML" , ddfm = "default" , type = 3 , class = NULL , bound = TRUE , control = list() ) ar$covariance ar$fit
vlm_interpret() turns a result of the package into a short report: a headline, findings, recommendations
and cautions, computed from its numbers, with the sources of the method. It covers vlm_fit(),
vlm_lsmeans(), vlm_estimate(), vlm_contrast(),
vlm_blup(), vlm_ems() and vlm_compare().
vlm_interpret(x, alpha = 0.05, top = 3L, ...) ## Default S3 method: vlm_interpret(x, alpha = 0.05, top = 3L, ...) ## S3 method for class 'vlm_interpretation' print(x, ...) ## S3 method for class 'vlm_interpretation' format(x, style = c("text", "markdown"), width = getOption("width", 80L), ...)vlm_interpret(x, alpha = 0.05, top = 3L, ...) ## Default S3 method: vlm_interpret(x, alpha = 0.05, top = 3L, ...) ## S3 method for class 'vlm_interpretation' print(x, ...) ## S3 method for class 'vlm_interpretation' format(x, style = c("text", "markdown"), width = getOption("width", 80L), ...)
x |
a result of a function of the package. |
alpha |
significance level used in the sentences (default 0.05). |
top |
number of levels named in the findings (default 3). |
... |
unused. |
style |
|
width |
line width of the text (default |
An object of class "vlm_interpretation": a list with analysis, title,
headline, findings, recommendations, cautions, facts (the numbers behind the
sentences), guide (how to read the method) and sources. format() gives it as text or
Markdown.
Muhammad Yaseen ([email protected])
Other VetResearchLMM utilities:
autoplot.vlm_result(),
vlm_app(),
vlm_cite(),
vlm_notation(),
vlm_reference(),
vlm_save(),
vlm_theme()
fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = NULL , bound = TRUE , control = list() ) vlm_interpret( x = fm , alpha = 0.05 , top = 3 )fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = NULL , bound = TRUE , control = list() ) vlm_interpret( x = fm , alpha = 0.05 , top = 3 )
Least-squares means (estimated marginal means) of a classification effect of a fitted model, with their standard errors, degrees of freedom and confidence limits, and optionally all pairwise differences with a multiple comparison adjustment: the LSMEANS statement of SAS PROC MIXED.
vlm_lsmeans( fit, specs, at = NULL, diff = FALSE, adjust = c("none", "tukey", "bonferroni", "sidak"), level = 0.95 ) ## Default S3 method: vlm_lsmeans( fit, specs, at = NULL, diff = FALSE, adjust = c("none", "tukey", "bonferroni", "sidak"), level = 0.95 )vlm_lsmeans( fit, specs, at = NULL, diff = FALSE, adjust = c("none", "tukey", "bonferroni", "sidak"), level = 0.95 ) ## Default S3 method: vlm_lsmeans( fit, specs, at = NULL, diff = FALSE, adjust = c("none", "tukey", "bonferroni", "sidak"), level = 0.95 )
fit |
a result of |
specs |
the effect: a character string such as |
at |
optional named list of covariate values (default: the means of the covariates). |
diff |
logical; also give all pairwise differences (default |
adjust |
multiple comparison adjustment of the differences: |
level |
confidence level (default 0.95). |
The least-squares mean of a level combination is , where
has 1 for the intercept and the matching levels, equal weights over the
levels (or cells) of the other factors of each effect, and the mean of each covariate (or the value in
at) for covariate columns. Its variance is , the broad-inference-space variance. Non-estimable means are
returned as NA. With adjust = "tukey", p-values of the differences come from the studentised range
distribution (Tukey-Kramer), , and the confidence limits use
.
A list of class c("vlm_lsmeans", "vlm_result", "list") with lsmeans, diffs
(NULL unless diff = TRUE) and L (the coefficient rows).
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi. Sections 2.5.2 and 3.3.
Searle, S. R., Speed, F. M. and Milliken, G. A. (1980). Population marginal means in the linear model: an alternative to least squares means. The American Statistician, 34, 216-221.
Other VetResearchLMM inference:
emmeans_mixed_model(),
report_mixed_model(),
vlm_blup(),
vlm_estimate()
fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = NULL , bound = TRUE , control = list() ) # Example 2.5.2.1: LSMEANS drug*dose lm1 <- vlm_lsmeans( fit = fm , specs = ~ Drug:dose , at = NULL , diff = TRUE , adjust = "tukey" , level = 0.95 ) lm1fm <- vlm_fit( fixed = Pcv ~ Drug + dose + Drug:dose , data = ex125 , random = ~ Region + Region:Drug , repeated = NULL , method = "REML" , ddfm = "satterth" , type = 3 , class = NULL , bound = TRUE , control = list() ) # Example 2.5.2.1: LSMEANS drug*dose lm1 <- vlm_lsmeans( fit = fm , specs = ~ Drug:dose , at = NULL , diff = TRUE , adjust = "tukey" , level = 0.95 ) lm1
The symbols used in the help pages and vignettes of VetResearchLMM, with their meaning and the argument or result
component that holds them. The notation follows one rule throughout: scalars are upper-case letters in normal
face (, ), indices lower-case italic (), vectors lower-case bold
(, ) and matrices upper-case bold (,
).
vlm_notation(format = c("table", "path", "tex"))vlm_notation(format = c("table", "path", "tex"))
format |
|
See format.
Muhammad Yaseen ([email protected])
Other VetResearchLMM utilities:
autoplot.vlm_result(),
vlm_app(),
vlm_cite(),
vlm_interpret(),
vlm_reference(),
vlm_save(),
vlm_theme()
vlm_notation( format = "table" )vlm_notation( format = "table" )
vlm_random() declares random coefficients for a subject (the RANDOM ... / SUBJECT= TYPE= statement
of SAS PROC MIXED), and vlm_repeated() declares the covariance structure of the residuals within a subject
(the REPEATED / SUBJECT= TYPE= statement). Both are passed to vlm_fit().
vlm_random(effects = ~1, subject, type = c("vc", "un")) vlm_repeated( type = c("vc", "cs", "ar1", "sp_pow", "un"), subject, order = NULL )vlm_random(effects = ~1, subject, type = c("vc", "un")) vlm_repeated( type = c("vc", "cs", "ar1", "sp_pow", "un"), subject, order = NULL )
effects |
one-sided formula of the random coefficients, such as |
subject |
one-sided formula of the subject, such as |
type |
|
order |
one-sided formula of the time (or order) variable within a subject, such as |
A random coefficient specification adds, for subject with design rows (the
values of effects for observation ), the term with
independent between subjects. With type = "vc",
is diagonal (one variance per effect); with type = "un" it is unstructured and its
parameters are reported as , , , ..., as in SAS.
The residual structures for the observations of one subject, with the order (or time) of observation
, are
where is the rank of among the distinct times in the data, a matrix of ones
and the compound-symmetry covariance. Observations of different subjects are independent.
An object of class vlm_random or vlm_repeated: a list with the arguments.
Muhammad Yaseen ([email protected])
Duchateau, L., Janssen, P. and Rowlands, G. J. (1998). Linear Mixed Models. An Introduction with Applications in Veterinary Research. International Livestock Research Institute, Nairobi. Section 3.4.
Littell, R. C., Milliken, G. A., Stroup, W. W. and Wolfinger, R. D. (1996). SAS System for Mixed Models. SAS Institute, Cary, NC.
Other VetResearchLMM models:
vlm_compare(),
vlm_ems(),
vlm_fit()
# random intercept and slope per animal, unstructured covariance (Example 3.3, Model 3) ri <- vlm_random( effects = ~ 1 + time , subject = ~ animal_id:breed , type = "un" ) ri # first-order autoregressive residuals within an animal (Example 3.3, Model 2) ar <- vlm_repeated( type = "ar1" , subject = ~ animal_id:breed , order = ~ time ) ar# random intercept and slope per animal, unstructured covariance (Example 3.3, Model 3) ri <- vlm_random( effects = ~ 1 + time , subject = ~ animal_id:breed , type = "un" ) ri # first-order autoregressive residuals within an animal (Example 3.3, Model 2) ar <- vlm_repeated( type = "ar1" , subject = ~ animal_id:breed , order = ~ time ) ar
Reads inst/extdata/reference.csv: one row per published number, with its source, the R call
that recomputes it with this package (call), the expression that extracts the number from the result
(extract, in terms of x), the printed value and the digits to compare. The same file drives the test
of published values and the vignette that reproduces the published examples. Each distinct call is evaluated once.
vlm_reference(source = NULL, evaluate = FALSE, level = 1)vlm_reference(source = NULL, evaluate = FALSE, level = 1)
source |
optional regular expression; keep rows whose |
evaluate |
logical; evaluate the rows and add columns |
level |
largest |
A data.table with columns id, source, quantity, call, extract,
value, digits, level, note (and computed, agrees).
Muhammad Yaseen ([email protected])
Other VetResearchLMM utilities:
autoplot.vlm_result(),
vlm_app(),
vlm_cite(),
vlm_interpret(),
vlm_notation(),
vlm_save(),
vlm_theme()
ref <- vlm_reference( source = NULL , evaluate = FALSE , level = 1 ) ref vlm_reference( source = "." , evaluate = TRUE , level = 1 )ref <- vlm_reference( source = NULL , evaluate = FALSE , level = 1 ) ref vlm_reference( source = "." , evaluate = TRUE , level = 1 )
A wrapper of ggsave with the defaults of the package: a vector PDF through
cairo_pdf (embedded fonts, correct glyphs), A4 landscape (11.69 x 8.27 inches) and 600
dpi for raster formats. The device follows the file extension for other formats (.png, .svg,
.tiff, ...).
vlm_save( plot = ggplot2::last_plot(), filename, path = NULL, width = 11.69, height = 8.27, units = c("in", "cm", "mm"), dpi = 600, scale = 1, device = NULL, limitsize = TRUE, ... ) ## Default S3 method: vlm_save( plot = ggplot2::last_plot(), filename, path = NULL, width = 11.69, height = 8.27, units = c("in", "cm", "mm"), dpi = 600, scale = 1, device = NULL, limitsize = TRUE, ... )vlm_save( plot = ggplot2::last_plot(), filename, path = NULL, width = 11.69, height = 8.27, units = c("in", "cm", "mm"), dpi = 600, scale = 1, device = NULL, limitsize = TRUE, ... ) ## Default S3 method: vlm_save( plot = ggplot2::last_plot(), filename, path = NULL, width = 11.69, height = 8.27, units = c("in", "cm", "mm"), dpi = 600, scale = 1, device = NULL, limitsize = TRUE, ... )
plot |
a |
filename |
file name; its extension chooses the format. |
path |
directory to save in (default |
width, height
|
size (default 11.69 x 8.27, A4 landscape, in |
units |
|
dpi |
resolution for raster formats (default 600). |
scale |
multiplicative scaling factor (default 1). |
device |
|
limitsize |
logical; refuse images larger than 50 x 50 inches (default |
... |
passed to |
The file name, invisibly.
Muhammad Yaseen ([email protected])
Other VetResearchLMM utilities:
autoplot.vlm_result(),
vlm_app(),
vlm_cite(),
vlm_interpret(),
vlm_notation(),
vlm_reference(),
vlm_theme()
library(ggplot2) p <- ggplot(data = data.frame(x = 1:10, y = (1:10)^2), mapping = aes(x = x, y = y)) + geom_line() + vlm_theme( base_size = 11 , base_family = "serif" , ticks_inward = TRUE , legend_position = "bottom" ) f <- tempfile(fileext = ".pdf") vlm_save( plot = p , filename = f , path = NULL , width = 11.69 , height = 8.27 , units = c("in", "cm", "mm")[1] , dpi = 600 , scale = 1 , device = NULL , limitsize = TRUE ) vlm_save( plot = p , filename = basename(f) , path = tempdir() , width = 11.69 , height = 8.27 , units = c("in", "cm", "mm")[1] , dpi = 600 , scale = 1 , device = grDevices::cairo_pdf , limitsize = TRUE ) vlm_save( plot = p , filename = tempfile(fileext = ".png") , path = NULL , width = 6 , height = 4 , units = c("in", "cm", "mm")[1] , dpi = 300 , scale = 1 , device = NULL , limitsize = TRUE )library(ggplot2) p <- ggplot(data = data.frame(x = 1:10, y = (1:10)^2), mapping = aes(x = x, y = y)) + geom_line() + vlm_theme( base_size = 11 , base_family = "serif" , ticks_inward = TRUE , legend_position = "bottom" ) f <- tempfile(fileext = ".pdf") vlm_save( plot = p , filename = f , path = NULL , width = 11.69 , height = 8.27 , units = c("in", "cm", "mm")[1] , dpi = 600 , scale = 1 , device = NULL , limitsize = TRUE ) vlm_save( plot = p , filename = basename(f) , path = tempdir() , width = 11.69 , height = 8.27 , units = c("in", "cm", "mm")[1] , dpi = 600 , scale = 1 , device = grDevices::cairo_pdf , limitsize = TRUE ) vlm_save( plot = p , filename = tempfile(fileext = ".png") , path = NULL , width = 6 , height = 4 , units = c("in", "cm", "mm")[1] , dpi = 300 , scale = 1 , device = NULL , limitsize = TRUE )
The theme used by every plot() method of VetResearchLMM (identical in all packages of the
author): theme_classic with a serif font, black axis lines, ticks pointing inwards and no
grid, close to the look of TikZ/pgfplots figures in LaTeX documents. The plot() methods also use
scales::pretty_breaks(n = 10) on every continuous axis. Save figures with vlm_save.
vlm_theme( base_size = 11, base_family = "serif", ticks_inward = TRUE, legend_position = "bottom" )vlm_theme( base_size = 11, base_family = "serif", ticks_inward = TRUE, legend_position = "bottom" )
base_size |
base font size in points (default 11). |
base_family |
font family (default |
ticks_inward |
logical; ticks point into the panel, as in pgfplots (default |
legend_position |
position of the legend (default |
A ggplot2 theme.
Muhammad Yaseen ([email protected])
Other VetResearchLMM utilities:
autoplot.vlm_result(),
vlm_app(),
vlm_cite(),
vlm_interpret(),
vlm_notation(),
vlm_reference(),
vlm_save()
library(ggplot2) p <- ggplot(data = data.frame(x = 1:20, y = cumsum(sin(1:20))), mapping = aes(x = x, y = y)) + geom_line() p + vlm_theme( base_size = 11 , base_family = "serif" , ticks_inward = TRUE , legend_position = "bottom" ) p + vlm_theme( base_size = 12 , base_family = "serif" , ticks_inward = FALSE , legend_position = "right" ) + scale_x_continuous(breaks = scales::pretty_breaks(n = 10))library(ggplot2) p <- ggplot(data = data.frame(x = 1:20, y = cumsum(sin(1:20))), mapping = aes(x = x, y = y)) + geom_line() p + vlm_theme( base_size = 11 , base_family = "serif" , ticks_inward = TRUE , legend_position = "bottom" ) p + vlm_theme( base_size = 12 , base_family = "serif" , ticks_inward = FALSE , legend_position = "right" ) + scale_x_continuous(breaks = scales::pretty_breaks(n = 10))
The analysis functions of VetResearchLMM return the named list they have always returned, now with the class
c("vlm_<analysis>", "vlm_result", "list"). Components are read as before (x$ANOVA,
x[["Means"]]); the methods below print, summarise and plot the result and turn any component into a
data.table.
## S3 method for class 'vlm_result' print(x, digits = 4L, ...) ## S3 method for class 'vlm_result' summary(object, ...) ## S3 method for class 'summary.vlm_result' print(x, ...) ## S3 method for class 'vlm_result' format(x, ...) ## S3 method for class 'vlm_result' as.data.table(x, keep.rownames = FALSE, ..., component = 1L) ## S3 method for class 'vlm_result' as.data.frame(x, row.names = NULL, optional = FALSE, ..., component = 1L) ## S3 method for class 'vlm_result' plot(x, ...)## S3 method for class 'vlm_result' print(x, digits = 4L, ...) ## S3 method for class 'vlm_result' summary(object, ...) ## S3 method for class 'summary.vlm_result' print(x, ...) ## S3 method for class 'vlm_result' format(x, ...) ## S3 method for class 'vlm_result' as.data.table(x, keep.rownames = FALSE, ..., component = 1L) ## S3 method for class 'vlm_result' as.data.frame(x, row.names = NULL, optional = FALSE, ..., component = 1L) ## S3 method for class 'vlm_result' plot(x, ...)
x, object
|
a VetResearchLMM result. |
digits |
significant digits of printed numbers (default 4). |
... |
passed on (to |
keep.rownames, row.names, optional
|
as in |
component |
name or number of the component to convert (default: the first one). |
print() returns x invisibly; summary() an object of class
summary.vlm_result; format() a character string; as.data.table() and
as.data.frame() the chosen component as a table; plot() a ggplot object.
Muhammad Yaseen ([email protected])