Skip to contents

Creates visualizations of bias-bounded conditional expectation estimation results

Usage

# S3 method for class 'bbnp_regression'
plot(
  x,
  type = c("regression", "ft"),
  fill_ci = .bbnp_pal[["ci"]],
  alpha_ci = 0.55,
  point_alpha = 0.28,
  point_color = .bbnp_pal[["point"]],
  ft_resol = 500,
  xi_range = NULL,
  expand = 2.5,
  ...
)

Arguments

x

An object of class bbnp_regression

type

Character string specifying plot type. Options are:

  • "regression" (default): Conditional expectation with confidence interval

  • "ft": Fourier transform plot with estimated envelope

fill_ci

Color for confidence interval ribbon (default: a muted blue).

alpha_ci

Transparency for confidence interval ribbon (default: 0.35)

point_alpha

Transparency for data points (default: 0.28)

point_color

Color for data points (default: a soft grey).

ft_resol

Resolution for Fourier transform plot (default: 500)

xi_range

Optional numeric c(lower, upper) giving the frequency range to display in the "ft" plot. If NULL (default) a wide range around the selected window is shown (see expand). This controls only what is drawn; it does not change the fitting window [xi_lb, xi_ub].

expand

For the "ft" plot when xi_range is NULL: how far past the selected window to display, as a multiple (default 2.5).

...

Additional arguments (unused)

Value

A ggplot2 object

Examples

# \donttest{
set.seed(1)
x_data <- runif(500) + runif(500)
y_data <- 2 * x_data - x_data^2 + rnorm(length(x_data), sd = 0.3)
fit <- bias_bound_regression(x_data, y_data, bw = 0.1)
#> Warning: Fitted envelope slope r-hat = 1.84 is below the smoothness floor r >= 2 the method assumes: the Fourier transform does not show a clear power-law decay over the window (likely a supersmooth density or a non-power-law/non-monotone cross-spectrum). The returned envelope dominates the fitted frequency grid, but Schennach's coverage theorem may not apply. Inspect plot(fit, type = "ft").
plot(fit)

plot(fit, type = "ft")

# }