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

View source: R/genscore.R

test_lambda_bounds2R Documentation

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

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.

Usage

test_lambda_bounds2(
  elts,
  symmetric,
  lambda_ratio = Inf,
  lower = TRUE,
  verbose = TRUE,
  tol = 1e-06,
  maxit = 10000,
  lambda_start = 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_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.

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.

lambda_start

Optional. A number, the starting point for searching. If NULL, set to 1e-4 if lower == TRUE, or 1 if lower == FALSE.

Details

This function calls test_lambda_bounds three times with step set to 10, 10^(1/4), 10^(1/16), respectively.

Value

A number, the best lambda that produces the desired number of edges. 1e-10 or 1e15 is returned if 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_bounds2()}) 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)
test_lambda_bounds2(elts_gauss_np, "symmetric", lambda_ratio=2,
     lower=TRUE, verbose=TRUE, lambda_start=NULL)
test_lambda_bounds2(elts_gauss_np, "symmetric", lambda_ratio=2,
     lower=FALSE, verbose=TRUE, lambda_start=1.0)

genscore documentation built on May 31, 2023, 6:28 p.m.