orsf_scale_cph {aorsf} | R Documentation |
These functions are exported so that users may access internal routines that are used to scale inputs when orsf_control_cph is used.
orsf_scale_cph(x_mat, w_vec = NULL)
orsf_unscale_cph(x_mat)
x_mat |
(numeric matrix) a matrix with values to be scaled or
unscaled. Note that |
w_vec |
(numeric vector) an optional vector of weights. If no weights
are supplied (the default), all observations will be equally weighted. If
supplied, |
The data are transformed by first subtracting the mean and then
multiplying by the scale. An inverse transform can be completed using
orsf_unscale_cph
or by dividing each column by the corresponding scale
and then adding the mean.
The values of means and scales are stored in an attribute of the output
returned by orsf_scale_cph
(see examples)
the scaled or unscaled x_mat
.
x_mat <- as.matrix(pbc_orsf[, c('bili', 'age', 'protime')])
head(x_mat)
x_scaled <- orsf_scale_cph(x_mat)
head(x_scaled)
attributes(x_scaled) # note the transforms attribute
x_unscaled <- orsf_unscale_cph(x_scaled)
head(x_unscaled)
# numeric difference in x_mat and x_unscaled should be practically 0
max(abs(x_mat - x_unscaled))