mboost (version 0.5-4)

FP: Fractional Polynomials

Description

Fractional polynomials transformation for continuous covariates.

Usage

FP(x, p = c(-2, -1, -0.5, 0.5, 1, 2, 3))

Arguments

x
a numeric vector.
p
all powers of x to be included.

Value

  • A matrix including all powers p of x, all powers p of log(x) and log(x).

Details

A fractional polynomial refers to a model $\sum_{j = 1}^k (\beta_j x^{p_j} + \gamma_j x^{p_j} \log(x)) + \beta_{k + 1} \log(x) + \gamma_{k + 1} \log(x)^2$ where the degree of the fractional polynomial is the number of non-zero regression coefficients $\beta$ and $\gamma$. See mfp for the reference implementation. Currently, no scaling of x is implemented. However, one may wish to standardize the inputs prior to fitting the model.

References

Willi Sauerbrei and Patrick Royston (1999), Building multivariable prognostic and diagnostic models: transformation of the predictors by using fractional polynomials. Journal of the Royal Statistical Society A, 162, 71--94.

Examples

Run this code
data("bodyfat", package = "mboost")
    tbodyfat <- bodyfat
 
    ### map covariates into [1, 2]
    indep <- names(tbodyfat)[-2]
    tbodyfat[indep] <- lapply(bodyfat[indep], function(x) {
        x <- x - min(x)
        x / max(x) + 1
    })
 
    ### generate formula
    fpfm <- as.formula(paste("DEXfat ~ ", paste("FP(", indep, ")", 
                             collapse = "+")))
    fpfm

    ### fit linear model
    bf_fp <- glmboost(fpfm, data = tbodyfat, 
                      control = boost_control(mstop = 3000))

    ### when to stop
    mstop(aic <- AIC(bf_fp))
    plot(aic)

    ### coefficients
    cf <- coef(bf_fp[mstop(aic)])
    length(cf)
    cf[abs(cf) > 0]

Run the code above in your browser using DataCamp Workspace