Learn R Programming

vcrpart (version 1.0-7)

olmm-methods: Methods for olmm objects

Description

Standard methods for computing on olmm objects.

Usage

# S3 method for olmm
anova(object, ...,
        boot = FALSE, boot.nsim = 199, boot.type = c("parametric"),
        boot.mc.cores = 1)

# S3 method for olmm coef(object, which = c("all", "fe"), ...)

# S3 method for olmm fixef(object, which = c("all", "ce", "ge"), ...)

# S3 method for olmm model.matrix(object, which = c("fe", "fe-ce", "fe-ge", "re", "re-ce", "re-ge"), ...)

# S3 method for olmm neglogLik2(object, ...)

# S3 method for olmm ranef(object, norm = FALSE, ...)

# S3 method for olmm ranefCov(object, ...)

# S3 method for olmm simulate(object, nsim = 1, seed = NULL, newdata = NULL, ranef = TRUE, ranef.simulate = TRUE,...)

# S3 method for olmm terms(x, which = c("fe-ce", "fe-ge", "re-ce", "re-ge"), ...)

# S3 method for olmm VarCorr(x, sigma = 1., ...)

# S3 method for olmm weights(object, level = c("observation", "subject"), ...)

Value

The anova.olmm method returns an object of class

anova, see also anova.

The coef.olmm, coefficients.olmm,

fixef, fixef.glm and

fixef.olmm methods return named numeric

vectors. See also coef and

coefficients.

The deviance.olmm method returns a single numeric, see also deviance.

The formula.olmm method extracts the model formula, which is an object of class formula. See also

formula.

The getCall.olmm method extracts the call for fitting the model, which is an object of class call. See also

call.

The logLik.olmm method returns an object of class

logLik, which is a single numeric with a few attributes. See also logLik.

The neglogLik2 and neglogLik2.olmm

methods return a single numeric.

The model.frame.olmm and

model.matrix.olmm methods return the model frame and the model matrix of the olmm object. See also

model.frame and model.matrix.

The ranef and ranef.olmm methods return a matrix with the estimated random effects.

The ranefCov and ranefCov.olmm

methods return an object of class matrix. The

VarCorr and VarCorr.olmm methods return an object of class

VarCorr.olmm. print.VarCorr.olmm returns an object of class VarCorr.olmm.

The resid.olmm and residuals.olmm

methods return a numeric vector.

The simulate.olmm method returns a data.frame

including simulated responses based on the input model.

The terms.olmm method returns an object of class

terms. See also terms.

The update.olmm method will update and (by default) re-fit a model. It returns an object of class olmm. See also

update.

The vcov.olmm method extracts a matrix with the variances and covariances of the fixed effects of the model. See also vcov.

The weights.olmm method extracts a numeric

vector with the model weights. See also weights.

Arguments

object, x

an olmm object.

boot

single logical. Whether or not performing bootstrap.

boot.nsim

single integer. Number of bootstrap iterations.

boot.type

type of bootstrap. Currently, only parametric bootstrap is available (boot.type = "parametric"). See details.

boot.mc.cores

single integer. The number of cpus used for bootstrap computations using the mclapply function of the parallel package. This may not work for Windows computers.

which

optional character string. For coef and fixef, it indicates whether "all" coefficients, the fixed effects "fe", the category-specific fixed effects "ce" (i.e. non-proportional odds) or the global fixed effects "ge" (i.e. proportional odds) should be extracted. For model.matrix it indicates whether the model matrix of the fixed- ("fe") or the random effects ("re") should be extracted.

level

character string. Whether the results should be on the observation level (level = "observation") or on the subject level (level = "subject").

norm

logical. Whether residuals should be divided by their standard deviation.

nsim

number of response vectors to simulate. Defaults to 1.

seed

an object specifying if and how the random number generator should be initialized. See simulate

newdata

a data frame with predictor variables.

ranef

either a logical or a matrix (see predict.olmm). Whether the simulated responses should be conditional on random effects. If TRUE, the newdata data frame must contain the subject identification variable. If ranef is set to TRUE combined with ranef.simulate = FALSE, then the estimated random effects are used for simulation. In these cases, value 0 is used as random effects for new subjects, i.e. subjects that are not known for the estimated model. If ranef.simulate = TRUE, then simulated random effects are used, see below. For user specific settings, use the option of assigning a matrix. Note that ranef = FALSE results simulated data based on population-averaged response probabilities, which might not be meaningful in any situation.

ranef.simulate

single logical. Whether random effects should be simulated according to the model assumtions. If so, then estimated random effects will be ignored.

sigma

ignored but obligatory argument from original generic.

...

potential further arguments passed to methods.

Author

Reto Burgin

Details

The function anova performs likelihood ratio tests for comparing statistical models, based on their marginal likelihoods. Currently, at least two models must be provided for comparison. To enable parametric bootstrap, set boot = TRUE and specify the number of simulations using boot.nsim, for example boot.nsim = 999. To speed up computations, you can enable parallel processing by setting boot.mc.cores to a value greater than 1. Note that parallel computing may not be supported on Windows systems (see mclapply for details). The implemented parametric bootstrap procedure is based on the data provided for estimating the model. It generates synthetic datasets by simulating random effects and response variables using the parameter estimates from the fitted models.

neglogLik2 returns the marginal maximum likelihood of the fitted model times minus 2.

ranefCov extracts the variance-covariance matrix of the random effects. Similarly, VarCorr extracts the estimated variances, standard deviations and correlations of the random effects.

resid extracts the residuals of Li and Sheperd (2012). By default, the marginal outcome distribution is used to compute these residuals. The conditional residuals can be computed by assigning ranef = TRUE as a supplementary argument.

simulate simulates responses based on the input model. Make sure that the arguments ranef and ranef.simulate are set appropriately. By default, responses are simulated conditionally on simulated random effects.

Further, undocumented methods are deviance, extractAIC, fitted, formula, getCall, logLik, model.frame, nobs, update, vcov.

The anova implementation is based on codes of the lme4 package. The authors are grateful for these codes.

References

Agresti, A. (2010). Analysis of Ordinal Categorical Data (2 ed.). New Jersey, USA: John Wiley & Sons.

Tutz, G. (2012). Regression for Categorical Data. New York, USA: Cambridge Series in Statistical and Probabilistic Mathematics.

Li, C. and B. E. Sheperd (2012). A New Residual for Ordinal Outcomes, Biometrika, 99(2), 437--480.

Bates, D., M. Maechler, B. M. Bolker and S. Walker (2015). Fitting Linear Mixed-Effects Models Using lme4, Journal of Statistical Software, 67(1), 1--48.

See Also

olmm, predict.olmm, olmm_gefp

Examples

Run this code
## --------------------------------------------------------- #
## Example: Schizophrenia (see also example of 'olmm')
## --------------------------------------------------------- #

data(schizo)

schizo <- schizo[1:181,]
schizo$id <- droplevels(schizo$id)

## anova comparison
## ----------------

## fit two alternative models for the 'schizo' data
model.0 <- olmm(imps79o ~ tx + sqrt(week) + re(1|id), schizo)
model.1 <- olmm(imps79o ~ tx + sqrt(week) + tx * sqrt(week) + re(1|id), schizo)
anova(model.0, model.1)
# anova(model.0, model.1, boot = TRUE, boot.nsim = 499) # new bootstrap option (slow!)

## simulate responses
## ------------------

## simulate responses based on estimated random effects
simulate(model.0, newdata = schizo[1, ], ranef = TRUE, seed = 1)
simulate(model.0, newdata = schizo[1, ], seed = 1,
         ranef = ranef(model.0)[schizo[1, "id"], , drop=FALSE])
## simulate responses based on simulated random effects
newdata <- schizo[1, ]
newdata$id <- factor("123456789")
simulate(model.0, newdata = newdata, ranef = TRUE)

## other methods
## -------------

coef(model.1)
fixef(model.1)
head(model.matrix(model.1, "fe-ge"))
head(weights(model.1))
ranefCov(model.1)
head(resid(model.1))
terms(model.1, "fe-ge")
VarCorr(model.1)
head(weights(model.1, "subject"))

Run the code above in your browser using DataLab