Skip to contents

Estimate a univariate conditional mean and construct pointwise confidence intervals that include estimated upper bounds on smoothing bias.

Usage

bias_bound_regression(
  x,
  y,
  eval = NULL,
  bw = "cv",
  conf_level = 0.95,
  kernel = c("schennach", "sinc", "normal", "epanechnikov"),
  control = NULL
)

Arguments

x

Numeric predictor sample.

y

Numeric response sample with the same length as x.

eval

Optional numeric evaluation points. When NULL, a regular grid is constructed from the sample.

bw

Either a positive numeric bandwidth or one of "cv" and "silverman" for automatic selection. "silverman" uses the stats::bw.nrd0() normal-reference rule, multiplied by 2.34 for the Epanechnikov kernel or by a heuristic 1.2 for either infinite-order kernel; the normal-kernel factor is unchanged.

conf_level

Confidence level in (0, 1).

kernel

One of "schennach", "sinc", "normal", or "epanechnikov". The formal coverage result in Schennach (2020) assumes an infinite-order kernel whose Fourier transform equals one near the origin; "schennach" is the recommended theorem-compatible default.

control

Optional named list of advanced settings. Supported entries are resolution (evaluation-grid size), frequency_window ("snr", "schennach", or "schennach_loose"), frequency_range (a positive, increasing vector of length two), noise_floor ("auto", "compact", or "general"), envelope_use_y (fit the regression numerator envelope to the response-weighted Fourier transform), smoothness_floor (enforce the theoretical integer restriction \(r \in \{2,3,\ldots\}\)), smoothness_max (largest exponent considered; default 50), approximate_kernel, kernel_resolution, and envelope_points_per_log. The "snr" frequency rule is a finite-sample heuristic; "schennach" is the exact Theorem 2 rule and errors with guidance when its feasible set is empty. The last setting replaces the formerly hard-coded 200-point log-frequency resolution.

Value

An object of class bbnp_regression. Standard methods include print(), summary(), plot(), coef(), fitted(), and confint().

Examples

set.seed(123)
x <- runif(200) + runif(200)
y <- -x^2 + 3 * x + rnorm(200, sd = x)
fit <- bias_bound_regression(x, y, bw = "silverman")
#> Warning: Fitted envelope slope r-hat = 1.82 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").
fit
#> Bias-Bounded Conditional Expectation Estimation
#> 
#> Call:
#> bias_bound_regression(x = x, y = y, bw = "silverman")
#> 
#> Sample size: n = 200
#> Bandwidth:   h = 0.1463 (automatic: silverman) 
#> Kernel:      Schennach2004 
#> 
#> Bias bound parameters:
#>   A = 9.8836, r = 2.0000, B = 1.9236
#>   bias bounds: b1x = 0.2081, byx = 0.4733
#> 
#> Evaluation points: 100 (range: [0.1259, 1.8734])
#> Fitted values: E[Y|X] range [0.3653, 3.0706]
#> Confidence level: 95%
#> 
#> Use summary() for detailed statistics
#> Use plot() to visualize results
#> Use fitted() to extract fitted values
fitted(fit)
#>   [1] 0.3653458 0.4231972 0.4780711 0.5303425 0.5816009 0.6303489 0.6784771
#>   [8] 0.7253820 0.7710120 0.8166370 0.8607514 0.9048203 0.9481336 0.9907406
#>  [15] 1.0332855 1.0747708 1.1162173 1.1568444 1.1970208 1.2367360 1.2755183
#>  [22] 1.3140678 1.3515374 1.3885789 1.4247465 1.4599188 1.4945966 1.5279630
#>  [29] 1.5607589 1.5924193 1.6229797 1.6527954 1.6812438 1.7089090 1.7353746
#>  [36] 1.7607370 1.7851502 1.8083715 1.8306386 1.8518093 1.8720467 1.8912040
#>  [43] 1.9095155 1.9268312 1.9432556 1.9590697 1.9737647 1.9880252 2.0014089
#>  [50] 2.0141380 2.0266476 2.0381117 2.0495238 2.0603121 2.0706618 2.0811663
#>  [57] 2.0908217 2.1007096 2.1103094 2.1196692 2.1294518 2.1387262 2.1483775
#>  [64] 2.1581071 2.1678041 2.1780396 2.1882658 2.1988618 2.2098967 2.2211445
#>  [71] 2.2328945 2.2452737 2.2579050 2.2712903 2.2852253 2.2994920 2.3151369
#>  [78] 2.3308857 2.3476223 2.3654049 2.3832707 2.4033266 2.4234569 2.4447120
#>  [85] 2.4677392 2.4906849 2.5166316 2.5429985 2.5706154 2.6010780 2.6317964
#>  [92] 2.6663405 2.7026286 2.7406577 2.7834923 2.8286299 2.8792095 2.9359522
#>  [99] 2.9976919 3.0705952