standardise_to {survextrap} | R Documentation |
Constructor for a standardising population used for survextrap outputs
Description
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.
Usage
standardise_to(newdata, nstd = 1, random = FALSE)
standardize_to(newdata, nstd = 1, random = FALSE)
Arguments
newdata |
Data frame describing a population. |
nstd |
Number of draws from the population distribution used
per MCMC sample from the parameters when |
random |
By default this is A quicker alternative is to sample a random row of the standard
population for each MCMC iteration. The standardised sample from
the posterior then has size |
Details
These are produced by generating 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.
Hence applying a vectorised output function g()
(such as the
RMST or survival probability) to this sample produces a sample from
the posterior of \int g(\theta|X) dX
: the average RMST (say)
for a heterogeneous population.
See the Examples vignette for some examples and notes on computation.
Value
A copy of newdata
, but with attributes added to
indicate that this should be used as a standard population. When
this newdata
is passed to survextrap
's output
functions, the outputs will then be presented as an average over
the empirical distribution of covariate values described by
newdata
, rather than as one output per row of
newdata
(distinct covariate values).
Examples
rxph_mod <- survextrap(Surv(years, status) ~ rx, data=colons, fit_method="opt")
ref_pop <- data.frame(rx = c("Obs","Lev+5FU"))
# covariate-specific outputs
survival(rxph_mod, t = c(5,10), newdata = ref_pop)
# standardised outputs
survival(rxph_mod, t = c(5,10), newdata = standardise_to(ref_pop))