This function computes the local false sign rate (LFSR) at each evaluation point for a specific dataset in a fash object using the posterior mean and variance instead of sampling-based methods.

compute_lfsr_summary(object, index = 1, smooth_var = NULL, deriv = 0)

Arguments

object

A fash object containing the fitted results.

index

An integer specifying the dataset index.

smooth_var

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

deriv

An integer specifying the order of the derivative to compute.

Value

A data frame with the following columns:

x

The refined x values where posterior probabilities are evaluated.

pos_prob

The posterior probability that the function is positive at each x.

neg_prob

The posterior probability that the function is negative at each x.

lfsr

The local false sign rate (LFSR) at each x, computed as pmin(pos_prob, neg_prob).

Examples

# Example usage
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.15 seconds.
#> Starting empirical Bayes estimation...
#> Completed empirical Bayes estimation in 0.00 seconds.
#> fash object created successfully.

# Compute LFSR summary for dataset 1
lfsr_summary_df <- compute_lfsr_summary(fash_obj, index = 1)
print(lfsr_summary_df)
#>   x pos_prob neg_prob lfsr
#> 1 1        1        1    1
#> 2 2        1        1    1
#> 3 3        1        1    1
#> 4 4        1        1    1
#> 5 5        1        1    1