| standardized-class {standardize} | R Documentation |
Class standardized containing regression variables in a standardized space.
Description
The standardize function returns a list of class
standardized, which has a print method,
and which can additionally be used to place new data into the same
standardized space as the data passed in the call to standardize
using the predict function.
The standardized list contains the following elements.
Details
- call
The call to
standardizewhich created the object.- scale
The
scaleargument tostandardize.- formula
The regression formula in standardized space (with new names) which can be used along with the
dataelement to fit regressions. It has an attributestandardized.scalewhich is the same as thescaleelement of the object (this allows users and package developers to write regression-fitting functions which can tell if the input is from astandardizedobject).- family
The regression family.
- data
A data frame containing the regression variables in a standardized space (renamed to have valid variable names corresponding to those in the
formulaelement).- offset
The offset passed through the
offsetargument tostandardize(scaled iffamily = gaussian), orNULLif theoffsetargument was not used.- pred
A list containing unevaluated calls which allow the
predictmethod to work.- variables
A data frame with the name of the original variable, the corresponding name in the standardized data frame and formula, and the class of the variable in the standardized data frame.
- contrasts
A named list of contrasts for all factors included as predictors, or
NULLif no predictors are factors.- groups
A named list of levels for random effects grouping factors, or
NULLif there are no random effects.
In the variables data frame, the Variable column contains the
name of the variable in the original formula passed to standardize.
The Standardized Name column contains the name of the variable in the standardized
formula and data frame. The original variable name is altered such that the
original name is still recoverable but is also a valid variable name for
regressions run using the formula and data elements of the
standardized object. For example, exp(x) would become
exp_x and log(x + 1) would become log_x.p.1. If
the indicator function is used, this can lead to a long and possibly
difficult to interpret name; e.g. I(x1 > 0 & x2 < 0) would become
I_x1.g.0.a.x2.l.0. In such cases, it is better to create the variable
explicitly in the data frame and give it a meaningful name; in this case,
something like mydata$x1Pos_x2Neg <- mydata$x1 > 0 & mydata$x2 < 0,
and then use x1Pos_x2Neg in the call to standardize.
The Class column in the variables data frame takes the
following values (except for non-gaussian responses, which are left
unaltered, and so may have a different class; the class for the response is
always preceded by response.).
- numeric
A numeric vector.
- poly
A numeric matrix resulting from a call to
poly.- scaledby
A numeric vector resulting from a call to
scale_by.- scaledby.poly
A numeric matrix resulting from a call to
polynested within a call toscale_by.- factor
An unordered factor.
- ordered
An ordered factor.
- group
A random effects grouping factor.
- offset
If the offset function was used within the formula passed to
standardize, then the variable is numeric and labeled asoffset. Theformulaelement of thestandardizeobject contains offset calls to ensure regression fitting functions use them properly. If theoffsetargument was used in the call tostandardize(rather than putting offset calls in the formula), then the offset is not in thevariablesdata frame (it is in theoffsetelement of thestandardizedobject).
The standardized object has a printing method which displays the call,
formula, and variable frame along with an explanation of the
standardization. The is.standardized function returns
TRUE if an object is the result of a call to standardize
and FALSE otherwise. The predict
method places new data into the same standardized space as the data
passed to the original standardize call.
Author(s)
Christopher D. Eager <eager.stats@gmail.com>