fracplot {mfp2}R Documentation

Plot response functions from a fitted mfp2 object

Description

Plots the partial linear predictors with confidence limits against the selected covariate(s) of interest.

Usage

fracplot(
  model,
  terms = NULL,
  partial_only = FALSE,
  type = c("terms", "contrasts"),
  ref = NULL,
  terms_seq = c("data", "equidistant"),
  alpha = 0.05,
  color_points = "#AAAAAA",
  color_line = "#000000",
  color_fill = "#000000",
  shape = 1,
  size_points = 1,
  linetype = "solid",
  linewidth = 1,
  alpha_fill = 0.1
)

plot_mfp(...)

Arguments

model

fitted mfp2 model.

terms

character vector with variable names to be plotted.

partial_only

a logical value indicating whether only the partial predictor (component) is drawn (TRUE), or also component-plus-residual (FALSE, the default). Only used if type = "terms". See below for details.

type, ref, terms_seq

arguments of predict.mfp2(). Only type = "terms" and type = "contrasts" are supported by this function.

alpha

alpha argument of predict.mfp2().

color_line, linetype, linewidth

ggplot2 properties of line for partial predictor.

color_fill, alpha_fill

ggplot2 properties of ribbon for confidence interval.

shape, size_points, color_points

ggplot2 properties of drawn data points.

...

used in alias plot_mfp to pass arguments.

Details

The confidence limits of the partial linear predictors or contrasts are obtained from the variance–covariance matrix of the final fitted model, which takes into account the uncertainty in estimating the model parameters but not the FP powers. This can lead to narrow confidence intervals. A simple way to obtain more realistic confidence intervals within the FP is by using bootstrap, which is not currently implemented. See Royston and Sauerbrei (2008) chapter 4.9.2 for guidance on conducting bootstrapping within the FP class.

The component-plus-residual, is the partial linear predictor plus residuals, where deviance residuals are used in generalized linear regression models, while martingale residuals are used in Cox models, as done in Stata mfp program. This kind of plot is only available if type = "terms".

Value

A list of ggplot2 plot objects, one for each term requested. Can be drawn as individual plots or facetted / combined easily using e.g. patchwork::wrap_plots and further customized.

Functions

See Also

predict.mfp2()

Examples


# Gaussian
data("prostate")
x = as.matrix(prostate[,2:8])
y = as.numeric(prostate$lpsa)
# default interface
fit = mfp2(x, y, verbose = FALSE)
fracplot(fit) # generate plots


[Package mfp2 version 1.0.0 Index]