Learn R Programming

PoSIAdjRSquared (version 0.1.0)

solve_selection_event: Solve selection event

Description

This function solves the selection event by calculating the intervals of the OLS estimator where the regression coefficient actually gets selected.

Usage

solve_selection_event(a,b,R_M_k,kappa_M_k,R_M_phat,kappa_M_phat,k)

Value

intervals_list

The intervals of the OLS estimator for which the inequality in Lemma 1 holds

z_interval

The intersection of the intervals of the OLS estimator for which the inequality in Lemma 1 holds: post-selection inference is conditioned on those intervals

Arguments

a

Residual vector of type "matrix" and dimension nx1 (see Lemma 1 for details)

b

Vector of type "matrix" and dimension nx1: useful in orthogonal decomposition of y (see Lemma 1 for details)

R_M_k

The orthogonal projection matrix of model k

kappa_M_k

Adjustment factor for model complexity kappa of model k

R_M_phat

The orthogonal projection matrix of the selected model

kappa_M_phat

Adjustment factor for model complexity kappa of the selected model

k

Index set included in model k

References

Pirenne, S. and Claeskens, G. (2024). Exact Post-Selection Inference for Adjusted R Squared.

Examples

Run this code
  # Generate data
  n <- 100
  Data <- datagen.norm(seed = 7, n, p = 10, rho = 0, beta_vec = c(1,0.5,0,0.5,0,0,0,0,0,0))
  X <- Data$X
  y <- Data$y

  # Select model
  result <- fit_all_subset_linear_models(y, X, intercept=FALSE)
  phat <- result$phat
  X_M_phat <- result$X_M_phat
  k <- result$k
  R_M_phat <- result$R_M_phat
  kappa_M_phat <- result$kappa_M_phat
  R_M_k <- result$R_M_k
  kappa_M_k <- result$kappa_M_k

  # Estimate Sigma from residuals of full model
  full_model <- lm(y ~ 0 + X)
  sigma_hat <- sd(resid(full_model))
  Sigma <- diag(n)*(sigma_hat)^2

  # Construct test statistic
  Construct_test <- construct_test_statistic(j = 5, X_M_phat, y, phat, Sigma, intercept=FALSE)
  a <- Construct_test$a
  b <- Construct_test$b

  # Solve selection event
  solve_selection_event(a,b,R_M_k,kappa_M_k,R_M_phat,kappa_M_phat,k)

Run the code above in your browser using DataLab