Learn R Programming

lgspline (version 0.2.0)

wald_univariate: Univariate Wald Tests and Confidence Intervals for Lagrangian Multiplier Smoothing Splines

Description

Performs coefficient-specific Wald tests and constructs confidence intervals for fitted lgspline models. (Wrapper for internal wald_univariate method). For Gaussian family with identity-link, a t-distribution replaces a normal distribution (and t-intervals, t-tests etc.) over Wald when mentioned.

Usage

wald_univariate(object, scale_vcovmat_by = 1, cv, ...)

Value

A data frame with rows for each coefficient (across all partitions) and columns:

estimate

Numeric; Coefficient estimate.

std_error

Numeric; Standard error.

statistic

Numeric; Wald or t-statistic (estimate/std_error).

p_value

Numeric; Two-sided p-value based on normal or t-distribution.

lower_ci

Numeric; Lower confidence bound (estimate - cv*std_error).

upper_ci

Numeric; Upper confidence bound (estimate + cv*std_error).

Arguments

object

A fitted lgspline model object containing coefficient estimates and variance-covariance matrix (requires return_varcovmat = TRUE in fitting).

scale_vcovmat_by

Numeric; Scaling factor for variance-covariance matrix. Adjusts standard errors and test statistics. Default 1.

cv

Numeric; Critical value for confidence interval construction. If missing, defaults to value specified in lgspline() fit (`object$critical_value`) or `qnorm(0.975)` as a fallback. Common choices:

  • qnorm(0.975) for normal-based 95

  • qt(0.975, df) for t-based 95

...

Additional arguments passed to the internal `wald_univariate` method.

Details

For each coefficient, provides:

  • Point estimates

  • Standard errors from the model's variance-covariance matrix

  • Two-sided test statistics and p-values

  • Confidence intervals using specified critical values

See Also

lgspline

Examples

Run this code

## Simulate some data and fit using default settings
set.seed(1234)
t <- runif(1000, -10, 10)
y <- 2*sin(t) + -0.06*t^2 + rnorm(length(t))
# Ensure varcovmat is returned for Wald tests
model_fit <- lgspline(t, y, return_varcovmat = TRUE)

## Use default critical value (likely qnorm(0.975) if not set in fit)
wald_default <- wald_univariate(model_fit)
print(wald_default)

## Specify t-distribution critical value
eff_df <- NA
if(!is.null(model_fit$N) && !is.null(model_fit$trace_XUGX)) {
   eff_df <- model_fit$N - model_fit$trace_XUGX
}
if (!is.na(eff_df) && eff_df > 0) {
  wald_t <- wald_univariate(
    model_fit,
    cv = stats::qt(0.975, eff_df)
  )
  print(wald_t)
} else {
  warning("Effective degrees of freedom invalid.")
}


Run the code above in your browser using DataLab