R/05_lfsr.R
compute_lfsr_summary.Rd
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)
A data frame with the following columns:
The refined x values where posterior probabilities are evaluated.
The posterior probability that the function is positive at each x.
The posterior probability that the function is negative at each x.
The local false sign rate (LFSR) at each x, computed as pmin(pos_prob, neg_prob)
.
# 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