| fp | R Documentation |
Use fp() or fp2() inside an mfp2() or mfpi() formula to set
fractional-polynomial (FP) options for one continuous predictor. In
mfp2(), continuous terms without fp() are also considered for FP
selection, using its top-level settings. fp() and fp2() specify the
same model term and record options for fitting; neither transforms the
values when the formula is created.
fp(
x,
df = 4,
alpha = 0.05,
select = 0.05,
shift = NULL,
scale = NULL,
center = TRUE,
acd = FALSE,
powers = NULL,
zero = FALSE,
catzero = FALSE,
spike = FALSE,
force_max_fp = FALSE,
acdx = NULL
)
fp2(...)
x |
Continuous numeric predictor to include in the formula. Do not
wrap a factor in |
df |
Maximum FP complexity: |
alpha |
Significance level for comparisons between functional forms
under p-value selection. Default |
select |
Significance level for variable inclusion under p-value
selection. Default |
shift |
Numeric value added before FP transformation. |
scale |
Positive divisor applied after shifting. |
center |
Whether to center the fitted terms. Default |
acd |
Whether to request approximate cumulative distribution (ACD)
modelling. Default |
powers |
Numeric vector of candidate FP powers for this predictor.
|
zero |
If |
catzero |
If |
spike |
If |
force_max_fp |
If |
acdx |
Deprecated alias for |
... |
Arguments passed by |
fp2() was introduced to avoid a name conflict with mfp::fp().
That conflict is now resolved: formulas passed to mfp2() or mfpi()
use this package's fp() even when mfp is attached.
Add categorical predictors to the formula without fp() or fp2().
Convert numeric category codes with factor().
The default df = 4 permits selection of a linear effect, a first-degree
FP (FP1), or a second-degree FP (FP2). Selection may also exclude the
predictor. Use df = 2 to permit at most FP1, or df = 1 for a linear
effect only. The fitting procedure may reduce the permitted complexity
when a predictor has few distinct values.
Candidate powers default to c(-2, -1, -0.5, 0, 0.5, 1, 2, 3). A power
of zero represents a logarithm. powers changes the candidates searched;
it does not specify the powers of the final fitted function.
Options set inside fp() apply to this term. df, alpha, select,
and center have their own defaults in fp() and ignore the values
supplied to the surrounding mfp2() call; set them inside fp() to
change them. shift, scale, and powers default to NULL and use the
top-level values unless set here. Under p-value selection, select = 1
forces inclusion and alpha = 1 prevents simplification of the permitted
functional form.
The input vector with modelling options attached as attributes.
The options take effect when the term is used in an mfp2() or
mfpi() formula.
fp2(), mfp2(), mfpi()
data("prostate")
# Search up to FP1 for age.
fit_fp <- mfp2(
lpsa ~ fp(age, df = 2) + svi,
data = prostate,
verbose = FALSE
)
# fp2() accepts the same options and produces the same model specification.
fit_fp2 <- mfp2(
lpsa ~ fp2(age, df = 2) + svi,
data = prostate,
verbose = FALSE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.