simresiduals | R Documentation |
Simulates residuals for a given regression model
simresiduals(object, ...)
## Default S3 method:
simresiduals(object, nrep=19, simfunction=NULL,
stdresiduals = NULL, sigma = object$sigma, ...)
## S3 method for class 'glm'
simresiduals(object, nrep=19, simfunction=NULL,
glm.restype="working", ...)
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
|
stdresiduals |
logical: should standardized residuals be produced? |
sigma |
scale parameter to be used, defaults to
|
glm.restype |
type of residuals to be generated (for glm) Warning: type "deviance" may produce NAs. |
... |
further arguments passed to forthcoming methods. |
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.
A matrix of which each column contains an set of simulated residuals.
If standardized residuals are available,
attribute "stdresisduals"
is the matrix containing corresponding
standardized residuals.
Werner A. Stahel, ETH Zurich
data(d.blast)
r.blast <-
lm(log10(tremor)~location+log10(distance)+log10(charge),
data=d.blast)
r.simblast <- simresiduals(r.blast, nrep=5)
showd(r.simblast)
## --------------------------
data(d.babysurvival)
r.babysurv <- lm( Survival~Weight+Age+Apgar1, data=d.babysurvival)
r.simbs <- simresiduals(r.babysurv, nrep=5)
showd(r.simbs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.