Learn R Programming

breathteststan (version 0.4.7)

coef_diff_by_group: Tabulates breath test parameter differences of groups from Stan group fit

Description

Given a Stan fit with grouping to 13C breath test curves, computes point estimated and Bayesian credible intervals for all group pair differences, for examples of the half emptying time t50.

Usage

coef_diff_by_group.breathteststangroupfit(fit, mcp_group = NULL,
  reference_group = NULL, ...)

Arguments

fit

Object of class breathteststangroupfit from stan_fit

mcp_group

Not used, always all pairs are compared

reference_group

Not used

...

Not used

Value

A tibble of class coef_diff_by_group_stan with columns

parameter

Parameter of fit, e.g. beta, k, m, t50

method

Method used to compute parameter. exp_beta refers to primary fit parameters beta, k, m.

groups

Which pairwise difference, e.g solid - liquid

estimate

Point estimate (chain mean) of the difference

cred.low, cred.high

Lower and upper 95 percent credible interval of difference.

The chains of pairwise differences are returned as a attribute chain for use in plotting. See example below how to use these to display difference histograms.

Examples

Run this code
# NOT RUN {
library(dplyr)
library(breathtestcore)
data("usz_13c", package = "breathtestcore")
data = usz_13c %>%
  dplyr::filter( patient_id %in%
    c("norm_001", "norm_002", "norm_003", "norm_004", "pat_001", "pat_002","pat_003")) %>%
  cleanup_data()
fit = stan_group_fit(data, iter = 300, chains = 1) # Use more iterations!
cf = coef_diff_by_group(fit)
cc = attr(cf, "chain") %>%
   filter(key == "t50_maes_ghoos", abs(diff) < 200) %>%
   mutate(
     groups = paste(group2, group1, sep = " - ")
   )
str(cc)
if (require(ggplot2)) {
  ggplot(cc, aes(x = diff)) + geom_histogram() + facet_wrap(~groups)
}
# For comparison
fit = nlme_fit(data)
coef_diff_by_group(fit)
# }

Run the code above in your browser using DataLab