simresiduals: Simulate Residuals

Description Usage Arguments Details Value Author(s) Examples

Description

Simulates residuals for a given normal regression model

Usage

1
2
3
4
5
6
simresiduals(object, ...)
## Default S3 method:
simresiduals(object, nrep=19, simfunction=NULL, stres=TRUE, ...)
## S3 method for class 'glm'
simresiduals(object, nrep=19, simfunction=NULL,
        glm.restype="working", ...)

Arguments

object

result of fitting a regression

nrep

number of replicates

simfunction

if a function, it is used to generate random values for the target variable, with three arguments, which will be fed by the number of observations, the fitted values, and object$sigma in the case of simresiduals.default, respectively.
If TRUE, the appropriate random number generator will be used.
If NULL (default) the standardized residuals of object will be randomly permuted in the case of simresiduals.default. For simresiduals.glm, this is the same as TRUE.

stres

logical: should standardized residuals be produced?

glm.restype

type of residuals to be generated (for glm) Warning: type "deviance" may produce NAs.

...

further arguments passed to forthcoming methods.

Details

The simulated residuals are obtained for the default method by replacing the response variable by permuted standardized residuals of the fitted regression, multiplied by the scale object\$sigma, then fitting the model to these residuals and getting the reseiduals from this new fit. This is repeated nrep times. If standarized residuals are not available, ordinary residuals are used.

For the glm method, the values of the response variable are obtained from simulating according to the model (binomial or Poisson), and the model is re-fitted to these generated values.

Value

A matrix of which each column contains an set of simulated residuals. If standardized residuals are available, attribute "stres" is the matrix containing corresponding standardized residuals.

Author(s)

Werner A. Stahel, ETH Zurich

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
data(d.blast)
r.blast <-
  regr(log10(tremor)~location+log10(distance)+log10(charge),
  data=d.blast)
r.simblast <- simresiduals(r.blast, nrep=5)
showd(r.simblast)
## --------------------------
data(d.babysurv)
r.babysurv <- regr( Survival~Weight+Age+Apgar1, data=d.babysurv)
r.simbs <- simresiduals(r.babysurv, nrep=5)
showd(r.simbs)

regr0 documentation built on May 2, 2019, 4:52 p.m.

Related to simresiduals in regr0...