To be used in find_best_fp_step()
. Only used if df = 1
for a variable.
Handles all criteria for selection.
For parameter explanations, see find_best_fp_step()
. All parameters
captured by ...
are passed on to fit_model()
.
select_linear(
x,
xi,
keep,
degree,
acdx,
y,
powers_current,
powers,
criterion,
ftest,
select,
alpha,
...
)
A list with several components:
keep
: logical indicating if xi
is forced into model.
acd
: logical indicating if an ACD transformation was applied for xi
.
powers
: fp powers investigated in step, indexing metrics
.
power_best
: a numeric vector with the best power found. The returned
best power may be NA
, indicating the variable has been removed from the
model.
metrics
: a matrix with performance indices for all models investigated.
Same number of rows as, and indexed by, powers
.
model_best
: row index of best model in metrics
.
pvalue
: p-value for comparison of linear and null model.
statistic
: test statistic used, depends on ftest
.
an input matrix of dimensions nobs x nvars. Does not contain intercept, but columns are already expanded into dummy variables as necessary. Data are assumed to be shifted and scaled.
a character string indicating the name of the current variable of interest, for which the best fractional polynomial transformation is to be estimated in the current step.
a character vector with names of variables to be kept in the model.
not used.
a logical vector of length nvars indicating continuous variables to undergo the approximate cumulative distribution (ACD) transformation.
a vector for the response variable or a Surv
object.
a list of length equal to the number of variables,
indicating the fp powers to be used in the current step for all variables
(except xi
).
a named list of numeric values that sets the permitted FP powers for each covariate.
a character string defining the criterion used to select variables and FP models of different degrees.
a logical indicating the use of the F-test for Gaussian models.
a numeric value indicating the significance level
for backward elimination of xi
.
a numeric value indicating the significance level
for tests between FP models of different degrees for xi
.
passed to fitting functions.
This function assesses a single variable of interest xi
regarding its
functional form in the current working model as indicated by
powers_current
, with the choice between a excluding xi
("null model") and
including a linear term ("linear fp") for xi
.
Note that this function handles an ACD transformation for xi
as well.
When a variable is forced into the model by including it in keep
, then
this function will not exclude it from the model (by setting its power to
NA
), but will only choose the linear model.