Pinheiro, et al. 2017. nlme: Linear and Nonlinear Mixed Effects Models. R package version 3.1-128. Retrieved from: http://CRAN.R-project.org/package=nlme
Other documents for the same rulemaking
References: 106 extracted, 29 linked to papers
Box, G.E.P., Jenkins, G.M., and Reinsel G.C. (1994) "Time Series Analysis: Forecasting and Control", 3rd Edition, Holden-Day.
Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models in S and S-PLUS", Springer. See Also
Ovary, random = ~ sin(2*pi*Time) | Mare) ACF(fm1, maxLag = 11) # Pinheiro and Bates, p240-241 fm1Over.lme <- lme(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), data=Ovary, random=pdDiag(~sin(2*pi*Time)) ) (ACF.fm1Over <- ACF(fm1Over.lme, maxLag=10)) plot(ACF.fm1Over, alpha=0.01) allCoef Alfalfa Split-Plot Experiment on Varieties of Alfalfa Description The Alfalfa data frame has 72 rows and 4 columns. Format This data frame contains the following columns: Variety a factor with levels Cossack, Ladak, and Ranger Date a factor with levels None S1 S20 O7 Block a factor with levels 1 2 3 4 5 6 Yield a numeric vector Details These data are described in Snedecor and Cochran (1980) as an example of a split-plot design. The treatment structure used in the experiment was a 3x4 full factorial, with three varieties of alfalfa and four dates of third cutting in 1943. The experimental units were arranged into six blocks, each subdivided into four plots. The varieties of alfalfa (Cossac, Ladak, and Ranger) were assigned randomly to the blocks and the dates of third cutting (None, S1—September 1, S20—September 20, and O7—October 7) were randomly assigned to the plots. All four dates were used on each block. Source
M. (2000), Mixed-Effects Models in S and S-PLUS, Springer, New York. (Appendix A.1)
G. (1980), Statistical Methods (7th ed), Iowa State University
M. (2000), Mixed-Effects Models in S and S-PLUS, Springer, New York. See Also gls, gnls, lme, logLik.gls, AIC, BIC, print.anova.lme Examples # AR(1) errors within each Mare fm1 <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), Ovary, correlation = corAR1(form = ~ 1 | Mare)) anova(fm1) # variance changes with a power of the absolute fitted values? fm2 <- update(fm1, weights = varPower()) anova(fm1, fm2) # Pinheiro and Bates, p. 251-252 fm1Orth.gls <- gls(distance ~ Sex * I(age - 11), Orthodont, correlation = corSymm(form = ~ 1 | Subject), weights = varIdent(form = ~ 1 | age)) fm2Orth.gls <- update(fm1Orth.gls, corr = corCompSymm(form = ~ 1 | Subject)) anova(fm1Orth.gls, fm2Orth.gls) # Pinheiro and Bates, pp. 215-215, 255-260 #p. 215 fm1Dial.lme <lme(rate ~(pressure + I(pressure^2) + I(pressure^3) + I(pressure^4))*QB,
M. (2000), Mixed-Effects Models in S and S-PLUS, Springer, New York. See Also corClasses, corMatrix Examples cst1 <- corAR1(form = ~1|Subject) cst1 <- Initialize(cst1, data = Orthodont) as.matrix(cst1) as.matrix.pdMat Matrix of a pdMat Object Description This method function extracts the positive-definite matrix represented by x. Usage ## S3 method for class 'pdMat' as.matrix(x, ...) as.matrix.reStruct Arguments an object inheriting from class "pdMat", representing a positive-definite matrix. further arguments passed from other methods. Value a matrix corresponding to the positive-definite matrix represented by x. Author(s) José Pinheiro and Douglas Bates <bates@stat.wisc.edu> References
M. (2000), Mixed-Effects Models in S and S-PLUS, Springer, New York. See Also pdMat, corMatrix Examples as.matrix(pdSymm(diag(4))) as.matrix.reStruct Matrices of an reStruct Object Description This method function extracts the positive-definite matrices corresponding to the pdMat elements of object. Usage ## S3 method for class 'reStruct' as.matrix(x, ...) Arguments an object inheriting from class "reStruct", representing a random effects structure and consisting of a list of pdMat objects. further arguments passed from other methods. Value a list with components given by the positive-definite matrices corresponding to the elements of object. asOneFormula Author(s) José Pinheiro and Douglas Bates <bates@stat.wisc.edu> References
M. (2000), Mixed-Effects Models in S and S-PLUS, Springer, New York. (Appendix A.2) asTable asTable Convert groupedData to a matrix Description Create a tabular representation of the response in a balanced groupedData object. Usage asTable(object) Arguments object A balanced groupedData object Details A balanced groupedData object can be represented as a matrix or table of response values corresponding to the values of a primary covariate for each level of a grouping factor. This function creates such a matrix representation of the data in object. Value A matrix. The data in the matrix are the values of the response. The columns correspond to the distinct values of the primary covariate and are labelled as such. The rows correspond to the distinct levels of the grouping factor and are labelled as such. Author(s) José Pinheiro and Douglas Bates <bates@stat.wisc.edu> References
M. (2000), Mixed-Effects Models in S and S-PLUS, Springer, New York. See Also groupedData, isBalanced, balancedGrouped Examples asTable(Orthodont) # Pinheiro and Bates, p. 109 ergoStool.mat <- asTable(ergoStool) augPred augPred Augmented Predictions Description Predicted values are obtained at the specified values of primary. If object has a grouping structure (i.e. getGroups(object) is not NULL), predicted values are obtained for each group. If level has more than one element, predictions are obtained for each level of the max(level) grouping factor. If other covariates besides primary are used in the prediction model, their average (numeric covariates) or most frequent value (categorical covariates) are used to obtain the predicted values. The original observations are also included in the returned object. Usage augPred(object, primary, minimum, maximum, length.out, ...) ## S3 method for class 'lme' augPred(object, primary = NULL, minimum = min(primary), maximum = max(primary), length.out = 51, level = Q, ...) Arguments object a fitted model object from which predictions can be extracted, using a predict method. primary an optional one-sided formula specifying the primary covariate to be used to generate the augmented predictions. By default, if a covariate can be extracted from the data used to generate object (using getCovariate), it will be used as primary. minimum an optional lower limit for the primary covariate. Defaults to min(primary). maximum
M. (2000), Mixed-Effects Models in S and S-PLUS, Springer, New York. See Also plot.augPred, getGroups, predict Examples fm1 <- lme(Orthodont, random = ~1) augPred(fm1, length.out = 2, level = c(0,1)) balancedGrouped Create a groupedData object from a matrix Description Create a groupedData object from a data matrix. This function can be used only with balanced data. The opposite conversion, from a groupedData object to a matrix, is done with asTable. Usage balancedGrouped(form, data, labels=NULL, units=NULL) Arguments form data labels units A formula of the form y ~ x | g giving the name of the response, the primary covariate, and the grouping factor. A matrix or data frame containing the values of the response grouped according to the levels of the grouping factor (rows) and the distinct levels of the primary covariate (columns). The dimnames of the matrix are used to construct the levels of the grouping factor and the primary covariate. an optional list of character strings giving labels for the response and the primary covariate. The label for the primary covariate is named x and that for the response is named y. Either label can be omitted. an optional list of character strings giving the units for the response and the primary covariate. The units string for the primary covariate is named x and that for the response is named y. Either units string can be omitted. Value A balanced groupedData object. Author(s) José Pinheiro and Douglas Bates <bates@stat.wisc.edu>
M. (2000), Mixed-Effects Models in S and S-PLUS, Springer, New York. See Also groupedData, isBalanced, asTable Examples OrthoMat <- asTable( Orthodont ) Orth2 <- balancedGrouped(distance ~ age | Subject, data = OrthoMat, labels = list(x = "Age", y = "Distance from pituitary to pterygomaxillary fissure"), units = list(x = "(yr)", y = "(mm)")) Orth2[ 1:10, ] ## check the first few entries # Pinheiro and Bates, p. 109 ergoStool.mat <- asTable(ergoStool) balancedGrouped(effort~Type|Subject, data=ergoStool.mat) Language scores Description The bdf data frame has 2287 rows and 25 columns of language scores from grade 8 pupils in elementary schools in The Netherlands. Usage data(bdf) Format schoolNR a factor denoting the school. pupilNR a factor denoting the pupil.
Snijders, Tom and Bosker, Roel (1999), Multilevel Analysis: An Introduction to Basic and Advanced Multilevel Modeling, Sage. BodyWeight Examples summary(bdf) ## More examples, including lme() fits reproducing parts in the above ## book, are available in the R script files system.file("mlbook", "ch04.R", package ="nlme") # and system.file("mlbook", "ch05.R", package ="nlme") BodyWeight Rat weight over time for different diets Description The BodyWeight data frame has 176 rows and 4 columns. Format This data frame contains the following columns: weight a numeric vector giving the body weight of the rat (grams). Time a numeric vector giving the time at which the measurement is made (days). Rat an ordered factor with levels 2 < 3 < 4 < 1 < 8 < 5 < 6 < 7 < 11 < 9 < 10 < 12 < 13 < 15 < 14 < 16 identifying the rat whose weight is measured. Diet a factor with levels 1 to 3 indicating the diet that the rat receives. Details Hand and Crowder (1996) describe data on the body weights of rats measured over 64 days. These data also appear in Table 2.4 of Crowder and Hand (1990). The body weights of the rats (in grams) are measured on day 1 and every seven days thereafter until day 64, with an extra measurement on day 44. The experiment started several weeks before “day 1.” There are three groups of rats, each on a different diet. Source
M. (2000), Mixed-Effects Models in S and S-PLUS, Springer, New York. (Appendix A.3)
Crowder, M. and Hand, D. (1990), Analysis of Repeated Measures, Chapman and Hall, London.
Hand, D. and Crowder, M. (1996), Practical Longitudinal Data Analysis, Chapman and Hall, London. Cefamandole Cefamandole Pharmacokinetics of Cefamandole Description The Cefamandole data frame has 84 rows and 3 columns. Format This data frame contains the following columns: Subject a factor giving the subject from which the sample was drawn. Time a numeric vector giving the time at which the sample was drawn (minutes post-injection). conc a numeric vector giving the observed plasma concentration of cefamandole (mcg/ml). Details Davidian and Giltinan (1995, 1.1, p. 2) describe data obtained during a pilot study to investigate the pharmacokinetics of the drug cefamandole. Plasma concentrations of the drug were measured on six healthy volunteers at 14 time points following an intraveneous dose of 15 mg/kg body weight of cefamandole. Source
M. (2000), Mixed-Effects Models in S and S-PLUS, Springer, New York. (Appendix A.4)
M. (1995), Nonlinear Models for Repeated Measurement Data, Chapman and Hall, London. Examples plot(Cefamandole) fm1 <- nlsList(SSbiexp, data = Cefamandole) summary(fm1) Coef Assign Values to Coefficients Description This function is generic; method functions can be written to handle specific classes of objects. Classes which already have methods for this function include all "pdMat", "corStruct" and "varFunc" classes, "reStruct", and "modelStruct". coef.corStruct Usage coef(object, ...) <value Arguments object any object representing a fitted model, or, by default, any object with a coef component. some methods for this generic function may require additional arguments. value a value to be assigned to the coefficients associated with object. Value will depend on the method function; see the appropriate documentation. Author(s) José Pinheiro and Douglas Bates <bates@stat.wisc.edu> See Also coef Examples ## see the method function documentation coef.corStruct Coefficients of a corStruct Object Description This method function extracts the coefficients associated with the correlation structure represented by object. Usage ## S3 method for class 'corStruct' coef(object, unconstrained, ...) ## S3 replacement method for class 'corStruct' coef(object, ...) <- value coef.corStruct Arguments object an object inheriting from class "corStruct", representing a correlation structure. unconstrained a logical value. If TRUE the coefficients are returned in unconstrained form (the
M. (2000), Mixed-Effects Models in S and S-PLUS, Springer, New York. See Also corAR1, corARMA, corCAR1, corCompSymm, corExp, corGaus, corLin, corRatio, corSpatial, corSpher, corSymm,Initialize Examples cst1 <- corARMA(p = 1, q = 1) coef(cst1) coef.gnls coef.gnls Extract gnls Coefficients Description The estimated coefficients for the nonlinear model represented by object are extracted. Usage ## S3 method for class 'gnls' coef(object, ...) Arguments object an object inheriting from class "gnls", representing a generalized nonlinear least squares fitted model. some methods for this generic require additional arguments. None are used in this method. Value a vector with the estimated coefficients for the nonlinear model represented by object. Author(s) José Pinheiro and Douglas Bates <bates@stat.wisc.edu> See Also gnls Examples fm1 <- gnls(weight ~ SSlogis(Time, Asym, xmid, scal), Soybean, weights = varPower()) coef(fm1) coef.lme coef.lme Extract lme Coefficients Description The estimated coefficients at level i are obtained by adding together the fixed effects estimates and the corresponding random effects estimates at grouping levels less or equal to i. The resulting estimates are returned as a data frame, with rows corresponding to groups and columns to coefficients.
M. (2000), Mixed-Effects Models in S and S-PLUS, Springer, New
Pinheiro, J.C. and Bates., D.M. (1996) "Unconstrained Parametrizations for Variance-Covariance Matrices", Statistics and Computing, 6, 289-296. See Also pdMat Examples coef(pdSymm(diag(3))) coef.reStruct reStruct Object Coefficients Description This method function extracts the coefficients associated with the positive-definite matrix represented by object. Usage ## S3 method for class 'reStruct' coef(object, unconstrained, ...) ## S3 replacement method for class 'reStruct' coef(object, ...) <- value Arguments object an object inheriting from class "reStruct", representing a random effects structure and consisting of a list of pdMat objects. unconstrained a logical value. If TRUE the coefficients are returned in unconstrained form (the same used in the optimization algorithm). If FALSE the coefficients are returned in "natural", possibly constrained, form. Defaults to TRUE. value a vector with the replacement values for the coefficients associated with object. It must be a vector with the same length of coef(object) and must be given in unconstrained form. some methods for this generic require additional arguments. None are used in this method. coef.varFunc Value a vector with the coefficients corresponding to object.
Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models in S and S-PLUS", Springer, esp. pp. 235, 397. See Also
Jones, R.H. (1993) "Longitudinal Data with Serial Correlation: A State-space Approach", Chapman and Hall.
E. (1992) "Analysis of Messy Data, Volume I: Designed Experiments", Van Nostrand Reinhold.
Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models in S and S-PLUS", Springer, esp. pp. 233-234. See Also corClasses, Initialize.corStruct, summary.corStruct corExp Examples ## covariate is observation order and grouping factor is Subject cs1 <- corCompSymm(0.5, form = ~ 1 | Subject) # Pinheiro and Bates, pp. 222-225 fm1BW.lme <- lme(weight ~ Time * Diet, BodyWeight, random = ~ Time) # p. 223 fm2BW.lme <- update(fm1BW.lme, weights = varPower()) # p. 225 cs1CompSymm <- corCompSymm(value = 0.3, form = ~ 1 | Subject) cs2CompSymm <- corCompSymm(value = 0.3, form = ~ age | Subject) cs1CompSymm <- Initialize(cs1CompSymm, data = Orthodont) corMatrix(cs1CompSymm) corExp Exponential Correlation Structure Description This function is a constructor for the "corExp" class, representing an exponential spatial correlation structure. Letting d denote the range and n denote the nugget effect, the correlation between two observations a distance r apart is exp(−r/d) when no nugget effect is present and (1 − n) exp(−r/d) when a nugget effect is assumed. Objects created using this constructor must later be initialized using the appropriate Initialize method. Usage corExp(value, form, nugget, metric, fixed) Arguments value an optional vector with the parameter values in constrained form. If nugget is
Cressie, N.A.C. (1993), "Statistics for Spatial Data", J. Wiley & Sons.
Venables, W.N. and Ripley, B.D. (2002) "Modern Applied Statistics with S", 4th Edition, SpringerVerlag.
Littel, Milliken, Stroup, and Wolfinger (1996) "SAS Systems for Mixed Models", SAS Institute.
Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models in S and S-PLUS", Springer. See Also Initialize.corStruct, summary.corStruct, dist Examples sp1 <- corGaus(form = ~ x + y + z) # example lme(..., corGaus ...) # Pinheiro and Bates, pp. 222-249 fm1BW.lme <- lme(weight ~ Time * Diet, BodyWeight, random = ~ Time) # p. 223 fm2BW.lme <- update(fm1BW.lme, weights = varPower()) # p 246 fm3BW.lme <- update(fm2BW.lme, correlation = corExp(form = ~ Time)) # p. 249 fm8BW.lme <- update(fm3BW.lme, correlation = corGaus(form = ~ Time)) corLin corLin Linear Correlation Structure Description This function is a constructor for the corLin class, representing a linear spatial correlation structure. Letting d denote the range and n denote the nugget effect, the correlation between two observations a distance r < d apart is 1 − (r/d) when no nugget effect is present and (1 − n)(1 − (r/d)) when a nugget effect is assumed. If r ≥ d the correlation is zero. Objects created using this constructor must later be initialized using the appropriate Initialize method. Usage corLin(value, form, nugget, metric, fixed) Arguments value an optional vector with the parameter values in constrained form. If nugget is
Pinheiro, J.C. and Bates., D.M. (1996) "Unconstrained Parametrizations for Variance-Covariance Matrices", Statistics and Computing, 6, 289-296.
Bates, D.M. and Pinheiro, J.C. (1998) "Computational methods for multilevel models" available in PostScript or PDF formats at http://nlme.stat.wisc.edu/pub/NLME/
Bates, D.M. and Pinheiro, J.C. (1998) "Computational methods for multilevel models" available in PostScript or PDF formats at http://nlme.stat.wisc.edu/pub/NLME/ See Also nlme, residuals.nlmeStruct fixed.effects Extract Fixed Effects Description This function is generic; method functions can be written to handle specific classes of objects. Classes which already have methods for this function include lmList and lme. Usage fixed.effects(object, ...) fixef(object, ...) Arguments object any fitted model object from which fixed effects estimates can be extracted. some methods for this generic function require additional arguments. Value will depend on the method function used; see the appropriate documentation. References
Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models in S and S-PLUS", Springer, esp. sec. 3.4. See Also gsummary Gasoline Examples ## Find number of non-missing "conc" observations for each Subject gapply( Phenobarb, FUN = function(x) sum(!is.na(x$conc)) ) # Pinheiro and Bates, p. 127 table( gapply(Quinidine, "conc", function(x) sum(!is.na(x))) ) changeRecords <- gapply( Quinidine, FUN = function(frm) any(is.na(frm[["conc"]]) & is.na(frm[["dose"]])) ) Gasoline Refinery yield of gasoline Description The Gasoline data frame has 32 rows and 6 columns. Format This data frame contains the following columns: yield a numeric vector giving the percentage of crude oil converted to gasoline after distillation and fractionation endpoint a numeric vector giving the temperature (degrees F) at which all the gasoline is vaporized Sample an ordered factor giving the inferred crude oil sample number
Details Prater (1955) provides data on crude oil properties and gasoline yields.
Atkinson (1985) uses these data to illustrate the use of diagnostics in multiple regression analysis. Three of the covariates—
API, vapor, and ASTM—measure characteristics of the crude oil used to produce the gasoline. The other covariate — endpoint—is a characteristic of the refining process. Daniel and Wood (1980) notice that the covariates characterizing the crude oil occur in only ten distinct groups and conclude that the data represent responses measured on ten different crude oil samples. Source
H. (1955), Estimate gasoline yields from crudes, Petroleum Refiner, 35 (5).
C. (1985), Plots, Transformations, and Regression, Oxford Press, New York.
S. (1980), Fitting Equations to Data, Wiley, New York
D. (2002) Modern Applied Statistics with S (4th ed), Springer, New York. getCovariate getCovariate Extract Covariate from an Object Description This function is generic; method functions can be written to handle specific classes of objects. Classes which already have methods for this function include corStruct, corSpatial, data.frame, and varFunc. Usage getCovariate(object, form, data) Arguments object any object with a covariate component form an optional one-sided formula specifying the covariate(s) to be extracted. Defaults to formula(object). data a data frame in which to evaluate the variables defined in form. Value will depend on the method function used; see the appropriate documentation. Author(s) José Pinheiro and Douglas Bates <bates@stat.wisc.edu> References
Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models in S and S-PLUS", Springer, esp. p. 100. See Also getCovariate.corStruct, getCovariate.data.frame, getCovariate.varFunc, getCovariateFormula Examples ## see the method function documentation getCovariate.corStruct getCovariate.corStruct Extract corStruct Object Covariate Description This method function extracts the covariate(s) associated with object. Usage ## S3 method for class 'corStruct' getCovariate(object, form, data) Arguments object an object inheriting from class corStruct representing a correlation structure. form this argument is included to make the method function compatible with the generic. It will be assigned the value of formula(object) and should not be modified. data an optional data frame in which to evaluate the variables defined in form, in case object is not initialized and the covariate needs to be evaluated. Value when the correlation structure does not include a grouping factor, the returned value will be a vector or a matrix with the covariate(s) associated with object. If a grouping factor is present, the returned value will be a list of vectors or matrices with the covariate(s) corresponding to each grouping level. Author(s) José Pinheiro and Douglas Bates <bates@stat.wisc.edu> References
Wolfinger, R.D. (1996), and Venables, W.N. and Ripley, B.D. (2002). The use of variance functions for linear and nonlinear models is presented in detail in Carroll, R.J. and Ruppert, D. (1988) and
Davidian, M. and Giltinan, D.M. (1995). Box, G.E.P., Jenkins, G.M., and Reinsel G.C. (1994) "Time Series Analysis: Forecasting and Control", 3rd Edition, Holden-Day. glsControl
Carroll, R.J. and Ruppert, D. (1988) "Transformation and Weighting in Regression", Chapman and Hall.
Davidian, M. and Giltinan, D.M. (1995) "Nonlinear Mixed Effects Models for Repeated Measurement Data", Chapman and Hall.
Littel, R.C., Milliken, G.A., Stroup, W.W., and Wolfinger, R.D. (1996) "SAS Systems for Mixed Models", SAS Institute.
Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models in S and S-PLUS", Springer, esp. pp. 100, 461.
Wolfinger, R.D. (1996), and Venables, W.N. and Ripley, B.D. (2002). The use of variance functions for linear and nonlinear models is presented in detail in Carrol, R.J. and Rupert, D. (1988) and
Davidian, M. and Giltinan, D.M. (1995). Box, G.E.P., Jenkins, G.M., and Reinsel G.C. (1994) "Time Series Analysis: Forecasting and Control", 3rd Edition, Holden-Day. gnlsControl
Carrol, R.J. and Rupert, D. (1988) "Transformation and Weighting in Regression", Chapman and Hall.