Constructor for a standardising population used for model outputs
Source:R/outputs.R
standardise_to.Rd
Standardised outputs are outputs from models with covariates, that are defined by marginalising (averaging) over covariate values in a given population, rather than being conditional on a given covariate value.
Details
Standardised outputs are produced from a Monte Carlo sample from the joint distribution of parameters \(\theta\) and covariate values \(X\), \(p(X,\theta) = p(\theta|X)p(X)\), where \(p(X)\) is defined by the empirical distribution of covariates in the standard population. This joint sample is obtained by concatenating samples of covariate-specific outputs.
Hence applying an output function \(g()\) (such as the transition probability) to this sample produces a sample from the posterior of \(\int g(\theta|X) dX\): the average transition probability (say) for a heterogeneous population.
Examples
nd <- data.frame(sex=c("female","male"))
## gender-specific outputs
qdf(infsim_modelc, new_data = nd)
#> # A tibble: 4 × 4
#> from to value sex
#> <int> <int> <rvar[1d]> <chr>
#> 1 1 2 0.62 ± NA female
#> 2 1 2 0.70 ± NA male
#> 3 2 1 3.84 ± NA female
#> 4 2 1 3.84 ± NA male
## averaged over men and women in the same proportions as are in `nd`
## in this case, `nd` has two rows, so we take a 50/50 average
qdf(infsim_modelc, new_data = standardise_to(nd))
#> # A tibble: 2 × 3
#> from to value
#> <int> <int> <rvar[1d]>
#> 1 1 2 0.66 ± 0.058
#> 2 2 1 3.84 ± 0.000