R: Predict method for Winsorized linear model fits with mixed...

predict.lmeWinsor {fda} | R Documentation

## Predict method for Winsorized linear model fits with mixed effects

### Description

Model predictions for object of class 'lmeWinsor'.

### Usage

    ## S3 method for class 'lmeWinsor'
    predict(object, newdata, level=Q, asList=FALSE,
          na.action=na.fail, ...)

### Arguments

`object` | Object of class inheriting from 'lmeWinsor', representing a fitted linear mixed-effects model.
`newdata` | an optional data frame to be used for obtaining the predictions. All variables used in the fixed and random effects models, as well as the grouping factors, must be present in the data frame. If missing, the fitted values are returned.
`level` | an optional integer vector giving the level(s) of grouping to be used in obtaining the predictions. Level values increase from outermost to innermost grouping, with level zero corresponding to the population predictions. Defaults to the highest or innermost level of grouping.
`asList` | an optional logical value. If 'TRUE' and a single value is given in 'level', the returned object is a list with the predictions split by groups; else the returned value is either a vector or a data.frame, according to the length of 'level'.
`na.action` | a function that indicates what should happen when 'newdata' contains 'NA's. The default action ('na.fail') causes the function to print an error message and terminate if there are any incomplete observations.
`...` | additional arguments for other methods

### Details

1. Identify inputs and outputs as with lmeWinsor.

2. If 'newdata' are provided, clip all numeric xNames to (object[["lower"]], object[["upper"]]).

3. Call predict.lme

4. Clip the responses to the relevant components of (object[["lower"]], object[["upper"]]).

5. Done.

### Value

'predict.lmeWinsor' produces a vector of predictions or a matrix of predictions with limits or a list, as produced by predict.lme

### Author(s)

Spencer Graves

### See Also

`lmeWinsor` `predict.lme` `lmWinsor` `predict.lm`

### Examples

    requireNamespace('nlme')
    fm1w <- lmeWinsor(distance ~ age, data = nlme::Orthodont,
                     random=~age|Subject)
    # predict with newdata
    newDat <- data.frame(age=seq(0, 30, 2),
               Subject=factor(rep("na", 16)) )
    pred1w <- predict(fm1w, newDat, level=0)

    # fit with 10 percent Winsorization
    fm1w.1 <- lmeWinsor(distance ~ age, data = nlme::Orthodont,
                     random=~age|Subject, trim=0.1)
    pred30 <- predict(fm1w.1)
    stopifnot(all.equal(as.numeric(
                  quantile(nlme::Orthodont$distance, c(.1, .9))),
              range(pred30)) )

[Package fda version 2.4.8 Index]