This function computes the minimum local false sign rate (LFSR) for each dataset in a fash object. It estimates the probability that the sign of the effect is positive or negative at each x value and returns a ranked data frame.

min_lfsr_sampling(
  fash_fit,
  smooth_var = NULL,
  M = 3000,
  num_cores = 1,
  deriv = 0
)

Arguments

fash_fit

A fash object containing posterior samples.

smooth_var

A numeric vector specifying refined x values for prediction. If NULL, defaults to the dataset's original x values.

M

An integer specifying the number of posterior samples to generate.

num_cores

An integer specifying the number of cores to use for parallel processing.

deriv

An integer specifying the order of the derivative to compute.

Value

A data frame containing:

index

The dataset index.

min_lfsr

The minimum LFSR computed for each dataset.

fsr

The cumulative false sign rate (FSR).

Examples

# Example fash object (assuming it has been fitted)
set.seed(1)
data_list <- list(
  data.frame(y = rpois(5, lambda = 5), x = 1:5, offset = 0),
  data.frame(y = rpois(5, lambda = 5), x = 1:5, offset = 0)
)
grid <- seq(0, 2, length.out = 10)
fash_obj <- fash(data_list = data_list, Y = "y", smooth_var = "x", grid = grid, likelihood = "poisson", verbose = TRUE)
#> Starting data setup...
#> Completed data setup in 0.00 seconds.
#> Starting likelihood computation...
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |======================================================================| 100%
#> Completed likelihood computation in 0.14 seconds.
#> Starting empirical Bayes estimation...
#> Completed empirical Bayes estimation in 0.00 seconds.
#> fash object created successfully.

# Compute min LFSR with sequential execution
result <- min_lfsr_sampling(fash_obj, num_cores = 1)
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |======================================================================| 100%

# Compute min LFSR with parallel execution
result_parallel <- min_lfsr_sampling(fash_obj, num_cores = 2)