cmdstanr keeps posterior draws in CSV files (by default in a temporary
folder that disappears when R closes). denmark_save() reads everything
into memory first, so the saved object can be reloaded and post-processed
in a later session.
Arguments
- obj
A
denmarkobject fromDenMark().- file
Path of the
.rdsfile.
Examples
toy <- denmark_toy_data()
tissue <- denmark_alpha_shape(toy$x, toy$y)
tumor <- subset(toy, celltype == "Tumor", select = -celltype)
fit <- DenMark(tumor, gene = "geneA", boundary = tissue,
grid_size = 10, basis = 10,
chains = 2, iter_warmup = 300, iter_sampling = 300,
seed = 2024, quiet = TRUE)
f <- tempfile(fileext = ".rds")
denmark_save(fit, f)
fit2 <- denmark_load(f)
denmark_summary(fit2)
#> variable mean sd q2.5 q25 q50 q75
#> 1 beta0 5.601331528 0.3097492 4.9325404 5.4181133 5.61098860 5.8053836
#> 2 beta1 -0.006866258 0.5578875 -1.3494302 -0.3105288 0.07316074 0.3673002
#> 3 ell[1] 0.605010793 0.1502094 0.3779487 0.5024737 0.58196906 0.6884403
#> 4 ell[2] 0.771993891 0.2643356 0.4080575 0.5885706 0.72639588 0.8915657
#> 5 Astar[2,1] 0.633226952 0.1356900 0.3432107 0.5478936 0.65264227 0.7333021
#> 6 sigma[1] 0.996146048 0.2059037 0.6932623 0.8644840 0.95049295 1.0908011
#> 7 sigma[2] 1.334124248 0.3150556 0.8565963 1.1129229 1.28822175 1.5008512
#> q97.5 rhat ess_bulk ess_tail label
#> 1 6.1774899 1.003058 582.9498 369.4042 intercept, cell density
#> 2 0.8390978 1.002995 507.7903 351.3187 intercept, expression
#> 3 0.9516199 1.010649 321.4436 419.2502 length-scale, density field
#> 4 1.4692636 1.005955 351.7718 339.1145 length-scale, expression field
#> 5 0.8651198 1.009571 291.8595 459.4095 rho: density-expression correlation
#> 6 1.5280511 1.001273 292.4361 359.8197 SD, density field
#> 7 2.0902071 1.008189 241.4411 251.0961 SD, expression field