test_lambda_bounds: Searches for a tight bound for lambda_K that gives the empty...

View source: R/genscore.R

test_lambda_boundsR Documentation

Searches for a tight bound for \lambda_{\boldsymbol{K}} that gives the empty or complete graph starting from a given lambda with a given step size

Description

Searches for the smallest lambda that gives the empty graph (if lower == FALSE) or the largest that gives the complete graph (if lower == TRUE) starting from the given lambda, each time updating by multiplying or dividing by step depending on the search direction.

Usage

test_lambda_bounds(
  elts,
  symmetric,
  lambda = 1,
  lambda_ratio = 1,
  step = 2,
  lower = TRUE,
  verbose = TRUE,
  tol = 1e-06,
  maxit = 10000,
  cur_res = NULL
)

Arguments

elts

A list, elements necessary for calculations returned by get_elts().

symmetric

A string. If equals "symmetric", estimates the minimizer \mathbf{K} over all symmetric matrices; if "and" or "or", use the "and"/"or" rule to get the support

lambda

A number, the initial searching point for \lambda_{\mathbf{K}}.

lambda_ratio

A positive number (or Inf), the fixed ratio \lambda_{\mathbf{K}} and \lambda_{\boldsymbol{\eta}}, if \lambda_{\boldsymbol{\eta}}\neq 0 (non-profiled) in the non-centered setting.

step

A number, the multiplicative constant applied to lambda at each iteration. Must be strictly larger than 1.

lower

A boolean. If TRUE, finds the largest possible lambda that gives the complete graph (a lower bound). If FALSE, finds the smallest possible lambda that gives the empty graph (an upper bound).

verbose

Optional. A boolean. If TRUE, prints out the lambda value at each iteration.

tol

Optional. A number, the tolerance parameter.

maxit

Optional. A positive integer, the maximum number of iterations in model fitting for each lambda.

cur_res

Optional. A list, current results returned from a previous lambda. If provided, used as a warm start. Default to NULL.

Value

lambda

A number, the best lambda that produces the desired number of edges. 1e-10 or 1e15 is returned if out of bound.

cur_res

A list, results for this lambda. May be NULL if lambda is out of bound.

Examples

# Examples are shown for Gaussian truncated to R+^p only. For other distributions
#   on other types of domains, please refer to \code{gen()} or \code{get_elts()}, as the
#   way to call this function (\code{test_lambda_bounds()}) is exactly the same in those cases.
n <- 50
p <- 30
domain <- make_domain("R+", p=p)
mu <- rep(0, p)
K <- diag(p)
x <- tmvtnorm::rtmvnorm(n, mean = mu, sigma = solve(K),
       lower = rep(0, p), upper = rep(Inf, p), algorithm = "gibbs",
       burn.in.samples = 100, thinning = 10)

h_hp <- get_h_hp("min_pow", 1, 3)
dm <- 1 + (1-1/(1+4*exp(1)*max(6*log(p)/n, sqrt(6*log(p)/n))))
elts_gauss_np <- get_elts(h_hp, x, setting="gaussian", domain=domain,
                 centered=FALSE, profiled=FALSE, diag=dm)
lambda_cur_res <- test_lambda_bounds(elts_gauss_np, "symmetric", lambda=1,
                  lambda_ratio=1, step=1.5, lower=TRUE, cur_res=NULL)
lambda_cur_res2 <- test_lambda_bounds(elts_gauss_np, "symmetric", lambda=1,
                  lambda_ratio=1, step=1.5, lower=FALSE, cur_res=lambda_cur_res$cur_res)

genscore documentation built on May 29, 2024, 9 a.m.