Fit gastric emptying curves with Stan
Usage
stan_gastempt(
d,
model_name = "linexp_gastro_2b",
lkj = 2,
student_df = 5L,
init_r = 0.2,
chains = 1,
iter = 2000,
...
)
Arguments
- d
A data frame with columns
rec
Record descriptor as grouping variable, e.g. patient IDminute
Time after meal or start of recording.vol
Volume of meal or stomach
- model_name
Name of predefined model in
gastempt/exec
. Usestan_model_names()
to get a list of available models.- lkj
LKJ prior for kappa/tempt correlation, only required for model linexp_gastro_2b. Values from 1.5 (strong correlation) to 50 (almost independent) are useful.
- student_df
Student-t degrees of freedom for residual error; default 5. Use 3 for strong outliers; values above 10 are close to gaussian residual distribution.
- init_r
for stan, default = 0.2; Stan's own default is 2, which often results in stuck chains.
- chains
for stan; default = 1
- iter
A positive integer specifying the number of iterations for each chain (including warmup). The default is 2000.
- ...
Additional parameter passed to
sampling
andstan
Value
A list of class stan_gastempt with elements coef, fit, plot
coef
is a data frame with columns:rec
Record descriptor, e.g. patient IDv0
Initial volume at t=0tempt
Emptying time constantkappa
Parameterkappa
formodel = linexp
beta
Parameterbeta
formodel = powexp
t50
Half-time of emptyingslope_t50
Slope in t50; typically in units of ml/minute On error,coef
is NULL
fit
Result of class `stanfit`plot
A ggplot graph of data and prediction. Plot of raw data is returned even when convergence was not achieved.
Examples
# Runs 30+ seconds on CRAN
dd = simulate_gastempt(n_records = 6, seed = 471)
d = dd$data
ret = stan_gastempt(d)
print(ret$coef)
#> # A tibble: 6 × 7
#> # Rowwise:
#> record v0 kappa tempt t50 slope_t50 auc
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 rec_01 286. 0.461 69.5 76.8 1.43 29016.
#> 2 rec_02 429. 0.628 78.0 100. 1.79 54417.
#> 3 rec_03 409. 0.405 76.2 79.7 1.92 43771.
#> 4 rec_04 366. 0.862 77.2 119. 1.49 52656.
#> 5 rec_05 429. 0.168 61.5 50.6 2.97 30836.
#> 6 rec_06 471. 0.230 65.7 57.6 2.90 38013.