Determines effects of varying each of the given variables while all
others are held constant. This function is mainly used to produce
plots of residuals versus explanatory variables, also showing
component effects. It can handle a multivariate response fitted by
lm
.
fitcomp(object, data = NULL, vars=NULL, transformed=FALSE, se = FALSE,
xm = NULL, xfromdata = FALSE, noexpand=NULL, nxcomp = 51)
A list consisting of
component effects. A matrix, unless the response is multivariate, in which case it will be a 3-dimensional array.
the values of the x variables for which the effects have been calculated
the values at which the x variables are held fixed while one of them is varied
standard errors of the component effects, if required by the
argument se
. Same structure as comp
a model fit, result of a fitting function
data frame in which the variables are found.
If not provided, it is obtained from object
.
character vector of names of variables for which
components are required. Only variables that appear in data
will be used. If NULL
(the default), all variables in
data
are used.
logical: should components be calculated for
transformed explanatory variables? If TRUE
, the variables are
transformed as implied by the model.
if TRUE, standard errors will be returned
named vector of values of the fixed (central) point from
which the individual variables are varied in turn.
Defaults to the componentwise median of quantitative variables and
the modes of factors.
if TRUE, the components effects will be evaluated for
the data values in data
. Otherwise, the range of each
numerical variable is filled with nxcomp
equidistant points,
whereas for factors, all levels are used.
This is useful for residual plots with component effects.
vector determining which variables should not be ``filled in'', probably because they are used like factors. Either a character vector of variable names or a vector of logical or numerical values with names, in which case the names corresponding to positive values will be identified.
number of points used for each (quantitative) variable
if xfromdata
is FALSE
Werner A. Stahel, ETH Zurich
The component effect is defined as the curve of fitted values
obtained by varying the explanatory variable or term, keeping all the other
variables (terms) at their "central value" xm
(the mean of continuous variables
and the mode of factors).
data(d.blast)
t.r <- lm(log10(tremor)~location+log10(distance)+log10(charge), data=d.blast)
t.fc <- fitcomp(t.r,se=TRUE)
t.fc$comp[1:10,]
Run the code above in your browser using DataLab