Skip to contents

This function numerically approximates the conditional maximum likelihood estimate (MLE) of a single regression coefficient using a Monte Carlo approximation to the selective likelihood, conditional on passing the overall F-test.

Usage

compute_MLE(
  X,
  y,
  beta_init,
  sigma_sq_init,
  alpha_ov,
  interval_beta = c(-10, 10),
  interval_sigma_sq = c(-10, 10),
  B = 1e+06
)

Arguments

X

A numeric matrix of predictor variables (n x p), with the first column corresponding to beta1.

y

A numeric response vector of length n.

alpha_ov

The significance level for the overall F-test (used in defining the selection region).

B

The number of Monte Carlo samples used to approximate the likelihood (default: 1e6).

interval

A numeric vector of length 2 giving the search interval for beta1 (default: c(-10, 10)).

Value

A list containing:

beta

The MLE of beta1 (a single coefficient) under the selective likelihood.

max_likelihood

The maximum log-likelihood value achieved at the optimal beta1.