| Title: | Singular Linear Models for Longitudinal Data |
| Version: | 0.1.1 |
| Description: | Fits singular linear models to longitudinal data. Singular linear models are useful when the number, or timing, of longitudinal observations may be informative about the observations themselves. They are described in Farewell (2010) <doi:10.1093/biomet/asp068>, and are extensions of the linear increments model <doi:10.1111/j.1467-9876.2007.00590.x> to general longitudinal data. |
| Depends: | R (≥ 3.2.0), data.table (≥ 1.9.6) |
| Imports: | stats, MASS (≥ 7.3) |
| Suggests: | lme4 (≥ 1.1), jmcm (≥ 0.1.6.0), gee (≥ 4.13-19), ggplot2(≥ 2.1.0), testthat (≥ 1.0.2), knitr, rmarkdown |
| License: | GPL-3 |
| LazyData: | true |
| RoxygenNote: | 6.0.1 |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2017-05-15 06:33:18 UTC; daniel |
| Author: | Daniel Farewell [aut, cre] |
| Maintainer: | Daniel Farewell <farewelld@cf.ac.uk> |
| Repository: | CRAN |
| Date/Publication: | 2017-05-15 06:39:33 UTC |
Singular linear models for longitudinal data.
Description
The slim package fits singular linear models to longitudinal data. Singularlinear models are useful when the number, or timing, of longitudinalobservations may be informative about the observations themselves. They aredescribed in Farewell (2010) <doi:10.1093/biomet/asp068>, and are extensionsof the linear increments model of Diggle et al. (2007)<doi:10.1111/j.1467-9876.2007.00590.x> to general longitudinal data.
Details
The most important function is slim, whose formula interface is similar tothat of lm.
See Also
Extract Model Coefficients from Singular Linear Model
Description
Extract Model Coefficients from Singular Linear Model
Usage
## S3 method for class 'slim'coef(object, ...)Arguments
object | an object of class 'slim', usually, a result of a call to'slim'. |
... | arguments passed to or from other methods. |
Value
a vector of model coefficients.
Laurent Expansion of Inverse of Linear Matrix Function
Description
This function computes the first two terms of the Laurent expansion of theinverse of a linear matrix function.
Usage
compute_laurent(V, zapsmall = TRUE)Arguments
V | for some integer m >= 1, an array of dimension (m, m, 2), where V[,, 1] is the intercept and V[, , 2] is the slope of the linear matrixfunction. |
zapsmall | logical: should zapsmall be called on the result? Default TRUE. |
Value
array of dimension (m, m, 2), where W[, , 1] corresponds to theexponent -1, and W[, , 2] corresponds to the exponent 0.
Confidence Intervals for Model Parameters from Singular Linear Model
Description
Confidence Intervals for Model Parameters from Singular Linear Model
Usage
## S3 method for class 'slim'confint(object, parm, level = 0.95, empirical = TRUE, ...)Arguments
object | an object of class 'slim', usually, a result of a call to'slim'. |
parm | a specification of which parameters are to be givenconfidence intervals, either a vector of numbers or a vector ofnames. If missing, all parameters are considered. |
level | the confidence level required. |
empirical | logical indicating if empirical variances of y should beused in estimating standard errors (the default). Empirical standard errorsshould be used unless covariances have been well modelled. |
... | arguments passed to or from other methods. |
Value
A matrix (or vector) with columns giving lower and upper confidencelimits for each parameter.
Renal Function in Three Groups of Peritoneal Dialysis Patients
Description
Longitudinal data on the renal function of 116 patients observed on up tofive different occasions.
Usage
dialysisFormat
A data.table with 116 rows and 5 variables:
| id | patient identifier, a character string |
| group | treatment group identifier, a character string |
| vintage | days since starting dialysis, an integer |
| month | month of observation, an integer |
| renalfn | renal function of the patient at that month, numeric |
Source
This data is derived from the Global Fluid Study. This part of thestudy was led by Dr James Chess and Prof. Nick Topley.
References
Lambie, M., Chess, J. et al. (2013). Independent effects ofsystemic and peritoneal inflammation on peritoneal dialysis survival. J AmSoc Nephrol, 24, 2071–80.
Fitter Function for Singular Linear Models
Description
This function computes the limiting solution to the estimating equationsum(x' V^-1 (y - x beta)) = 0 as the covariance V tends from V[, , 1] +V[, , 2] to V[, , 1].
Usage
fit_slim(x, V, y)Arguments
x | list of design matrices, one for each subject, all having the samenumber of columns. |
V | list of covariance arrays, one for each subject, matching thedimensions of y. |
y | list of response vectors, one for each subject. |
Value
a list with components coefficients (the limiting solution),residuals, fitted_values, vcov_empirical and vcov_modelled.
Extract Model Fitted Values from Singular Linear Model
Description
Extract Model Fitted Values from Singular Linear Model
Usage
## S3 method for class 'slim'fitted(object, ...)Arguments
object | an object of class 'slim', usually, a result of a call to'slim'. |
... | arguments passed to or from other methods. |
Value
a vector of fitted values from the model fit.
List Covariance Matrices for Every Subject
Description
This function is generic, and methods exists for character, list, function,and various model fit classes.
Usage
list_covariances(obj, t)## S3 method for class 'character'list_covariances(obj, t)## S3 method for class 'list'list_covariances(obj, t)## S3 method for class 'function'list_covariances(obj, t)## S3 method for class 'jmcmMod'list_covariances(obj, t)## S3 method for class 'lmerMod'list_covariances(obj, t)Arguments
obj | an R object of class character, function, or a model fit |
t | list of vectors of observation times, one for each subject |
Value
a list containing covariance matrices of appropriate dimensions
Model Predictions from Singular Linear Model
Description
Model Predictions from Singular Linear Model
Usage
## S3 method for class 'slim'predict(object, newdata, ...)Arguments
object | an object of class 'slim', usually, a result of a call to'slim'. |
newdata | An optional data frame in which to look for variables withwhich to predict. If omitted, the fitted values are used. |
... | arguments passed to or from other methods. |
Value
a vector of model predictions.
Print 'slim' Objects
Description
'print' methods for class 'slim' and 'slim_summary'. 'print.slim_summary'differs only in its default value of 'empirical'.
Usage
## S3 method for class 'slim'print(x, empirical = TRUE, digits = max(3, getOption("digits") - 3), signif.stars = getOption("show.signif.stars"), ...)## S3 method for class 'slim_summary'print(x, empirical = x$empirical, ...)Arguments
x | an object of class 'slim' or 'slim_summary', as appropriate. |
empirical | logical indicating if empirical variances of y should beused in estimating standard errors (the default). Empirical standard errorsshould be used unless covariances have been well modelled. |
digits | minimal number ofsignificant digits, see |
signif.stars | logical. If |
... | arguments passed to or from other methods. |
Value
x, invisibly.
Extract Model Residuals from Singular Linear Model
Description
Extract Model Residuals from Singular Linear Model
Usage
## S3 method for class 'slim'residuals(object, ...)Arguments
object | an object of class 'slim', usually, a result of a call to'slim'. |
... | arguments passed to or from other methods. |
Value
a vector of model residuals.
Fit Singular Linear Models
Description
Fit a singular linear model to longitudinal data.
Usage
slim(formula, data, covariance = "randomwalk", limit = ~1, contrasts = NULL)Arguments
formula | a model formula for the fixed effects |
data | a 'data.table' with two keys, respectively identifying subjectsand observation times |
covariance | an R object for which a 'list_covariances' method exists.Options include a character string such as "identity", "randomwalk" (thedefault), "brownian" or "pascal"; a list of covariance matrices; a functionto be used in 'outer' and applied to the observation times; or a 'jmcmMod'or 'lmerMod' model fit. |
limit | a one-sided model formula for the (thin) Cholesky factor of thelimiting covariance matrix (default ~ 1, so the limiting covariance matrixis the matrix of ones) |
contrasts | an optional list. See the 'contrasts.arg' argument of'model.matrix.default'. |
Value
an object of class 'slim'
Examples
slim_fit <- slim(renalfn ~ group + month, dialysis)summary(slim_fit)if(require("lme4")) { lmer_fit <- lmer(renalfn ~ group + month + (1 + month | id), dialysis) slim_fit <- slim(renalfn ~ 1 + group + month, dialysis, covariance = lmer_fit) summary(slim_fit) summary(slim_fit, empirical = FALSE)}if(require("jmcm")) { jmcm_fit <- jmcm(renalfn | id | month ~ group | 1, dialysis, triple = rep(2L, 3), cov.method = "mcd") slim_fit <- slim(renalfn ~ group + month, dialysis, covariance = jmcm_fit) summary(slim_fit) summary(slim_fit, empirical = FALSE)}Methods for Singular Linear Model Fits
Description
Methods for Singular Linear Model Fits
Arguments
object | an object of class 'slim', usually, a result of a call to'slim'. |
empirical | logical indicating if empirical variances of y should beused in estimating standard errors (the default). Empirical standard errorsshould be used unless covariances have been well modelled. |
... | arguments passed to or from other methods. |
Summarizing Singular Linear Model Fits
Description
'summary' method for class 'slim'.
Usage
## S3 method for class 'slim'summary(object, empirical = TRUE, ...)Arguments
object | an object of class 'slim', usually, a result of a call to'slim'. |
empirical | logical indicating if empirical variances of y should beused in estimating standard errors (the default). Empirical standard errorsshould be used unless covariances have been well modelled. |
... | arguments passed to or from other methods. |
Value
an object with class c("slim_summary", "slim") and, in addition tothe usual 'slim' components, coefficient_matrix (the matrix of estimatedcoefficients, standard errors, z- and p-values) and empirical (logicalindicating if empirical standard errors have been used)
Extract Variance-Covariance Matrix from a 'slim' Object
Description
'vcov' method for class 'slim'.
Usage
## S3 method for class 'slim'vcov(object, empirical = TRUE, ...)Arguments
object | an object of class 'slim', usually, a result of a call to'slim'. |
empirical | logical indicating if empirical variances of y should beused in estimating standard errors (the default). Empirical standard errorsshould be used unless covariances have been well modelled. |
... | arguments passed to or from other methods. |
Value
a matrix of the estimated covariances between the parameterestimates.