Skip to contents

Returns a function (as expected by cmdstanr) giving valid starting values. The Cholesky factor of the correlation matrix must be lower triangular with unit-norm rows: Astar = [[1, 0], [rho0, sqrt(1 - rho0^2)]]. The length-scales start at the prior mean (mrange) and the intercepts at their empirical values (for beta0, the number of cells per unit of tissue area), which shortens warm-up.

Usage

denmark_init(stan_data, rho0 = 0.3)

Arguments

stan_data

Stan data list, as in denmark_prepare()$stan_data.

rho0

Starting value of rho, in (-1, 1).

Value

A function without arguments that returns a list of initial values.

Examples

toy <- denmark_toy_data()
tumor <- subset(toy, celltype == "Tumor", select = -celltype)
prep <- denmark_prepare(tumor, gene = "geneA", grid_size = 10, basis = 10)
init <- denmark_init(prep$stan_data)
str(init())
#> List of 7
#>  $ Astar : num [1:2, 1:2] 1 0.3 0 0.954
#>  $ sigma : num [1:2] 1 0.5
#>  $ beta0 : num 5.6
#>  $ beta1 : num 1.55
#>  $ ell   : num [1:2] 0.93 0.93
#>  $ betab1: num [1:100] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ betab2: num [1:100] 0 0 0 0 0 0 0 0 0 0 ...