| Title: | Code to set up and run simulations using the JHEEM Engine |
|---|---|
| Description: | The engine for the JHEEM (Joint HIV Epidemiology and Economic Model) family of compartmental models of HIV and STI transmission. Provides tools to specify versioned model structures, compile and run them as differential-equation simulations, manage surveillance data, map between data ontologies, define interventions, and calibrate models to data via likelihoods. |
| Authors: | Anthony Fojo |
| Maintainer: | Anthony Fojo <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 1.13.0 |
| Built: | 2026-11-13 22:50:46 UTC |
| Source: | https://github.com/CIPHER-Epi/jheem2 |
Subset an ont
## S3 method for class 'ontology' ont[i]## S3 method for class 'ontology' ont[i]
ont |
An ontology, as created by |
i |
What to subset |
An ontology
Modify an ontology
## S3 replacement method for class 'ontology' ont[[i]] <- value## S3 replacement method for class 'ontology' ont[[i]] <- value
ont |
An ontology, as created by |
i |
What to subset |
value |
New value to insert |
An ontology
Modify an ontology
## S3 replacement method for class 'ontology' ont[i] <- value## S3 replacement method for class 'ontology' ont[i] <- value
ont |
An ontology, as created by |
i |
What to subset |
value |
New values to insert |
An ontology
Modify an ontology
## S3 replacement method for class 'ontology' ont$i <- value## S3 replacement method for class 'ontology' ont$i <- value
ont |
An ontology, as created by |
i |
What to subset |
value |
New value to insert |
An ontology
Add Sub Version to Specification
add.sub.version( specification, sub.version, description, inherit.outcomes = T, can.seed.new.engine = T )add.sub.version( specification, sub.version, description, inherit.outcomes = T, can.seed.new.engine = T )
Anchor Intervention Effect's Location and Version
anchor.intervention.effect.location.and.version( intervention.effect, location, specification.metadata, error.prefix = "" )anchor.intervention.effect.location.and.version( intervention.effect, location, specification.metadata, error.prefix = "" )
intervention.effect |
A 'jheem.intervention.effect' object that does not have a location or version set |
specification.metadata |
A 'jheem.specification.metadata' object for the desired version. Its location need not match the location given as argument to this function. |
A new intervention effect that has location and version set
Apply an Ontology Mapping to Data
apply.ontology.mapping( ontology.mapping, from.arr, to.dim.names = NULL, fun = "sum", na.rm = F, error.prefix = "" )apply.ontology.mapping( ontology.mapping, from.arr, to.dim.names = NULL, fun = "sum", na.rm = F, error.prefix = "" )
ontology.mapping |
An object of class 'ontology.mapping' - obtained either through register.ontology.mapping, get.ontology.mapping, get.mappings.to.align.ontologies |
from.arr |
An array to transform. Can have any underlying data type, although the function is optimized for numeric data |
to.dim.names |
The dimnames that the resulting transformed data should have (can represent a subset of the dimnames that the ontology mapping knows how to transform). If NULL, the ontology mapping will keep the dimnames in from.arr except for dimensions that are transformed |
fun |
A function used to combine values, or the name of a function. The function must be able to accept any number of arguments (including none). The default, 'sum', is optimized for numeric arrays |
na.rm |
Passed through to fun |
error.prefix |
A character value to be prepended to any error messages thrown by the function |
Other Functions to identify why ontologies fail to map:
get.identity.ontology.mapping(),
map.value.ontology()
Summarize the progress of a calibration task
are.simulations.present( version, locations, calibration.code, interventions, n.sim, sub.version = NULL, root.dir = get.jheem.root.directory() )are.simulations.present( version, locations, calibration.code, interventions, n.sim, sub.version = NULL, root.dir = get.jheem.root.directory() )
version, calibration.code, locations
|
The version, locations, and calibration code for which to gauge progress |
root.dir |
The root directory from which to search for calibrations |
as.pct |
Whether the progress should be shown as a percentage instead of a fraction |
round.to.digits |
How many digits to round progress to |
Flexibly Subset an Array
array.access(arr, ..., drop = F) fast.array.access(arr, dimension.values, drop = F)array.access(arr, ..., drop = F) fast.array.access(arr, dimension.values, drop = F)
arr |
The array or matrix to be subsetted. Must have named dimensions and named dimnames set |
drop |
Pass-through for the drop argument for array access. If set to true, any dimensions in the return value that have length one are omitted (as with standard subsetting). If false, then the dimensions are retained in the array |
dimension.values |
A named list containing the values of dimensions to subset for. The names of dimension.values should correspond to the names of dimnames. The elements of dimension.values should be character, integer, or logical vectors |
fast.array.access():
arr = array(1:24, dim=c(age=4, race=3, sex=2), dimnames=list(age=c('age1','age2','age3','age4'), race=c('black','hispanic','other'), sex=c('female','male'))) array.access(arr, dimension.values=list(age=1:3, race='black')) #is equivalent to arr[1:3, 'black',]arr = array(1:24, dim=c(age=4, race=3, sex=2), dimnames=list(age=c('age1','age2','age3','age4'), race=c('black','hispanic','other'), sex=c('female','male'))) array.access(arr, dimension.values=list(age=1:3, race='black')) #is equivalent to arr[1:3, 'black',]
Convert an ontology back to a plain list
## S3 method for class 'ontology' as.list(ont)## S3 method for class 'ontology' as.list(ont)
ont |
An ontology as created by |
Convert a named list to an ontology
as.ontology(x, incomplete.dimensions = NULL)as.ontology(x, incomplete.dimensions = NULL)
x |
A named list of character vectors or NULL elements |
Assemble an MCMC From a Calibration
assemble.mcmc.from.calibration( version, location, calibration.code, root.dir = get.jheem.root.directory("Cannot set up calibration: "), allow.incomplete = F, chains = NULL )assemble.mcmc.from.calibration( version, location, calibration.code, root.dir = get.jheem.root.directory("Cannot set up calibration: "), allow.incomplete = F, chains = NULL )
version |
The version of the model specification (must have been previously registered) |
location |
A single character value representing the location for the calibration |
chains |
Assemble Simulations From A Calibration
assemble.simulations.from.calibration( version, location, calibration.code, root.dir = get.jheem.root.directory("Cannot set up calibration: "), allow.incomplete = F, chains = NULL, verbose = T )assemble.simulations.from.calibration( version, location, calibration.code, root.dir = get.jheem.root.directory("Cannot set up calibration: "), allow.incomplete = F, chains = NULL, verbose = T )
version |
The version of the model specification (must have been previously registered) |
location |
A single character value representing the location for the calibration |
chains |
Assemble Transmuted Simulations
assemble.transmuted.simulations( transmute.code, location, n.sim, to.version = NULL, to.sub.version = NULL, chunks = NULL, allow.incomplete = F, root.dir = get.jheem.root.directory() )assemble.transmuted.simulations( transmute.code, location, n.sim, to.version = NULL, to.sub.version = NULL, chunks = NULL, allow.incomplete = F, root.dir = get.jheem.root.directory() )
Subset a simulation set by trimming off a portion of earlier simulations.
burn.simset(simset, keep = NULL)burn.simset(simset, keep = NULL)
keep |
Either a number of simulations to keep or a fraction to keep (between 0 and 1). The latest simulations will be kept. |
Decimal values above 1 are rounded down to the nearest whole number.
Cache A Summary of an MCMC
cache.mcmc.summary( version, location, calibration.code, root.dir = get.jheem.root.directory(), get.one.set.of.parameters = F, throw.error.if.incomplete = T )cache.mcmc.summary( version, location, calibration.code, root.dir = get.jheem.root.directory(), get.one.set.of.parameters = F, throw.error.if.incomplete = T )
'Transmutation' of a simulation is calculating a set of outcomes for another version without re-running the (expensive) differential equation solver
can.transmute.versions( from.version, to.version, from.sub.version = NULL, to.sub.version = NULL, print.details = T )can.transmute.versions( from.version, to.version, from.sub.version = NULL, to.sub.version = NULL, print.details = T )
from.version, to.version
|
The versions from and to which we want to transmute |
from.sub.version, to.sub.versions
|
The sub-versions from and to which we want to transmute |
print.details |
Whether to print the reasons why transmutation cannot happen |
Clear JHEEM Version, Calibration, Intervention, and Ontology Mappings
clear.all.managers()clear.all.managers()
Clear a Calibration Cache
clear.calibration.cache( version, location, calibration.code, root.dir = get.jheem.root.directory("Cannot set up calibration: "), remove.mcmc.summary = F, allow.remove.incomplete = F )clear.calibration.cache( version, location, calibration.code, root.dir = get.jheem.root.directory("Cannot set up calibration: "), remove.mcmc.summary = F, allow.remove.incomplete = F )
version |
The version of the model specification (must have been previously registered) |
location |
A single character value representing the location for the calibration |
allow.remove.incomplete |
Clear JHEEM Calibrations
clear.calibrations()clear.calibrations()
Clear JHEEM Interventions
clear.interventions()clear.interventions()
Clear Ontology Error Debug Info
clear.ontology.error.debug.info()clear.ontology.error.debug.info()
Clear All Registered Ontology Mappings
clear.ontology.mappings()clear.ontology.mappings()
Clears all registered ontology mappings, such that new mappings can be added
Clear a Calibration Cache
clear.transmute.calibration.cache( transmute.code, location, n.sim, to.version = NULL, to.sub.version = NULL, allow.remove.incomplete = F, root.dir = get.jheem.root.directory() )clear.transmute.calibration.cache( transmute.code, location, n.sim, to.version = NULL, to.sub.version = NULL, allow.remove.incomplete = F, root.dir = get.jheem.root.directory() )
location |
A single character value representing the location for the calibration |
allow.remove.incomplete |
Collapse an Array According to Indices
collapse.array.according.to.indices( arr, small.indices, large.indices, small.n, check.consistency = T )collapse.array.according.to.indices( arr, small.indices, large.indices, small.n, check.consistency = T )
Combine multiple ontology mappings into a single mapping
combine.ontology.mappings(..., thorough.validation = T)combine.ontology.mappings(..., thorough.validation = T)
... |
Either ontology.mapping objects or lists containing ontology.mapping objects#' |
Compare how two simsets score on a likelihood.
compare.sims(likelihood, sim1, sim2, piecewise = T, log = F)compare.sims(likelihood, sim1, sim2, piecewise = T, log = F)
sim1, sim2
|
'jheem.simulation.set' objects to compare |
piecewise |
Should they be compared on each likelihood individually, if a joint likelihood is supplied? |
log |
Whether to use log likelihood |
Compute Likelihood
compute.likelihood( likelihood, sim, log = T, use.optimized.get = F, check.consistency = T, debug = F )compute.likelihood( likelihood, sim, log = T, use.optimized.get = F, check.consistency = T, debug = F )
log |
Whether to use log likelihood |
use.optimized.get |
Should the optimized sim$get be used? The optimized get only works on simsets of the same internal structure as that defined in the specification at the time this likelihood was instantiated, so use it for the MCMC but leave it FALSE for analysis. |
check.consistency |
- Whether to spend time checking to make sure everything is internally consistent. Setting to F is faster, but may generate weird error messages if there are bugs |
Compute Joint Likelihood Piecewise
compute.likelihood.piecewise( likelihood, sim, log = T, use.optimized.get = F, check.consistency = T, debug = F )compute.likelihood.piecewise( likelihood, sim, log = T, use.optimized.get = F, check.consistency = T, debug = F )
log |
Whether to use log likelihood |
use.optimized.get |
Should the optimized sim$get be used? The optimized get only works on simsets of the same internal structure as that defined in the specification at the time this likelihood was instantiated, so use it for the MCMC but leave it FALSE for analysis. |
check.consistency |
- Whether to spend time checking to make sure everything is internally consistent. Setting to F is faster, but may generate weird error messages if there are bugs |
For likelihoods that are not joint likelihoods, this is the same as compute.likelihood()
Copy Calibration Info to a New Code
copy.calibration.info( from.code, to.code, n.iter = NULL, n.burn = NULL, thin = NULL, solver.metadata = NULL )copy.calibration.info( from.code, to.code, n.iter = NULL, n.burn = NULL, thin = NULL, solver.metadata = NULL )
from.code |
The code for the the calibration info to copy |
to.code |
The calibration code to be used for the copied calibration info |
Create a copy of a JHEEM Data Manager
copy.data.manager( data.manager = get.default.data.manager(), name, description, set.as.default = F, preserve.original.creation.date = T, preserve.original.last.modified.date = T )copy.data.manager( data.manager = get.default.data.manager(), name, description, set.as.default = F, preserve.original.creation.date = T, preserve.original.last.modified.date = T )
data.manager |
A jheem.data.manager object to be copied |
name |
The name of the new data manager |
description |
A short description of the new data manager. If NULL, the description of the copied data manager. |
set.as.default |
Should the new data manager be set as the default data manager |
preserve.original.creation.date, preserve.original.last.modified.date
|
Should the new data manager keep the copied data manager's creation date/last modified date (T) or set that date to now (F)? |
Make a copy of a Simulation Set
copy.simulation.set(simset, update.labels = T)copy.simulation.set(simset, update.labels = T)
simset |
The simulation.set object to copy |
update.labels |
Whether to get updated labels from the latest specification (vs the specification as it was when the simulations were created) |
Create JHEEM Basic Likelihood Instructions
create.basic.likelihood.instructions( outcome.for.data, outcome.for.sim, dimensions = character(0), denominator.dimensions = dimensions, dimension.values = NULL, levels.of.stratification = NULL, from.year = -Inf, to.year = Inf, omit.years = NULL, sources.to.use = NULL, minimum.error.sd = 0, correlation.different.years = 0.5, correlation.different.strata = 0.1, correlation.different.sources = 0.3, correlation.same.source.different.details = 0.3, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], error.variance.term = NULL, error.variance.type = NULL, weights = list(), equalize.weight.by.year = T, name = outcome.for.sim, na.rm = NULL )create.basic.likelihood.instructions( outcome.for.data, outcome.for.sim, dimensions = character(0), denominator.dimensions = dimensions, dimension.values = NULL, levels.of.stratification = NULL, from.year = -Inf, to.year = Inf, omit.years = NULL, sources.to.use = NULL, minimum.error.sd = 0, correlation.different.years = 0.5, correlation.different.strata = 0.1, correlation.different.sources = 0.3, correlation.same.source.different.details = 0.3, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], error.variance.term = NULL, error.variance.type = NULL, weights = list(), equalize.weight.by.year = T, name = outcome.for.sim, na.rm = NULL )
outcome.for.data |
A single character vector specifying the outcome that data managers will use to find data. |
outcome.for.sim |
A single character vector specifying the simulation outcome to use. |
dimensions |
A character vector of dimensions, excluding year, from which stratifications will be generated. |
denominator.dimensions |
(Optional) Analogous to 'dimensions' but for the simulation denominator outcome when applicable. Must be a subset of 'dimensions'. |
levels.of.stratification |
An integer vector specifying how the dimensions should be combined to form strata. '0' indicates totals (not stratified) while '1' indicates strata that are each stratified by one dimension at a time, '2' indicates strat that are each stratified by a combination of two dimensions at a time, etc. May not exceed the number of dimensions. Defaults to NULL, which is equivalent to '0'. |
from.year |
-Inf or a single integer value specifying the earliest year for which data should be pulled. |
to.year |
Inf or a single integer value specifying the latest year for which data should be pulled. |
omit.years |
(Optional) An integer vector of years to ignore. |
sources.to.use |
A character vector of sources from which to pull data. |
minimum.error.sd |
A single, positive numeric value. If any standard deviations are calculated to a value below this, they will be replaced with this value. This can help keep the likelihood from computing to negative infinity. |
correlation.different.years |
A single numeric value specifying the correlation between observations of different years. |
correlation.different.strata |
A single numeric value specifying the correlation between observations from different strata. |
correlation.different.sources |
A single numeric value specifying the correlation between observations from different sources. |
correlation.same.source.different.details |
A single numeric value specifying the correlation between observations of the same source but which have different 'details'. |
observation.correlation.form |
Which correlation form to use in building the measurement error covariance matrix. May be 'compound.symmetry' or 'autoregressive.1'. |
error.variance.type, error.variance.term
|
The type of error variance(s) to be used and the corresponding value or function required for each. See details for the allowable values. For more than one type, supply them in a vector. If you therefore need more than one term, supply these in a list. |
weights |
A list containing only numeric vectors and objects of class 'jheem.likelihood.weights', which are generated by |
equalize.weight.by.year |
A Boolean indicating whether every year should be weighted equally before the weights from 'weights' are applied. |
na.rm |
Setting this TRUE will pass 'na.rm=T' along to the pull function. If set to NULL, 'na.rm=T' will be used for outcomes with scale 'proportion', 'rate', or 'ratio'. |
measurement.error.coefficient.of.variance |
A single numeric value specifying the coefficient of variance used to build the measurement error covariance matrix. |
Error variance may be specified in a variety of ways, and more than one can be used in the same likelihood. 'error.variance.type' is a vector containing single character values describing the type(s) of variance to use, and there is one 'error.variance.term' corresponding to each. The types "sd" (standard deviation), "variance", "cv" (covariance), and "exp.of.variance" (exponent of variance) require a single numeric value as their term. The types "data.sd", "data.variance", and "data.cv" indicate that error data will be pulled from the data manager and matched directly to data points, and they require NULL as their term. Finally, the type "function.sd" requires as its term a function that takes only arguments "data", "details", "version", and "location" and returns a numeric array of the same dimensions as "data". Supplying multiple types (and therefore terms) results in the variances created by each being summed prior to use in the measurement error covariance matrix.
As an example, one type could be specified with an 'error.variance.type' of "cv" and an 'error.variance.term' of 0.13 (or list(0.13)). Two or more types might look like an 'error.variance.type' of 'c("data.sd", "function.sd") and an 'error.variance.term' of list(NULL, my_sd_function). It is possible to use the same type multiple times, although this is not recommended.
Other Basic Likelihoods:
create.basic.likelihood.instructions.with.included.multiplier(),
create.basic.likelihood.instructions.with.specified.outcome(),
create.time.lagged.comparison.likelihood.instructions(),
create.time.lagged.comparison.likelihood.instructions.with.included.multiplier()
Create JHEEM Basic Likelihood Instructions With Included Multiplier
create.basic.likelihood.instructions.with.included.multiplier( outcome.for.data, outcome.for.sim, dimensions = character(0), denominator.dimensions = dimensions, dimension.values = NULL, levels.of.stratification = NULL, from.year = -Inf, to.year = Inf, omit.years = NULL, sources.to.use = NULL, minimum.error.sd = 0, included.multiplier, included.multiplier.sd, included.multiplier.correlation = NULL, included.multiplier.correlation.structure = c("compound.symmetry", "autoregressive.1")[1], correlation.different.years = 0.5, correlation.different.strata = 0.1, correlation.different.sources = 0.3, correlation.same.source.different.details = 0.3, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], error.variance.term = NULL, error.variance.type = NULL, weights = list(), equalize.weight.by.year = T, name = outcome.for.sim, na.rm = NULL )create.basic.likelihood.instructions.with.included.multiplier( outcome.for.data, outcome.for.sim, dimensions = character(0), denominator.dimensions = dimensions, dimension.values = NULL, levels.of.stratification = NULL, from.year = -Inf, to.year = Inf, omit.years = NULL, sources.to.use = NULL, minimum.error.sd = 0, included.multiplier, included.multiplier.sd, included.multiplier.correlation = NULL, included.multiplier.correlation.structure = c("compound.symmetry", "autoregressive.1")[1], correlation.different.years = 0.5, correlation.different.strata = 0.1, correlation.different.sources = 0.3, correlation.same.source.different.details = 0.3, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], error.variance.term = NULL, error.variance.type = NULL, weights = list(), equalize.weight.by.year = T, name = outcome.for.sim, na.rm = NULL )
outcome.for.data |
A single character vector specifying the outcome that data managers will use to find data. |
outcome.for.sim |
A single character vector specifying the simulation outcome to use. |
dimensions |
A character vector of dimensions, excluding year, from which stratifications will be generated. |
denominator.dimensions |
(Optional) Analogous to 'dimensions' but for the simulation denominator outcome when applicable. Must be a subset of 'dimensions'. |
levels.of.stratification |
An integer vector specifying how the dimensions should be combined to form strata. '0' indicates totals (not stratified) while '1' indicates strata that are each stratified by one dimension at a time, '2' indicates strat that are each stratified by a combination of two dimensions at a time, etc. May not exceed the number of dimensions. Defaults to NULL, which is equivalent to '0'. |
from.year |
-Inf or a single integer value specifying the earliest year for which data should be pulled. |
to.year |
Inf or a single integer value specifying the latest year for which data should be pulled. |
omit.years |
(Optional) An integer vector of years to ignore. |
sources.to.use |
A character vector of sources from which to pull data. |
minimum.error.sd |
A single, positive numeric value. If any standard deviations are calculated to a value below this, they will be replaced with this value. This can help keep the likelihood from computing to negative infinity. |
included.multiplier |
The value of the multiplier that has already been used in calculating the simulation value of the outcome (represents the mean of the distribution around the multiplier). |
included.multiplier.sd |
The standard deviation of the uncertainty around the included multiplier. |
included.multiplier.correlation |
The correlation between values of the multiplier across different strata and years. |
included.multiplier.correlation.structure |
Which correlation form to use for values of the multiplier across various strata and years. |
correlation.different.years |
A single numeric value specifying the correlation between observations of different years. |
correlation.different.strata |
A single numeric value specifying the correlation between observations from different strata. |
correlation.different.sources |
A single numeric value specifying the correlation between observations from different sources. |
correlation.same.source.different.details |
A single numeric value specifying the correlation between observations of the same source but which have different 'details'. |
observation.correlation.form |
Which correlation form to use in building the measurement error covariance matrix. May be 'compound.symmetry' or 'autoregressive.1'. |
error.variance.type, error.variance.term
|
The type of error variance(s) to be used and the corresponding value or function required for each. See details for the allowable values. For more than one type, supply them in a vector. If you therefore need more than one term, supply these in a list. |
weights |
A list containing only numeric vectors and objects of class 'jheem.likelihood.weights', which are generated by |
equalize.weight.by.year |
A Boolean indicating whether every year should be weighted equally before the weights from 'weights' are applied. |
na.rm |
Setting this TRUE will pass 'na.rm=T' along to the pull function. If set to NULL, 'na.rm=T' will be used for outcomes with scale 'proportion', 'rate', or 'ratio'. |
Error variance may be specified in a variety of ways, and more than one can be used in the same likelihood. 'error.variance.type' is a vector containing single character values describing the type(s) of variance to use, and there is one 'error.variance.term' corresponding to each. The types "sd" (standard deviation), "variance", "cv" (covariance), and "exp.of.variance" (exponent of variance) require a single numeric value as their term. The types "data.sd", "data.variance", and "data.cv" indicate that error data will be pulled from the data manager and matched directly to data points, and they require NULL as their term. Finally, the type "function.sd" requires as its term a function that takes only arguments "data", "details", "version", and "location" and returns a numeric array of the same dimensions as "data". Supplying multiple types (and therefore terms) results in the variances created by each being summed prior to use in the measurement error covariance matrix.
As an example, one type could be specified with an 'error.variance.type' of "cv" and an 'error.variance.term' of 0.13 (or list(0.13)). Two or more types might look like an 'error.variance.type' of 'c("data.sd", "function.sd") and an 'error.variance.term' of list(NULL, my_sd_function). It is possible to use the same type multiple times, although this is not recommended.
Other Basic Likelihoods:
create.basic.likelihood.instructions(),
create.basic.likelihood.instructions.with.specified.outcome(),
create.time.lagged.comparison.likelihood.instructions(),
create.time.lagged.comparison.likelihood.instructions.with.included.multiplier()
Create JHEEM Basic Likelihood Instructions With Specified Outcome
create.basic.likelihood.instructions.with.specified.outcome( outcome.for.sim, outcome.value, from.year, to.year, omit.years = NULL, minimum.error.sd = 0, correlation.different.years = 0.5, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], error.variance.term = NULL, error.variance.type = NULL, weights = list(), equalize.weight.by.year = T, name = outcome.for.sim, na.rm = NULL )create.basic.likelihood.instructions.with.specified.outcome( outcome.for.sim, outcome.value, from.year, to.year, omit.years = NULL, minimum.error.sd = 0, correlation.different.years = 0.5, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], error.variance.term = NULL, error.variance.type = NULL, weights = list(), equalize.weight.by.year = T, name = outcome.for.sim, na.rm = NULL )
outcome.for.sim |
A single character vector specifying the simulation outcome to use. |
outcome.value |
A single, non-NA numeric value that is the value of the outcome at the totals level (i.e., not stratified). |
from.year |
-Inf or a single integer value specifying the earliest year for which data should be pulled. |
to.year |
Inf or a single integer value specifying the latest year for which data should be pulled. |
omit.years |
(Optional) An integer vector of years to ignore. |
minimum.error.sd |
A single, positive numeric value. If any standard deviations are calculated to a value below this, they will be replaced with this value. This can help keep the likelihood from computing to negative infinity. |
correlation.different.years |
A single numeric value specifying the correlation between observations of different years. |
observation.correlation.form |
Which correlation form to use in building the measurement error covariance matrix. May be 'compound.symmetry' or 'autoregressive.1'. |
error.variance.type, error.variance.term
|
The type of error variance(s) to be used and the corresponding value or function required for each. See details for the allowable values. For more than one type, supply them in a vector. If you therefore need more than one term, supply these in a list. |
weights |
A list containing only numeric vectors and objects of class 'jheem.likelihood.weights', which are generated by |
equalize.weight.by.year |
A Boolean indicating whether every year should be weighted equally before the weights from 'weights' are applied. |
na.rm |
Setting this TRUE will pass 'na.rm=T' along to the pull function. If set to NULL, 'na.rm=T' will be used for outcomes with scale 'proportion', 'rate', or 'ratio'. |
Error variance may be specified in a variety of ways, and more than one can be used in the same likelihood. 'error.variance.type' is a vector containing single character values describing the type(s) of variance to use, and there is one 'error.variance.term' corresponding to each. The types "sd" (standard deviation), "variance", "cv" (covariance), and "exp.of.variance" (exponent of variance) require a single numeric value as their term. The types "data.sd", "data.variance", and "data.cv" indicate that error data will be pulled from the data manager and matched directly to data points, and they require NULL as their term. Finally, the type "function.sd" requires as its term a function that takes only arguments "data", "details", "version", and "location" and returns a numeric array of the same dimensions as "data". Supplying multiple types (and therefore terms) results in the variances created by each being summed prior to use in the measurement error covariance matrix.
As an example, one type could be specified with an 'error.variance.type' of "cv" and an 'error.variance.term' of 0.13 (or list(0.13)). Two or more types might look like an 'error.variance.type' of 'c("data.sd", "function.sd") and an 'error.variance.term' of list(NULL, my_sd_function). It is possible to use the same type multiple times, although this is not recommended.
Other Basic Likelihoods:
create.basic.likelihood.instructions(),
create.basic.likelihood.instructions.with.included.multiplier(),
create.time.lagged.comparison.likelihood.instructions(),
create.time.lagged.comparison.likelihood.instructions.with.included.multiplier()
Create Basic Ratio Likelihood Instructions
create.basic.ratio.likelihood.instructions( outcome.for.data, outcome.for.sim, dimensions = character(0), denominator.dimensions = dimensions, dimension.values = NULL, levels.of.stratification = NULL, from.year = -Inf, to.year = Inf, omit.years = NULL, sources.to.use = NULL, correlation.different.years = 0.5, correlation.different.strata = 0.1, correlation.different.sources = 0.3, correlation.same.source.different.details = 0.3, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], error.variance.term = NULL, error.variance.type = NULL, ratio.cv = NULL, ratio.correlation = NULL, weights = list(), equalize.weight.by.year = T, name = outcome.for.sim )create.basic.ratio.likelihood.instructions( outcome.for.data, outcome.for.sim, dimensions = character(0), denominator.dimensions = dimensions, dimension.values = NULL, levels.of.stratification = NULL, from.year = -Inf, to.year = Inf, omit.years = NULL, sources.to.use = NULL, correlation.different.years = 0.5, correlation.different.strata = 0.1, correlation.different.sources = 0.3, correlation.same.source.different.details = 0.3, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], error.variance.term = NULL, error.variance.type = NULL, ratio.cv = NULL, ratio.correlation = NULL, weights = list(), equalize.weight.by.year = T, name = outcome.for.sim )
outcome.for.data |
A single character vector specifying the outcome that data managers will use to find data. |
outcome.for.sim |
A single character vector specifying the simulation outcome to use. |
dimensions |
A character vector of dimensions, excluding year, from which stratifications will be generated. |
denominator.dimensions |
(Optional) Analogous to 'dimensions' but for the simulation denominator outcome when applicable. Must be a subset of 'dimensions'. |
levels.of.stratification |
An integer vector specifying how the dimensions should be combined to form strata. '0' indicates totals (not stratified) while '1' indicates strata that are each stratified by one dimension at a time, '2' indicates strat that are each stratified by a combination of two dimensions at a time, etc. May not exceed the number of dimensions. Defaults to NULL, which is equivalent to '0'. |
from.year |
-Inf or a single integer value specifying the earliest year for which data should be pulled. |
to.year |
Inf or a single integer value specifying the latest year for which data should be pulled. |
omit.years |
(Optional) An integer vector of years to ignore. |
sources.to.use |
A character vector of sources from which to pull data. |
correlation.different.years |
A single numeric value specifying the correlation between observations of different years. |
correlation.different.strata |
A single numeric value specifying the correlation between observations from different strata. |
correlation.different.sources |
A single numeric value specifying the correlation between observations from different sources. |
correlation.same.source.different.details |
A single numeric value specifying the correlation between observations of the same source but which have different 'details'. |
observation.correlation.form |
Which correlation form to use in building the measurement error covariance matrix. May be 'compound.symmetry' or 'autoregressive.1'. |
error.variance.type, error.variance.term
|
The type of error variance(s) to be used and the corresponding value or function required for each. See details for the allowable values. For more than one type, supply them in a vector. If you therefore need more than one term, supply these in a list. |
ratio.cv, ratio.correlation
|
Covariance and correlation coefficients for a compound symmetry matrix representing...? Must be greater than 0, and between -1 and 1, respectively. If 'ratio.cv' is not NULL, 'ratio.correlation' will default to 0. |
weights |
A list containing only numeric vectors and objects of class 'jheem.likelihood.weights', which are generated by |
equalize.weight.by.year |
A Boolean indicating whether every year should be weighted equally before the weights from 'weights' are applied. |
Create Bernoulli Likelihood Instructions
create.bernoulli.likelihood.instructions( outcome.for.sim, years, probability.decreasing, weights, dimensions = character(0), levels.of.stratification = NULL, name = outcome.for.sim )create.bernoulli.likelihood.instructions( outcome.for.sim, years, probability.decreasing, weights, dimensions = character(0), levels.of.stratification = NULL, name = outcome.for.sim )
outcome.for.sim |
A single character vector specifying the simulation outcome to use. |
years |
A length two numeric vector specifying the baseline year (first) and the year which will be assessed against it (second). |
probability.decreasing |
A single numeric value between 0 and 1 specifying probability that the outcome value is lower in the second year than in the first. |
weights |
A list containing only numeric vectors and objects of class 'jheem.likelihood.weights', which are generated by |
dimensions |
A character vector of dimensions, excluding year, from which stratifications will be generated. |
levels.of.stratification |
A numeric vector specifying how the dimensions should be combined to form strata. '0' indicates totals (not stratified) while '1' indicates strata that are each stratified by one dimension at a time, '2' indicates strat that are each stratified by a combination of two dimensions at a time, etc. May not exceed the number of dimensions. Defaults to NULL, which is equivalent to '0'. |
Create instructions for a likelihood that computes using a custom function.
create.custom.likelihood.instructions( name, compute.function, get.data.function = NULL, weights = NULL, verbose = F )create.custom.likelihood.instructions( name, compute.function, get.data.function = NULL, weights = NULL, verbose = F )
compute.function |
A function that takes only arguments "sim", "log", and "weights", with optional "data" and "debug" arguments. |
weights |
A list containing only numeric vectors and objects of class 'jheem.likelihood.weights', which are generated by |
All weights used in the compute function should arrive in its "weights" argument in two ways: From the "weights" argument of the likelihood instructions (which apply to these instructions only), and additional weights passed top-down from joint likelihoods that will include this likelihood. So, no weights should be passed in the "data" function, for example, to maintain consistency and accuracy.
A map from names to data managers. Pass it to using.data.binding or
set.data.binding to build model objects with it.
create.data.binding(...)create.data.binding(...)
... |
Data managers, each named with the name code uses to get it (letters, digits, '.' and '_', starting with a letter), or a single named list of them |
An object of class 'jheem.data.binding'
Create a JHEEM Data Manager
create.data.manager(name, description, set.as.default = F)create.data.manager(name, description, set.as.default = F)
name |
The name of the data manager |
description |
A short description |
Turns 'variable' into an active binding whose value is
get.data.manager(name), so code that reads the variable (for example CENSUS.MANAGER)
gets the manager bound to 'name' in the active binding, and the read is recorded. Assigning a
data manager to the variable registers it under 'name' (see
register.data.manager); this is not allowed while a binding other than the
session's is active or jheem2 is building under one.
If the variable already holds a data manager, it is registered under 'name' unless another manager already is. Aliasing a variable again to the same name does nothing; aliasing it to a different name is an error.
create.data.manager.alias(variable, name, envir = globalenv())create.data.manager.alias(variable, name, envir = globalenv())
variable |
The variable's name, for example 'CENSUS.MANAGER' |
name |
The data manager's name in the binding, for example 'census' |
envir |
The environment holding the variable |
NULL, invisibly
Create instructions that can try a sequence of likelihood instructions until the first one that works without error.
create.ifelse.likelihood.instructions(..., name = NULL)create.ifelse.likelihood.instructions(..., name = NULL)
... |
'jheem.likelihood.instructions' objects that all have the same 'outcome.for.sim'. |
name |
Name for the ifelse; will default to |
The instructions are attempted in the order that they are supplied.
Create an Intervention
create.intervention( ..., code = NULL, name = NULL, parameters = NULL, parameter.distribution = NULL, generate.parameters.function = NULL, overwrite.existing.intervention = F )create.intervention( ..., code = NULL, name = NULL, parameters = NULL, parameter.distribution = NULL, generate.parameters.function = NULL, overwrite.existing.intervention = F )
... |
Either (a) objects of class 'target.population', (b) objects of class 'intervention.effect', or (d) lists containing only 'target.population' or 'intervention.effect' objects. Must contain at least one 'target.population' object and at least one 'intervention.effect' object |
code |
A brief (2-30 character) string that will uniquely identify this intervention |
parameter.distribution |
Creates a 'jheem.intervention' object where all the intervention effects given in ... apply to all the target populations given in ...
Create an Effect for an Intervention to Have on a Model Quantity
create.intervention.effect( quantity.name, start.time, effect.values, times, end.time = Inf, apply.effects.as, scale, allow.values.less.than.otherwise, allow.values.greater.than.otherwise, bindings = NULL, ... )create.intervention.effect( quantity.name, start.time, effect.values, times, end.time = Inf, apply.effects.as, scale, allow.values.less.than.otherwise, allow.values.greater.than.otherwise, bindings = NULL, ... )
quantity.name |
The name of the quantity, defined in a jheem.model.specification, which an intervention affects |
start.time |
The time at which the intervention begins to take effect (ie, depart from what the value of the quantity would otherwise have been) |
effect.values |
The values to apply to the quantity at times. Must be either (1) a numeric vector, (2) a character vector, (3) an expression or call, or (4) a list containing only numeric vectors, character vectors, expressions, or calls |
times |
The times as which values apply to the quantity. |
end.time |
The time at which the intervention stops taking effect (ie, returns to what the value of the quantity otherwise would have been) |
apply.effects.as |
A single character value indicating how values should be applied to the quantity. Choices are (1) 'value' - the quantity takes the given value, (2) 'multiplier' - the value is multiplied by the value the quantity would otherwise have taken, or (3) 'addend' - the value is added to the value the quantity would otherwise have taken. |
scale |
The scale at which values are applied to the quantity |
allow.values.less.than.otherwise, allow.values.greater.than.otherwise
|
Logical indicators of whether the intervention may cause the value of the quantity to be less/greater than it otherwise would have been |
bindings |
A named list. The names must correspond to variables on which the intervention effect applies, if it is a variable. The elements of the list must be either (1) numeric values or (2) functions must take only "location" and "specification.metadata" as arguments and return numeric vectors with no NA values |
... |
Additional arguments to be passed to any bindings which are functions |
Create an Engine to Run JHEEM Simulations
create.jheem.engine( version, location, end.year, sub.version = NULL, max.run.time.seconds = Inf, solver.metadata = NULL )create.jheem.engine( version, location, end.year, sub.version = NULL, max.run.time.seconds = Inf, solver.metadata = NULL )
version, location, sub.version
|
The JHEEM version, sub.version, and location for which to run simulations |
end.year |
The year to run simulations to |
max.run.time.seconds |
The maximum amount of time to run simulations before terminating |
solver.metadata |
A solver.metadata object, as created by |
Create a Model Specification for Running the JHEEM
create.jheem.specification( version, iteration, description, start.year, parent.version = NULL, do.not.inherit.model.quantity.names = character(), do.not.inherit.model.outcome.names = character(), do.not.inherit.transitions.for.dimension = character(), do.not.inherit.components.with.tags = character(), compartments.for.infected.only = list(), compartments.for.uninfected.only = list(), compartments.for.infected.and.uninfected = list(), compartments.for.outcomes = list(), age.endpoints = NULL, compartment.value.aliases = list(), order.locations.by.outcomes = NULL, labels = NULL, default.solver.metadata = NULL )create.jheem.specification( version, iteration, description, start.year, parent.version = NULL, do.not.inherit.model.quantity.names = character(), do.not.inherit.model.outcome.names = character(), do.not.inherit.transitions.for.dimension = character(), do.not.inherit.components.with.tags = character(), compartments.for.infected.only = list(), compartments.for.uninfected.only = list(), compartments.for.infected.and.uninfected = list(), compartments.for.outcomes = list(), age.endpoints = NULL, compartment.value.aliases = list(), order.locations.by.outcomes = NULL, labels = NULL, default.solver.metadata = NULL )
version |
A single character value denoting the version |
iteration |
A single character or numeric value denoting the iteration of the model specification for this version |
description |
A short text description of this version |
start.year |
The numeric year at which simulations should start. If NULL inherits the parent specification's start year |
parent.version |
The character version of the specification from which this new specification should inherit. Must have been registered |
do.not.inherit.model.quantity.names |
A vector of names of model.quantities which should NOT be inherited from ancestor specifications |
do.not.inherit.model.outcome.names |
A vector of names of model outcomes which should NOT be inherited from ancestor specifications |
do.not.inherit.transitions.for.dimension |
A vector of names of dimensions for which transitions should NOT be inherited from ancestor specifications |
do.not.inherit.components.with.tags |
A vector of tags for which core components (transmission, natality, mortality, transitions, aging) should NOT be inherited from ancestor specifications |
compartments.for.infected.only, compartments.for.uninfected.only, compartments.for.infected.and.uninfected, compartments.for.outcomes
|
Named lists of character vectors F@specifying the compartments for uninfected and infected groups, compartments shared by both, or additional compartments that show in the outcomes. The names of the lists represent dimensions, and the values the compartments for each dimension. Compartments can either be string referencing the compartments themselves, or strings representing aliases passed to compartment.value.aliases |
age.endpoints |
Optional. A numeric vector (with at least two elements) giving the endpoints of the age brackets to use for the 'age' dimension. Results in length(age.endpoints)-1 different brackets, where the first bracket spans age.endpoints[1] (inclusive) to age.endpoints[2] (exclusive), the second bracket spans age.endpoints[2] to age.endpoints[3], etc |
compartment.value.aliases |
A named list representing substitutions to be made into compartment names (both in compartments.for.infected.only, compartments.for.uninfected.only, compartments.for.infected.and.uninfected and in subsequent references in registering model quantities). The names of the list represent what is to be replaced. The values of the list can be either (1) character vectors that are substituted in place or (2) functions that take parameter 'location' and return a character vector |
order.locations.by.outcomes |
A character vector of outcome names from a data manager to be referenced in deciding which locations to show if there is a need to prioritize in making plots |
labels |
A named character vector, representing how compartments should be labeled when making figures/charts, etc. Eg c(msm="MSM", idu="PWID") |
Create a Transmuter
create.jheem.transmuter( simulation.set, to.version, from.year = simulation.set$from.year, to.year = simulation.set$to.year, to.sub.version = NULL )create.jheem.transmuter( simulation.set, to.version, from.year = simulation.set$from.year, to.year = simulation.set$to.year, to.sub.version = NULL )
simulation.set |
The simulation.set to transmute |
to.version, to.sub.version
|
The version and sub.version to transmute to |
A jheem.transmuter can convert simulations from one version/specification to another using its transmute() method
Create Weights to Be Applied in Calculating a JHEEM Likelihood
create.likelihood.weights( total.weight = 1, dimension.values = list(), is.recursive = T )create.likelihood.weights( total.weight = 1, dimension.values = list(), is.recursive = T )
total.weight |
The weight that is applied to all observations in the |
is.recursive |
Should this weight apply to deeper levels of stratification? For example, if F and dimension.values is the default empty list, this weight would only apply to data points that are totals. |
Create an Functional Form that is Linear (possibly on a transformed scale)
create.linear.functional.form( intercept, slope, anchor.year, link = c("identity", "log", "logit")[1], min = NA, max = NA, intercept.link = NULL, intercept.min = NA, intercept.max = NA, intercept.robust.to.negative = F, slope.link = intercept.link, slope.min = NA, slope.max = NA, slope.robust.to.negative = F, parameters.are.on.transformed.scale = T, overwrite.parameters.with.alphas = F, error.prefix = "Cannot create linear functional.form: " )create.linear.functional.form( intercept, slope, anchor.year, link = c("identity", "log", "logit")[1], min = NA, max = NA, intercept.link = NULL, intercept.min = NA, intercept.max = NA, intercept.robust.to.negative = F, slope.link = intercept.link, slope.min = NA, slope.max = NA, slope.robust.to.negative = F, parameters.are.on.transformed.scale = T, overwrite.parameters.with.alphas = F, error.prefix = "Cannot create linear functional.form: " )
intercept, slope
|
Arrays or scalar values representing the intercept and slope on the transformed scale |
anchor.year |
The year at which the functional form evaluates to the intercept |
link |
The name of the transformation to the scale on which alphas are added to the value. One of "identity", "log", "logit" |
min, max
|
The minimum and maximum values this functional form can create. The default (NA) sets to the min/max for the link specified (eg, 0-Inf for a log link, 0-1 for a logistic link) |
intercept.link, slope.link
|
The names of the transformations to the scale on which alphas are added to calculate the intercept and slope. One of "identity", "log", "logit". If NULL, inferred automatically from the link for the entire functional form |
intercept.min, intercept.max, slope.min, slope.max
|
The min and max values to which intercept and slope can evaluate |
overwrite.parameters.with.alphas |
Logical indicating whether, when alphas are applied, they OVERWRITE values. If F, alphas are added to the transformed value (on the transformed scale) |
error.prefix |
String to prepend to any error message in case of an error |
parameters.is.on.transformed.scale |
Logical indicating whether the intercept and slope are already on the transformed scale at which alphas apply |
intercept.robust.intercept.linkto.negative, slope.robust.to.negative
|
Whether intercept and slope should be allowed to be negative, even if a log or logit link is used (this is handled by letting the the alphas apply to the negative of the parameter, then negating it) |
create.static.functional.form, create.log.linear.functional.form, create.logistic.linear.functional.form
Create a Linear Spline Functional Form
create.linear.spline.functional.form( knot.times, knot.values, link = c("identity", "log", "logit")[1], min = NA, max = NA, knot.link = link, knot.min = min, knot.max = max, knots.are.on.transformed.scale = F, overwrite.knot.values.with.alphas = F, before.time = NULL, before.modifier = NULL, after.time = NULL, after.modifier = NULL, modifiers.apply.to.change = T, modifier.link = link, after.modifier.increasing.change.link = modifier.link, after.modifier.decreasing.change.link = modifier.link, before.modifier.increasing.change.link = modifier.link, before.modifier.decreasing.change.link = modifier.link, modifier.min = min, modifier.max = max, overwrite.modifiers.with.alphas = F, error.prefix = "Cannot create linear spline functional.form: " )create.linear.spline.functional.form( knot.times, knot.values, link = c("identity", "log", "logit")[1], min = NA, max = NA, knot.link = link, knot.min = min, knot.max = max, knots.are.on.transformed.scale = F, overwrite.knot.values.with.alphas = F, before.time = NULL, before.modifier = NULL, after.time = NULL, after.modifier = NULL, modifiers.apply.to.change = T, modifier.link = link, after.modifier.increasing.change.link = modifier.link, after.modifier.decreasing.change.link = modifier.link, before.modifier.increasing.change.link = modifier.link, before.modifier.decreasing.change.link = modifier.link, modifier.min = min, modifier.max = max, overwrite.modifiers.with.alphas = F, error.prefix = "Cannot create linear spline functional.form: " )
knot.times |
The (numeric) times at which the knots of the spline apply. Must have names set |
knot.values |
Initial values for the knots. Must have names set, matching the names of knot times |
link |
The name of a transformation to the scale at which the SPLINE should apply. The knots are transformed to this scale, the spline is applied, and then the splined values are back-transformed. One of 'identity', 'log', or 'logistic' |
min, max
|
The minimum and maximum values this functional form can create. The default (NA) sets to the min/max for the link specified (eg, 0-Inf for a log link, 0-1 for a logistic link) |
knot.link |
The name of a transformation to the scale at which the knot values have alphas ADDED. The knots are back-transformed from this scale prior to the spline scale being applied |
knot.min, knot.max
|
The min and max values that KNOTS can take before being splined (note, the min and max values the functional form can take, after splining, are determined by parameters min and max) |
knots.are.on.transformed.scale |
Logical indicating whether the knots are already on the transformed scale (ie knot.link has been applied) |
before.time, after.time
|
The times at which the knots calculated from before.modifier and after.modifier apply, respectively |
before.modifier, after.modifier
|
If either of these is set, an additional knot is added to the specified knots. For before.modifier, this knot is calculated as before.modifier added or multiplier by the value of the first knot (on the model scale); after.modifier is added or multiplied by the value of the last knot |
modifiers.apply.to.change |
If TRUE, after.modifier (the untransformed-by-link value) is multiplied by the change between the penultimate and last knots and added to the last knot to generate an additional knot at after.time (similarly, before.modifier is multiplied by the change from the first to the second and subtracted from the first). If FALSE, the transformed after.multiplier is added to the last knot after the last knot is transformed to modifier.link scale, and the resulting value is back-transformed to yield the knot at after.time (similarly, before.modifier is added to the first knot on modifier.link scale) |
modifier.link |
The name of a transformation to the scale at which the before.modifer and after.modifier have alphas added |
modifier.min, modifier.max
|
The min and max values for before.modifier and after.modifier |
overwrite.modifiers.with.alphas |
Logical indicating whether, when alphas are applied to the before.modifier or after.modifier, they OVERWRITE the modifiers. If F, alphas are added on the scale specified by modifier.link |
error.prefix |
String to prepend to any error message in case of an error |
Create instructions that can instantiate a different 'jheem.likelihood' depending on the location.
create.location.based.ifelse.likelihood.instructions( ..., name = NULL, locations.list = list() )create.location.based.ifelse.likelihood.instructions( ..., name = NULL, locations.list = list() )
... |
'jheem.likelihood.instructions' objects that all have the same 'outcome.for.sim'. |
name |
Name for the ifelse; will default to |
locations.list |
A list of character vectors of locations that will use the corresponding instruction. The list should be length one shorter than the number of instructions. For example, if you have three instructions, the first vector has locations that will use the first instruction and second vector has locations that will use the second instruction. The third instruction will be used for all other locations. |
Create a Functional Form that is Linear on the Log Scale
create.log.linear.functional.form( intercept, slope, anchor.year, min = 0, max = Inf, parameters.are.on.log.scale = T, overwrite.parameters.with.alphas = F, error.prefix = "Cannot create log-linear functional.form: " )create.log.linear.functional.form( intercept, slope, anchor.year, min = 0, max = Inf, parameters.are.on.log.scale = T, overwrite.parameters.with.alphas = F, error.prefix = "Cannot create log-linear functional.form: " )
intercept, slope
|
Arrays or scalar values representing the intercept and slope on the log scale |
anchor.year |
The year at which the functional form evaluates to the intercept |
min, max
|
The minimum and maximum values this functional form can create. The default (NA) sets to the min/max for the link specified (eg, 0-Inf for a log link, 0-1 for a logistic link) |
parameters.are.on.log.scale |
Logical indicating whether the intercept and slope are already on the log scale |
overwrite.parameters.with.alphas |
Logical indicating whether, when alphas are applied, they OVERWRITE values. If F, alphas are added to the transformed value (on the transformed scale) |
error.prefix |
String to prepend to any error message in case of an error |
create.static.functional.form, create.linear.functional.form, create.logistic.linear.functional.form
Create a Functional Form that is Linear on the Logistic Scale
create.logistic.linear.functional.form( intercept, slope, anchor.year, min = 0, max = 1, parameters.are.on.logit.scale = T, overwrite.parameters.with.alphas = F, error.prefix = "Cannot create logistic-linear functional.form: " )create.logistic.linear.functional.form( intercept, slope, anchor.year, min = 0, max = 1, parameters.are.on.logit.scale = T, overwrite.parameters.with.alphas = F, error.prefix = "Cannot create logistic-linear functional.form: " )
intercept, slope
|
Arrays or scalar values representing the intercept and slope on the logistic scale |
anchor.year |
The year at which the functional form evaluates to the intercept |
min, max
|
The minimum and maximum values this functional form can create. The default (NA) sets to the min/max for the link specified (eg, 0-Inf for a log link, 0-1 for a logistic link) |
parameters.are.on.logit.scale |
Logical indicating whether the intercept and slope are already on the logistic scale |
overwrite.parameters.with.alphas |
Logical indicating whether, when alphas are applied, they OVERWRITE values. If F, alphas are added to the transformed value (on the transformed scale) |
error.prefix |
String to prepend to any error message in case of an error |
create.static.functional.form, create.linear.functional.form, create.log.linear.functional.form
Create a Logistic Spline Functional Form
create.logistic.spline.functional.form( knot.times, knot.values, min = -Inf, max = Inf, knot.link = c("identity", "log", "logit")[2], knot.min = NA, knot.max = NA, knots.are.on.transformed.scale = F, overwrite.knot.values.with.alphas = F, fraction.of.asymptote.after.end = 0.05, fraction.of.asymptote.before.start = 0.025, fraction.of.asymptote.for.change.dir = 0.02, fraction.asymptote.link = "log", overwrite.fraction.asymptote.with.alphas = F, error.prefix = "Cannot create logistic spline functional.form: " )create.logistic.spline.functional.form( knot.times, knot.values, min = -Inf, max = Inf, knot.link = c("identity", "log", "logit")[2], knot.min = NA, knot.max = NA, knots.are.on.transformed.scale = F, overwrite.knot.values.with.alphas = F, fraction.of.asymptote.after.end = 0.05, fraction.of.asymptote.before.start = 0.025, fraction.of.asymptote.for.change.dir = 0.02, fraction.asymptote.link = "log", overwrite.fraction.asymptote.with.alphas = F, error.prefix = "Cannot create logistic spline functional.form: " )
knot.times |
The (numeric) times at which the knots of the spline apply. Must have names set |
knot.values |
Initial values for the knots. Must have names set, matching the names of knot times |
min, max
|
The minimum and maximum values this functional form can create. The default (NA) sets to the min/max for the link specified (eg, 0-Inf for a log link, 0-1 for a logistic link) |
knot.link |
The name of a transformation to the scale at which the knot values have alphas ADDED. The knots are back-transformed from this scale prior to the spline scale being applied |
knot.min, knot.max
|
The min and max values that KNOTS can take before being splined (note, the min and max values the functional form can take, after splining, are determined by parameters min and max) |
knots.are.on.transformed.scale |
Logical indicating whether the knots are already on the transformed scale (ie knot.link has been applied) |
fraction.of.asymptote.after.end, fraction.of.asymptote.before.start
|
The fraction of the total change in the first or last segment that would take place before the first knot or after the last |
fraction.of.asymptote.for.change.dir |
The fraction of the total change in a segment that should take place before between two segments |
fraction.asymptote.link |
The name of a transformation to the scale at which alphas are added to the betas for the fraction.asymptote.<x> values |
overwrite.fraction.asymptote.with.alphas |
Logical indicating whether, when alphas are applied to the fraction.of.asymptote.<x>, they OVERWRITE the values. If F, alphas are interpreted as either additive or multiplicative to the knot.values, depending on the value of fraction.asymptote.alphas.are.multipliers |
error.prefix |
String to prepend to any error message in case of an error |
Create a "Logistic Tail" Functional Form
create.logistic.tail.functional.form( intercept, slope, anchor.year, logistic.after.frac.of.span = 0.5, min = 0, max = 1, intercept.link = "logistic", intercept.min = NA, intercept.max = NA, intercept.robust.to.negative = F, slope.link = intercept.link, slope.min = NA, slope.max = NA, slope.robust.to.negative = F, parameters.are.on.transformed.scale = F, overwrite.parameters.with.alphas = F, error.prefix = "Cannot create logistic-tail functional.form: " )create.logistic.tail.functional.form( intercept, slope, anchor.year, logistic.after.frac.of.span = 0.5, min = 0, max = 1, intercept.link = "logistic", intercept.min = NA, intercept.max = NA, intercept.robust.to.negative = F, slope.link = intercept.link, slope.min = NA, slope.max = NA, slope.robust.to.negative = F, parameters.are.on.transformed.scale = F, overwrite.parameters.with.alphas = F, error.prefix = "Cannot create logistic-tail functional.form: " )
intercept, slope
|
Scalar values or arrays representing the intercept and slope. Note that the final form constrains the slope to be non-negative |
anchor.year |
The year at which the functional form evaluates to the intercept |
logistic.after.frac.of.span |
The fraction of the the total span (max - min) after which the model follows a logistic curve |
min, max
|
The upper and lower limits to which the functional form can evaluate |
intercept.link, slope.link
|
The names of the transformations to the scale on which alphas are added to calculate the intercept and slope. One of "identity", "log", "logit" |
intercept.min, intercept.max, slope.min, slope.max
|
The min and max values to which intercept and slope can evaluate |
overwrite.parameters.with.alphas |
Logical indicating whether, when alphas are applied, they OVERWRITE values. If F, alphas are added to the transformed value (on the transformed scale) |
error.prefix |
String to prepend to any error message in case of an error |
A "logistic tail" functional form follows a linear (intercept + slope) in its first part, and a logistic-linear form in its second part. This allows a linear trend to taper off
Create a Model Foreground Object
create.model.foreground(..., error.prefix = "")create.model.foreground(..., error.prefix = "")
... |
The intervention.effects and target.populations for this foreground. Can be either: (1) an alternating set of jheem.intervention.effect objects and target.population objects (ie, one intervention.effect followed by one target.population, then the next pair, or vice versa) or (2) one list of intervention effects and one list of target populations, both of the same length |
A model foreground object applies multiple effects to multiple subpopulations *simultaneously*, with all effects targeting the same model quantity
Create a "Guess-and-Check" Intervention that Must Satisfy Some Criteria by Varying Parameters
create.monotonic.criteria.based.intervention( base.intervention, completion.criteria, max.iterations, n.iterations.after.satisfying.criteria = 5, max.iterations.first.sim = max.iterations, n.iterations.after.satisfying.criteria.first.sim = ceiling(max.iterations.first.sim/2), max.failure.rate = 0, discount.prior.n = 0.5, code = NULL, name = NULL, overwrite.existing.intervention = F )create.monotonic.criteria.based.intervention( base.intervention, completion.criteria, max.iterations, n.iterations.after.satisfying.criteria = 5, max.iterations.first.sim = max.iterations, n.iterations.after.satisfying.criteria.first.sim = ceiling(max.iterations.first.sim/2), max.failure.rate = 0, discount.prior.n = 0.5, code = NULL, name = NULL, overwrite.existing.intervention = F )
base.intervention |
A single.iteration.intervention, as created by |
completion.criteria |
Either a single jheem.intervention.criterion object, as created by |
max.iterations |
The maximum number of iterations to run in trying to satisfy intervention criteria. If criteria are not satisfied after max.iterations, will 'give up' (and either produce degenerate simulations or throw an error, depending on max.failure.rate) |
n.iterations.after.satisfying.criteria |
The number of iterations to run after we have satisfied the criteria to try to get as close as possible to the target |
max.failure.rate |
The maximum proportion of simulations in a simulation set which can fail to find a solution that satisfies intervention criteria within max.iterations. If this threshold is exceeded, will throw an error; otherwise, will return degenerate simulations when it could not find a solution |
code |
A brief (2-30 character) string that will uniquely identify this intervention |
Create a criterion for monotonic parameter, criteria-based interventions
create.monotonic.criterion( parameter.name, outcome, parameter.scale, parameter.initial.value, min.acceptable.parameter.value = NULL, max.acceptable.parameter.value = NULL, target.value, min.acceptable.value, max.acceptable.value, subsequent.thresholds.apply.after.iteration = numeric(), dimension.values = list(), draw.parameter.from.previous.sims = !is.function(parameter.initial.value), ... )create.monotonic.criterion( parameter.name, outcome, parameter.scale, parameter.initial.value, min.acceptable.parameter.value = NULL, max.acceptable.parameter.value = NULL, target.value, min.acceptable.value, max.acceptable.value, subsequent.thresholds.apply.after.iteration = numeric(), dimension.values = list(), draw.parameter.from.previous.sims = !is.function(parameter.initial.value), ... )
parameter.name |
The name of the parameter to be modified to achieve the outcome |
outcome |
A character vector indicating the name of the outcome to which the criterion applies |
parameter.scale |
The scale on which the parameter operates |
parameter.initial.value |
Either a single scalar numeric or a function that takes argument sim and returns a single scalar numeric |
min.acceptable.parameter.value, max.acceptable.parameter.value
|
Indicators of the min and max possible values of the parameter to prevent unreasonably large (or small) parameter values crashing the algorithm. Must be single, numeric values or NULL, in which case the limits allowed by the 'parameter.scale' will be used. |
target.value |
A single, numeric value that we want the outcome to get to |
min.acceptable.value, max.acceptable.value
|
Indicators of the min and max possible values of the outcome we would be willing to accept. Must be either (1) single, numeric values or (2) numeric vectors. In this case, the first values are the min/max threshold until subsequent.thresholds.apply.after.iteration[1], the second values are the thresholds prior to subsequent.thresholds.apply.after.iteration[2], etc |
subsequent.thresholds.apply.after.iteration |
The number of iterations after which the 2nd, 3rd, etc thresholds in min.acceptable.value, max.acceptable.value apply |
dimension.values |
The dimension values for which we should pull the outcome. Must be a named list of either character vectors, integer vectors, or logical vectors |
... |
An alternative way of supplying dimensions values - must be named character vectors, integer vectors, or logical vectors |
draw.parameters.from.previous.sims |
Whether the initial value for the parameter after the first simulation in a set should be the given initial value, or should be based on what worked for previous simulations in the set |
If the intervention algorithm finds it needs to keep raising (or lowering) the parameter value so high (or low) that it reaches the bounds, the parameter will be considered optimized. This often occurs when the parameter's outcome is already beyond the target and would be generally deemed acceptable anyway.
Create a Natural Spline Functional Form
create.natural.spline.functional.form( knot.times, knot.values, link = c("identity", "log", "logit")[1], min = NA, max = NA, knot.link = link, knot.min = min, knot.max = max, knots.are.on.transformed.scale = F, overwrite.knot.values.with.alphas = F, before.time = NULL, before.modifier = NULL, after.time = NULL, after.modifier = NULL, modifiers.apply.to.change = T, modifier.link = link, after.modifier.increasing.change.link = modifier.link, after.modifier.decreasing.change.link = modifier.link, before.modifier.increasing.change.link = modifier.link, before.modifier.decreasing.change.link = modifier.link, modifier.min = min, modifier.max = max, overwrite.modifiers.with.alphas = F, error.prefix = "Cannot create natural spline functional.form: " )create.natural.spline.functional.form( knot.times, knot.values, link = c("identity", "log", "logit")[1], min = NA, max = NA, knot.link = link, knot.min = min, knot.max = max, knots.are.on.transformed.scale = F, overwrite.knot.values.with.alphas = F, before.time = NULL, before.modifier = NULL, after.time = NULL, after.modifier = NULL, modifiers.apply.to.change = T, modifier.link = link, after.modifier.increasing.change.link = modifier.link, after.modifier.decreasing.change.link = modifier.link, before.modifier.increasing.change.link = modifier.link, before.modifier.decreasing.change.link = modifier.link, modifier.min = min, modifier.max = max, overwrite.modifiers.with.alphas = F, error.prefix = "Cannot create natural spline functional.form: " )
knot.times |
The (numeric) times at which the knots of the spline apply. Must have names set |
knot.values |
Initial values for the knots. Must have names set, matching the names of knot times |
link |
The name of a transformation to the scale at which the SPLINE should apply. The knots are transformed to this scale, the spline is applied, and then the splined values are back-transformed. One of 'identity', 'log', or 'logistic' |
min, max
|
The minimum and maximum values this functional form can create. The default (NA) sets to the min/max for the link specified (eg, 0-Inf for a log link, 0-1 for a logistic link) |
knot.link |
The name of a transformation to the scale at which the knot values have alphas ADDED. The knots are back-transformed from this scale prior to the spline scale being applied |
knot.min, knot.max
|
The min and max values that KNOTS can take before being splined (note, the min and max values the functional form can take, after splining, are determined by parameters min and max) |
knots.are.on.transformed.scale |
Logical indicating whether the knots are already on the transformed scale (ie knot.link has been applied) |
before.time, after.time
|
The times at which the knots calculated from before.modifier and after.modifier apply, respectively |
before.modifier, after.modifier
|
If either of these is set, an additional knot is added to the specified knots. For before.modifier, this knot is calculated as before.modifier added or multiplier by the value of the first knot (on the model scale); after.modifier is added or multiplied by the value of the last knot |
modifiers.apply.to.change |
If TRUE, after.modifier (the untransformed-by-link value) is multiplied by the change between the penultimate and last knots and added to the last knot to generate an additional knot at after.time (similarly, before.modifier is multiplied by the change from the first to the second and subtracted from the first). If FALSE, the transformed after.multiplier is added to the last knot after the last knot is transformed to modifier.link scale, and the resulting value is back-transformed to yield the knot at after.time (similarly, before.modifier is added to the first knot on modifier.link scale) |
modifier.link |
The name of a transformation to the scale at which the before.modifer and after.modifier have alphas added |
modifier.min, modifier.max
|
The min and max values for before.modifier and after.modifier |
overwrite.modifiers.with.alphas |
Logical indicating whether, when alphas are applied to the before.modifier or after.modifier, they OVERWRITE the modifiers. If F, alphas are added on the scale specified by modifier.link |
error.prefix |
String to prepend to any error message in case of an error |
Create Nested Proportion Likelihood Instructions
create.nested.proportion.likelihood.instructions( outcome.for.data, denominator.outcome.for.data, outcome.for.sim, outcome.for.n.multipliers = denominator.outcome.for.data, location.types, minimum.geographic.resolution.type, maximum.locations.per.type = 3, dimensions = NULL, levels.of.stratification = 0:length(dimensions), from.year = -Inf, to.year = Inf, omit.years = NULL, sources.to.use = NULL, exclude.denominator.ontology.names = NULL, location.overall.keep.threshold = 5, location.stratum.keep.threshold = 1, p.bias.inside.location, p.bias.outside.location, p.bias.sd.inside.location, p.bias.sd.outside.location, within.location.p.error.correlation = 0.5, within.location.n.error.correlation = 0.5, minimum.error.sd = 0, correlation.different.locations = 0, correlation.different.years = 0.5, correlation.different.strata = 0.1, correlation.different.sources = 0.3, correlation.same.source.different.details = 0.3, obs.n.correlation.different.years = within.location.n.error.correlation, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], n.multiplier.cv = 0.1, p.error.variance.term = NULL, p.error.variance.type = NULL, n.error.variance.term = 0.05, n.error.variance.type = "cv", n.error.variance.term.if.estimated = 0.8, n.error.variance.type.if.estimated = "exp.of.variance", weights = list(), equalize.weight.by.year = T, partitioning.function, name = outcome.for.sim )create.nested.proportion.likelihood.instructions( outcome.for.data, denominator.outcome.for.data, outcome.for.sim, outcome.for.n.multipliers = denominator.outcome.for.data, location.types, minimum.geographic.resolution.type, maximum.locations.per.type = 3, dimensions = NULL, levels.of.stratification = 0:length(dimensions), from.year = -Inf, to.year = Inf, omit.years = NULL, sources.to.use = NULL, exclude.denominator.ontology.names = NULL, location.overall.keep.threshold = 5, location.stratum.keep.threshold = 1, p.bias.inside.location, p.bias.outside.location, p.bias.sd.inside.location, p.bias.sd.outside.location, within.location.p.error.correlation = 0.5, within.location.n.error.correlation = 0.5, minimum.error.sd = 0, correlation.different.locations = 0, correlation.different.years = 0.5, correlation.different.strata = 0.1, correlation.different.sources = 0.3, correlation.same.source.different.details = 0.3, obs.n.correlation.different.years = within.location.n.error.correlation, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], n.multiplier.cv = 0.1, p.error.variance.term = NULL, p.error.variance.type = NULL, n.error.variance.term = 0.05, n.error.variance.type = "cv", n.error.variance.term.if.estimated = 0.8, n.error.variance.type.if.estimated = "exp.of.variance", weights = list(), equalize.weight.by.year = T, partitioning.function, name = outcome.for.sim )
outcome.for.data |
A single character vector specifying the outcome that data managers will use to find data. |
outcome.for.sim |
A single character vector specifying the simulation outcome to use. |
location.types |
The types of the locations that contain or are contained by the model location. These should be in order of decreasing preference since in the case that two locations have the same contained 'minimum.geographic.resolution.type', such as county "11001" and state "DC", only the higher priority type location will be used. |
minimum.geographic.resolution.type |
The type of location used to partition locations. The type of the model location AND 'location.types' types must all completely enclose regions of this type |
dimensions |
A character vector of dimensions, excluding year, from which stratifications will be generated. |
levels.of.stratification |
An integer vector specifying how the dimensions should be combined to form strata. '0' indicates totals (not stratified) while '1' indicates strata that are each stratified by one dimension at a time, '2' indicates strat that are each stratified by a combination of two dimensions at a time, etc. May not exceed the number of dimensions. Defaults to NULL, which is equivalent to '0'. |
from.year |
-Inf or a single integer value specifying the earliest year for which data should be pulled. |
to.year |
Inf or a single integer value specifying the latest year for which data should be pulled. |
omit.years |
(Optional) An integer vector of years to ignore. |
sources.to.use |
A character vector of sources from which to pull data. |
location.overall.keep.threshold, location.stratum.keep.threshold
|
How many data points a location must offer beyond what is found for the main location to justify being retained. Either overall (across ALL strata in total) or on a stratum-by-stratum basis. If a location doesn't meet the overall threshold, it will be ignored entirely. If it does, but fails to meet the stratum threshold for a certain stratum, it will be ignored only in that stratum. |
p.bias.inside.location, p.bias.outside.location, p.bias.sd.inside.location, p.bias.sd.outside.location
|
A single numeric value specifying the bias in the outcome proportion between locations inside (or outside) the model location and the model location itself, and their associated standard deviations. Each of these may alternatively be a function that takes only arguments 'version' and 'location' and returns an acceptable numeric value. For the estimates, values should be between -1 and 1, inclusive. For sd, should be non-negative and non-infinite. The bias should = outside/inside location MINUS main location (eg, state - MSA or county - MSA) |
within.location.p.error.correlation, within.location.n.error.correlation
|
Single numeric values specifying the correlation between p or n values from the same location and stratum |
minimum.error.sd |
A single, positive numeric value. If any standard deviations are calculated to a value below this, they will be replaced with this value. This can help keep the likelihood from computing to negative infinity. |
correlation.different.locations |
A single numeric value specifying the correlation between observations of different locations. |
correlation.different.years |
A single numeric value specifying the correlation between observations of different years. |
correlation.different.strata |
A single numeric value specifying the correlation between observations from different strata. |
correlation.different.sources |
A single numeric value specifying the correlation between observations from different sources. |
correlation.same.source.different.details |
A single numeric value specifying the correlation between observations of the same source but which have different 'details'. |
obs.n.correlation.different.years |
Single numeric value specifying the correlation between different calculated obs n values |
observation.correlation.form |
Which correlation form to use in building the measurement error covariance matrix. May be 'compound.symmetry' or 'autoregressive.1'. |
n.multiplier.cv |
A single numeric value specifying the covariance term used to find the n.multipliers. |
p.error.variance.type, p.error.variance.term
|
The type of error variance(s) to be used for the outcome proportion and the corresponding value or function required for each. See details for the allowable values. For more than one type, supply them in a vector. If you therefore need more than one term, supply these in a list. |
n.error.variance.type, n.error.variance.type
|
The 'p.error.variance.type/term' analog for the denominator outcome. Has fewer options of type. See details for more information. |
weights |
A list containing only numeric vectors and objects of class 'jheem.likelihood.weights', which are generated by |
equalize.weight.by.year |
A Boolean indicating whether every year should be weighted equally before the weights from 'weights' are applied. |
partitioning.function |
A function that partitions values in the data ontology into values in the model ontology. Must have two arguments, "arr" and "version" and return an array with the same dimnames as the input array. |
P error variance may be specified in a variety of ways, and more than one can be used in the same likelihood. 'error.variance.type' is a vector containing single character values describing the type(s) of variance to use, and there is one 'error.variance.term' corresponding to each. The types "sd" (standard deviation), "variance", "cv" (covariance), and "exp.of.variance" (exponent of variance) require a single numeric value as their term. The types "data.sd", "data.variance", and "data.cv" indicate that error data will be pulled from the data manager and matched directly to data points, and they require NULL as their term. Finally, the type "function.sd" requires as its term a function that takes only arguments "data", "details", "version", and "location" and returns a numeric array of the same dimensions as "data". Supplying multiple types (and therefore terms) results in the variances created by each being summed prior to use in the measurement error covariance matrix.
As an example, one type could be specified with a 'p.error.variance.type' of "cv" and a 'p.error.variance.term' of 0.13 (or list(0.13)). Two or more types might look like a 'p.error.variance.type' of 'c("data.sd", "function.sd") and a 'p.error.variance.term' of list(NULL, my_sd_function). It is possible to use the same type multiple times, although this is not recommended.
N error variance works the same way but only one type is currently supported: "cv" (covariance).
Other Nested Proportion Likelihoods:
create.nested.proportion.likelihood.instructions.with.included.multiplier(),
create.time.lagged.comparison.nested.proportion.likelihood.instructions(),
get.p.bias.estimates()
Create Nested Proportion Likelihood Instructions With Included Multiplier
create.nested.proportion.likelihood.instructions.with.included.multiplier( outcome.for.data, denominator.outcome.for.data, outcome.for.sim, outcome.for.n.multipliers = denominator.outcome.for.data, location.types, minimum.geographic.resolution.type, maximum.locations.per.type = 3, dimensions = NULL, levels.of.stratification = 0:length(dimensions), from.year = -Inf, to.year = Inf, omit.years = NULL, sources.to.use = NULL, exclude.denominator.ontology.names = NULL, location.overall.keep.threshold = 5, location.stratum.keep.threshold = 1, included.multiplier, included.multiplier.sd, included.multiplier.correlation = NULL, included.multiplier.correlation.structure = c("compound.symmetry", "autoregressive.1")[1], p.bias.inside.location, p.bias.outside.location, p.bias.sd.inside.location, p.bias.sd.outside.location, within.location.p.error.correlation = 0.5, within.location.n.error.correlation = 0.5, minimum.error.sd = 0, correlation.different.locations = 0, correlation.different.years = 0.5, correlation.different.strata = 0.1, correlation.different.sources = 0.3, correlation.same.source.different.details = 0.3, obs.n.correlation.different.years = within.location.n.error.correlation, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], n.multiplier.cv = 0.1, p.error.variance.term = NULL, p.error.variance.type = NULL, n.error.variance.term = 0.05, n.error.variance.type = "cv", n.error.variance.term.if.estimated = 0.8, n.error.variance.type.if.estimated = "exp.of.variance", weights = list(), equalize.weight.by.year = T, partitioning.function, name = outcome.for.sim )create.nested.proportion.likelihood.instructions.with.included.multiplier( outcome.for.data, denominator.outcome.for.data, outcome.for.sim, outcome.for.n.multipliers = denominator.outcome.for.data, location.types, minimum.geographic.resolution.type, maximum.locations.per.type = 3, dimensions = NULL, levels.of.stratification = 0:length(dimensions), from.year = -Inf, to.year = Inf, omit.years = NULL, sources.to.use = NULL, exclude.denominator.ontology.names = NULL, location.overall.keep.threshold = 5, location.stratum.keep.threshold = 1, included.multiplier, included.multiplier.sd, included.multiplier.correlation = NULL, included.multiplier.correlation.structure = c("compound.symmetry", "autoregressive.1")[1], p.bias.inside.location, p.bias.outside.location, p.bias.sd.inside.location, p.bias.sd.outside.location, within.location.p.error.correlation = 0.5, within.location.n.error.correlation = 0.5, minimum.error.sd = 0, correlation.different.locations = 0, correlation.different.years = 0.5, correlation.different.strata = 0.1, correlation.different.sources = 0.3, correlation.same.source.different.details = 0.3, obs.n.correlation.different.years = within.location.n.error.correlation, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], n.multiplier.cv = 0.1, p.error.variance.term = NULL, p.error.variance.type = NULL, n.error.variance.term = 0.05, n.error.variance.type = "cv", n.error.variance.term.if.estimated = 0.8, n.error.variance.type.if.estimated = "exp.of.variance", weights = list(), equalize.weight.by.year = T, partitioning.function, name = outcome.for.sim )
outcome.for.data |
A single character vector specifying the outcome that data managers will use to find data. |
outcome.for.sim |
A single character vector specifying the simulation outcome to use. |
location.types |
The types of the locations that contain or are contained by the model location. These should be in order of decreasing preference since in the case that two locations have the same contained 'minimum.geographic.resolution.type', such as county "11001" and state "DC", only the higher priority type location will be used. |
minimum.geographic.resolution.type |
The type of location used to partition locations. The type of the model location AND 'location.types' types must all completely enclose regions of this type |
dimensions |
A character vector of dimensions, excluding year, from which stratifications will be generated. |
levels.of.stratification |
An integer vector specifying how the dimensions should be combined to form strata. '0' indicates totals (not stratified) while '1' indicates strata that are each stratified by one dimension at a time, '2' indicates strat that are each stratified by a combination of two dimensions at a time, etc. May not exceed the number of dimensions. Defaults to NULL, which is equivalent to '0'. |
from.year |
-Inf or a single integer value specifying the earliest year for which data should be pulled. |
to.year |
Inf or a single integer value specifying the latest year for which data should be pulled. |
omit.years |
(Optional) An integer vector of years to ignore. |
sources.to.use |
A character vector of sources from which to pull data. |
location.overall.keep.threshold, location.stratum.keep.threshold
|
How many data points a location must offer beyond what is found for the main location to justify being retained. Either overall (across ALL strata in total) or on a stratum-by-stratum basis. If a location doesn't meet the overall threshold, it will be ignored entirely. If it does, but fails to meet the stratum threshold for a certain stratum, it will be ignored only in that stratum. |
included.multiplier |
The value of the multiplier that has already been used in calculating the simulation value of the outcome (represents the mean of the distribution around the multiplier). |
included.multiplier.sd |
The standard deviation of the uncertainty around the included multiplier. |
included.multiplier.correlation |
The correlation between values of the multiplier across different strata and years. |
included.multiplier.correlation.structure |
Which correlation form to use for values of the multiplier across various strata and years. |
p.bias.inside.location, p.bias.outside.location, p.bias.sd.inside.location, p.bias.sd.outside.location
|
A single numeric value specifying the bias in the outcome proportion between locations inside (or outside) the model location and the model location itself, and their associated standard deviations. Each of these may alternatively be a function that takes only arguments 'version' and 'location' and returns an acceptable numeric value. For the estimates, values should be between -1 and 1, inclusive. For sd, should be non-negative and non-infinite. The bias should = outside/inside location MINUS main location (eg, state - MSA or county - MSA) |
within.location.p.error.correlation, within.location.n.error.correlation
|
Single numeric values specifying the correlation between p or n values from the same location and stratum |
minimum.error.sd |
A single, positive numeric value. If any standard deviations are calculated to a value below this, they will be replaced with this value. This can help keep the likelihood from computing to negative infinity. |
correlation.different.locations |
A single numeric value specifying the correlation between observations of different locations. |
correlation.different.years |
A single numeric value specifying the correlation between observations of different years. |
correlation.different.strata |
A single numeric value specifying the correlation between observations from different strata. |
correlation.different.sources |
A single numeric value specifying the correlation between observations from different sources. |
correlation.same.source.different.details |
A single numeric value specifying the correlation between observations of the same source but which have different 'details'. |
obs.n.correlation.different.years |
Single numeric value specifying the correlation between different calculated obs n values |
observation.correlation.form |
Which correlation form to use in building the measurement error covariance matrix. May be 'compound.symmetry' or 'autoregressive.1'. |
n.multiplier.cv |
A single numeric value specifying the covariance term used to find the n.multipliers. |
p.error.variance.type, p.error.variance.term
|
The type of error variance(s) to be used for the outcome proportion and the corresponding value or function required for each. See details for the allowable values. For more than one type, supply them in a vector. If you therefore need more than one term, supply these in a list. |
n.error.variance.type |
The 'p.error.variance.type/term' analog for the denominator outcome. Has fewer options of type. See details for more information. |
weights |
A list containing only numeric vectors and objects of class 'jheem.likelihood.weights', which are generated by |
equalize.weight.by.year |
A Boolean indicating whether every year should be weighted equally before the weights from 'weights' are applied. |
partitioning.function |
A function that partitions values in the data ontology into values in the model ontology. Must have two arguments, "arr" and "version" and return an array with the same dimnames as the input array. |
P error variance may be specified in a variety of ways, and more than one can be used in the same likelihood. 'error.variance.type' is a vector containing single character values describing the type(s) of variance to use, and there is one 'error.variance.term' corresponding to each. The types "sd" (standard deviation), "variance", "cv" (covariance), and "exp.of.variance" (exponent of variance) require a single numeric value as their term. The types "data.sd", "data.variance", and "data.cv" indicate that error data will be pulled from the data manager and matched directly to data points, and they require NULL as their term. Finally, the type "function.sd" requires as its term a function that takes only arguments "data", "details", "version", and "location" and returns a numeric array of the same dimensions as "data". Supplying multiple types (and therefore terms) results in the variances created by each being summed prior to use in the measurement error covariance matrix.
As an example, one type could be specified with a 'p.error.variance.type' of "cv" and a 'p.error.variance.term' of 0.13 (or list(0.13)). Two or more types might look like a 'p.error.variance.type' of 'c("data.sd", "function.sd") and a 'p.error.variance.term' of list(NULL, my_sd_function). It is possible to use the same type multiple times, although this is not recommended.
N error variance works the same way but only one type is currently supported: "cv" (covariance).
Other Nested Proportion Likelihoods:
create.nested.proportion.likelihood.instructions(),
create.time.lagged.comparison.nested.proportion.likelihood.instructions(),
get.p.bias.estimates()
Create a mapping that allows transformations of arrays
create.ontology.mapping( mappings, from.dimensions, to.dimensions = from.dimensions, name = NULL, error.prefix = "Error creating ontology mapping: " )create.ontology.mapping( mappings, from.dimensions, to.dimensions = from.dimensions, name = NULL, error.prefix = "Error creating ontology mapping: " )
mappings |
A character matrix, with a number of columns == length(from.dimensions) + length(to.dimensions). The first length(from.dimensions) columns represent values for the from.dimensions (in the same order as from.dimensions), and the last length(to.dimensions) colums represent values for to.dimensions (in the order of to.dimensions). Each row represents a mapping from a set of values for from.dimension to a set of values for to.dimensions. NB: any dimnames on mappings will be ignored |
from.dimensions |
A character vector of names of the dimensions we are mapping from |
to.dimensions |
A character vector of names of the dimensions we are mapping to |
error.prefix |
A text string to prepend to any error messages generated in executing the function |
Create an ontology mapping that lumps otherwise unspecified categories into an "other" category
create.other.catchall.ontology.mapping( dimension, from.values, to.values, other.category.value = "other" )create.other.catchall.ontology.mapping( dimension, from.values, to.values, other.category.value = "other" )
dimension |
A single character value indicating what dimension this mapping applies to |
from.values |
The possible values for the dimension in the ontology to map from |
to.values |
The possible values for the dimension in the ontology to map to |
other.category.value |
What the "other" category should be called in the to ontology |
Create Outcome Location Mapping
create.outcome.location.mapping( location.mappings, outcome.name, version = jheem.kernel$version, location = jheem.kernel$location, sub.version = NULL, jheem.kernel = NULL )create.outcome.location.mapping( location.mappings, outcome.name, version = jheem.kernel$version, location = jheem.kernel$location, sub.version = NULL, jheem.kernel = NULL )
location.mappings |
is a named list, where the names correspond to modeled locations, and the elements are vectors of observed locations |
create.outcome.metadata( display.name, description, scale, axis.name, units, singular.unit = units, display.as.percent = scale == "proportion" )create.outcome.metadata( display.name, description, scale, axis.name, units, singular.unit = units, display.as.percent = scale == "proportion" )
display.name |
The (nicely formatted) name of the quantity - to use in titling figures and other reporting. Should be capitalized |
description |
A phrase or single sentence describing the quantity. Should be captialized |
scale |
The scale of the quantity. Either "rate", "ratio", "proportion", "time", "number", "non.negative.number" |
axis.name |
A name to use in labeling axes on figures that display this quantity. Should be capitalized |
units |
The units the quantity takes (eg, "cases", " \itemsingular.unitThe unit to use if the value of the quantity is exactly == 1 \itemdisplay.as.percentA logical indicator for whether, when plotted or otherwise displayed, the quantity should be converted to a percent. Only valid if scale=='proportion' |
An object of class 'outcome.metadata' which can be passed to track.transition, track.quantity, track.dynamic.quantity
Create a metadata object for tracked quantities or tracked transitions
Create a Collection of JHEEM Simulation-Sets
create.simset.collection( version, calibration.code, locations, interventions, n.sim = NULL, sub.version = NULL, root.dir = get.jheem.root.directory("Cannot create simset collection: ") )create.simset.collection( version, calibration.code, locations, interventions, n.sim = NULL, sub.version = NULL, root.dir = get.jheem.root.directory("Cannot create simset collection: ") )
version, sub.version
|
The version and (optional) sub-version for the simsets |
locations |
A character vector of locations for which to collect simsets |
interventions |
The interventions for which to collect interventions. Can be either (a) a character vector of intervention codes or (b) a list of 'jheem.intervention' objects or single character intervention codes |
n.sim |
Optional - the number of simulations which collected simsets should contain. If NULL, the number will attempt to be figured out |
root.dir |
The root directory relative to which all simset files (and all JHEEM files) are saved |
An object of class 'jheem.simset.collection'
Create Solver Metadata
create.solver.metadata( method = "ode45", package = NULL, atol = 0.01, rtol = 0.001 )create.solver.metadata( method = "ode45", package = NULL, atol = 0.01, rtol = 0.001 )
Create an Static (Time-Invariant) Functional Form
create.static.functional.form( value, link = c("identity", "log", "logit")[1], min = NA, max = NA, value.name = "value", value.is.on.transformed.scale = F, overwrite.parameters.with.alphas = F, error.prefix = "Cannot create static functional.form: " )create.static.functional.form( value, link = c("identity", "log", "logit")[1], min = NA, max = NA, value.name = "value", value.is.on.transformed.scale = F, overwrite.parameters.with.alphas = F, error.prefix = "Cannot create static functional.form: " )
value |
array representing the value |
link |
The name of the transformation to the scale on which alphas are added to the value. One of "identity", "log", "logit" |
min, max
|
The minimum and maximum values this functional form can create. The default (NA) sets to the min/max for the link specified (eg, 0-Inf for a log link, 0-1 for a logistic link) |
value.is.on.transformed.scale |
Logical indicating whether the value is already on the transformed scale at which alphas apply |
overwrite.parameters.with.alphas |
Logical indicating whether, when alphas are applied, they OVERWRITE values. If F, alphas are added to the transformed value (on the transformed scale) |
error.prefix |
String to prepend to any error message in case of an error |
Create A Style Manager
create.style.manager( color.sim.by = "stratum", color.data.by = "stratum", shade.data.by = "location", linetype.sim.by = "simset", shape.data.by = "source", shape.sim.by = "simset", sim.palette = ggsci::pal_jama(), data.palette = ggsci::pal_jama(), linetypes = c("solid", "dashed", "dotted", "dotdash"), shapes = 21:25, shade.increment = -64, alpha.ribbon = 0.2, alpha.line = 1, linewidth.baseline = 1, linewidth.slope = 3 )create.style.manager( color.sim.by = "stratum", color.data.by = "stratum", shade.data.by = "location", linetype.sim.by = "simset", shape.data.by = "source", shape.sim.by = "simset", sim.palette = ggsci::pal_jama(), data.palette = ggsci::pal_jama(), linetypes = c("solid", "dashed", "dotted", "dotdash"), shapes = 21:25, shade.increment = -64, alpha.ribbon = 0.2, alpha.line = 1, linewidth.baseline = 1, linewidth.slope = 3 )
sim.palette, data.palette
|
Must be either a character vector of colors to choose from or a function that takes a number of colors needed and returns a character vector of colors. |
shapes |
A numeric vector indicating which of the 25 ggplot shapes to select from. Each value must be an integer between 1 and 25. |
shade.increment |
A single numeric value less than 0 indicating the extent of shading to apply (to alternate values of the 'shade.data.by'/'shade.sim.by' variables) |
alpha.line |
A single numeric value which determines the transparency of the simulation lines. If NULL, the width of the lines is used (see "linewidth.slope" argument for details). |
linewidth.baseline |
A single numeric value greater than zero which determines the simset linewidth in combination with the "linewidth.slope" argument. |
linewidth.slope |
A single numeric value specifying how simset linewidth will be determined for based on how many simulations it has (its "n.sim"). The formula used is linewidth = baseline/(slope * log10(n.sim) + 1), where "baseline" is the argument "linewidth.baseline". If this slope is the default of 3, and linewidth.baseline is the default of 1, this will result in simsets with 1000 simulations having a linewidth of 0.1 while simsets with only 1 simulation will have a linewidth of 1. If you would like all simsets to plot with the same thickness, use a slope of 0. |
Create a Target Population to Which Interventions May be Applied
create.target.population(..., name, invert = F)create.target.population(..., name, invert = F)
... |
Dimension values that denote the categories that comprise this target population. Each element must be namned with the name of the dimension, and can be either (1) character values, (2) integers, or (3) logical vectors |
name |
A short (<= 20 characters) descriptive name for the target population. Should be nicely formatted for public display |
invert |
A logical indicating whether the target population should be the INVERSE of the characteristics specified in ... (ie, everyone who does NOT fall into those categories) |
Other Functions to create Target Populations:
diff.target.populations(),
intersect.target.populations(),
union.target.populations()
Create JHEEM Basic Likelihood Instructions
create.time.lagged.comparison.likelihood.instructions( outcome.for.data, outcome.for.sim, dimensions = character(0), denominator.dimensions = dimensions, dimension.values = NULL, levels.of.stratification = NULL, from.year = -Inf, to.year = Inf, omit.years = NULL, sources.to.use = NULL, minimum.error.sd = 0, correlation.different.years = 0.5, correlation.different.strata = 0.1, correlation.different.sources = 0.3, correlation.same.source.different.details = 0.3, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], error.variance.term = NULL, error.variance.type = NULL, ratio.cv = NULL, ratio.correlation = NULL, weights = list(), equalize.weight.by.year = T, use.lognormal.approximation = T, name = outcome.for.sim, na.rm = NULL )create.time.lagged.comparison.likelihood.instructions( outcome.for.data, outcome.for.sim, dimensions = character(0), denominator.dimensions = dimensions, dimension.values = NULL, levels.of.stratification = NULL, from.year = -Inf, to.year = Inf, omit.years = NULL, sources.to.use = NULL, minimum.error.sd = 0, correlation.different.years = 0.5, correlation.different.strata = 0.1, correlation.different.sources = 0.3, correlation.same.source.different.details = 0.3, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], error.variance.term = NULL, error.variance.type = NULL, ratio.cv = NULL, ratio.correlation = NULL, weights = list(), equalize.weight.by.year = T, use.lognormal.approximation = T, name = outcome.for.sim, na.rm = NULL )
outcome.for.data |
A single character vector specifying the outcome that data managers will use to find data. |
outcome.for.sim |
A single character vector specifying the simulation outcome to use. |
dimensions |
A character vector of dimensions, excluding year, from which stratifications will be generated. |
denominator.dimensions |
(Optional) Analogous to 'dimensions' but for the simulation denominator outcome when applicable. Must be a subset of 'dimensions'. |
levels.of.stratification |
An integer vector specifying how the dimensions should be combined to form strata. '0' indicates totals (not stratified) while '1' indicates strata that are each stratified by one dimension at a time, '2' indicates strat that are each stratified by a combination of two dimensions at a time, etc. May not exceed the number of dimensions. Defaults to NULL, which is equivalent to '0'. |
from.year |
-Inf or a single integer value specifying the earliest year for which data should be pulled. |
to.year |
Inf or a single integer value specifying the latest year for which data should be pulled. |
omit.years |
(Optional) An integer vector of years to ignore. |
sources.to.use |
A character vector of sources from which to pull data. |
minimum.error.sd |
A single, positive numeric value. If any standard deviations are calculated to a value below this, they will be replaced with this value. This can help keep the likelihood from computing to negative infinity. |
correlation.different.years |
A single numeric value specifying the correlation between observations of different years. |
correlation.different.strata |
A single numeric value specifying the correlation between observations from different strata. |
correlation.different.sources |
A single numeric value specifying the correlation between observations from different sources. |
correlation.same.source.different.details |
A single numeric value specifying the correlation between observations of the same source but which have different 'details'. |
observation.correlation.form |
Which correlation form to use in building the measurement error covariance matrix. May be 'compound.symmetry' or 'autoregressive.1'. |
error.variance.type, error.variance.term
|
The type of error variance(s) to be used and the corresponding value or function required for each. See details for the allowable values. For more than one type, supply them in a vector. If you therefore need more than one term, supply these in a list. |
weights |
A list containing only numeric vectors and objects of class 'jheem.likelihood.weights', which are generated by |
equalize.weight.by.year |
A Boolean indicating whether every year should be weighted equally before the weights from 'weights' are applied. |
use.lognormal.approximation |
A single logical value. |
na.rm |
Setting this TRUE will pass 'na.rm=T' along to the pull function. If set to NULL, 'na.rm=T' will be used for outcomes with scale 'proportion', 'rate', or 'ratio'. |
Error variance may be specified in a variety of ways, and more than one can be used in the same likelihood. 'error.variance.type' is a vector containing single character values describing the type(s) of variance to use, and there is one 'error.variance.term' corresponding to each. The types "sd" (standard deviation), "variance", "cv" (covariance), and "exp.of.variance" (exponent of variance) require a single numeric value as their term. The types "data.sd", "data.variance", and "data.cv" indicate that error data will be pulled from the data manager and matched directly to data points, and they require NULL as their term. Finally, the type "function.sd" requires as its term a function that takes only arguments "data", "details", "version", and "location" and returns a numeric array of the same dimensions as "data". Supplying multiple types (and therefore terms) results in the variances created by each being summed prior to use in the measurement error covariance matrix.
As an example, one type could be specified with an 'error.variance.type' of "cv" and an 'error.variance.term' of 0.13 (or list(0.13)). Two or more types might look like an 'error.variance.type' of 'c("data.sd", "function.sd") and an 'error.variance.term' of list(NULL, my_sd_function). It is possible to use the same type multiple times, although this is not recommended.
Other Basic Likelihoods:
create.basic.likelihood.instructions(),
create.basic.likelihood.instructions.with.included.multiplier(),
create.basic.likelihood.instructions.with.specified.outcome(),
create.time.lagged.comparison.likelihood.instructions.with.included.multiplier()
Create JHEEM Basic Likelihood Instructions
create.time.lagged.comparison.likelihood.instructions.with.included.multiplier( outcome.for.data, outcome.for.sim, dimensions = character(0), denominator.dimensions = dimensions, dimension.values = NULL, levels.of.stratification = NULL, from.year = -Inf, to.year = Inf, omit.years = NULL, sources.to.use = NULL, minimum.error.sd = 0, included.multiplier, included.multiplier.sd, included.multiplier.correlation = NULL, included.multiplier.correlation.structure = c("compound.symmetry", "autoregressive.1")[1], correlation.different.years = 0.5, correlation.different.strata = 0.1, correlation.different.sources = 0.3, correlation.same.source.different.details = 0.3, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], error.variance.term = NULL, error.variance.type = NULL, weights = list(), equalize.weight.by.year = T, use.lognormal.approximation = T, name = outcome.for.sim, na.rm = NULL )create.time.lagged.comparison.likelihood.instructions.with.included.multiplier( outcome.for.data, outcome.for.sim, dimensions = character(0), denominator.dimensions = dimensions, dimension.values = NULL, levels.of.stratification = NULL, from.year = -Inf, to.year = Inf, omit.years = NULL, sources.to.use = NULL, minimum.error.sd = 0, included.multiplier, included.multiplier.sd, included.multiplier.correlation = NULL, included.multiplier.correlation.structure = c("compound.symmetry", "autoregressive.1")[1], correlation.different.years = 0.5, correlation.different.strata = 0.1, correlation.different.sources = 0.3, correlation.same.source.different.details = 0.3, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], error.variance.term = NULL, error.variance.type = NULL, weights = list(), equalize.weight.by.year = T, use.lognormal.approximation = T, name = outcome.for.sim, na.rm = NULL )
outcome.for.data |
A single character vector specifying the outcome that data managers will use to find data. |
outcome.for.sim |
A single character vector specifying the simulation outcome to use. |
dimensions |
A character vector of dimensions, excluding year, from which stratifications will be generated. |
denominator.dimensions |
(Optional) Analogous to 'dimensions' but for the simulation denominator outcome when applicable. Must be a subset of 'dimensions'. |
levels.of.stratification |
An integer vector specifying how the dimensions should be combined to form strata. '0' indicates totals (not stratified) while '1' indicates strata that are each stratified by one dimension at a time, '2' indicates strat that are each stratified by a combination of two dimensions at a time, etc. May not exceed the number of dimensions. Defaults to NULL, which is equivalent to '0'. |
from.year |
-Inf or a single integer value specifying the earliest year for which data should be pulled. |
to.year |
Inf or a single integer value specifying the latest year for which data should be pulled. |
omit.years |
(Optional) An integer vector of years to ignore. |
sources.to.use |
A character vector of sources from which to pull data. |
minimum.error.sd |
A single, positive numeric value. If any standard deviations are calculated to a value below this, they will be replaced with this value. This can help keep the likelihood from computing to negative infinity. |
included.multiplier |
The value of the multiplier that has already been used in calculating the simulation value of the outcome (represents the mean of the distribution around the multiplier). |
included.multiplier.sd |
The standard deviation of the uncertainty around the included multiplier. |
included.multiplier.correlation |
The correlation between values of the multiplier across different strata and years. |
included.multiplier.correlation.structure |
Which correlation form to use for values of the multiplier across various strata and years. |
correlation.different.years |
A single numeric value specifying the correlation between observations of different years. |
correlation.different.strata |
A single numeric value specifying the correlation between observations from different strata. |
correlation.different.sources |
A single numeric value specifying the correlation between observations from different sources. |
correlation.same.source.different.details |
A single numeric value specifying the correlation between observations of the same source but which have different 'details'. |
observation.correlation.form |
Which correlation form to use in building the measurement error covariance matrix. May be 'compound.symmetry' or 'autoregressive.1'. |
error.variance.type, error.variance.term
|
The type of error variance(s) to be used and the corresponding value or function required for each. See details for the allowable values. For more than one type, supply them in a vector. If you therefore need more than one term, supply these in a list. |
weights |
A list containing only numeric vectors and objects of class 'jheem.likelihood.weights', which are generated by |
equalize.weight.by.year |
A Boolean indicating whether every year should be weighted equally before the weights from 'weights' are applied. |
use.lognormal.approximation |
A single logical value. |
na.rm |
Setting this TRUE will pass 'na.rm=T' along to the pull function. If set to NULL, 'na.rm=T' will be used for outcomes with scale 'proportion', 'rate', or 'ratio'. |
Error variance may be specified in a variety of ways, and more than one can be used in the same likelihood. 'error.variance.type' is a vector containing single character values describing the type(s) of variance to use, and there is one 'error.variance.term' corresponding to each. The types "sd" (standard deviation), "variance", "cv" (covariance), and "exp.of.variance" (exponent of variance) require a single numeric value as their term. The types "data.sd", "data.variance", and "data.cv" indicate that error data will be pulled from the data manager and matched directly to data points, and they require NULL as their term. Finally, the type "function.sd" requires as its term a function that takes only arguments "data", "details", "version", and "location" and returns a numeric array of the same dimensions as "data". Supplying multiple types (and therefore terms) results in the variances created by each being summed prior to use in the measurement error covariance matrix.
As an example, one type could be specified with an 'error.variance.type' of "cv" and an 'error.variance.term' of 0.13 (or list(0.13)). Two or more types might look like an 'error.variance.type' of 'c("data.sd", "function.sd") and an 'error.variance.term' of list(NULL, my_sd_function). It is possible to use the same type multiple times, although this is not recommended.
Other Basic Likelihoods:
create.basic.likelihood.instructions(),
create.basic.likelihood.instructions.with.included.multiplier(),
create.basic.likelihood.instructions.with.specified.outcome(),
create.time.lagged.comparison.likelihood.instructions()
Create Time Lagged Comparison Nested Proportion Likelihood Instructions
create.time.lagged.comparison.nested.proportion.likelihood.instructions( outcome.for.data, denominator.outcome.for.data, outcome.for.sim, outcome.for.n.multipliers = denominator.outcome.for.data, location.types, minimum.geographic.resolution.type, maximum.locations.per.type = 3, dimensions = NULL, levels.of.stratification = 0:length(dimensions), from.year = -Inf, to.year = Inf, omit.years = NULL, sources.to.use = NULL, exclude.denominator.ontology.names = NULL, location.overall.keep.threshold = 5, location.stratum.keep.threshold = 1, p.bias.inside.location, p.bias.outside.location, p.bias.sd.inside.location, p.bias.sd.outside.location, within.location.p.error.correlation = 0.5, within.location.n.error.correlation = 0.5, minimum.error.sd = 0, correlation.different.locations = 0, correlation.different.years = 0.5, correlation.different.strata = 0.1, correlation.different.sources = 0.3, correlation.same.source.different.details = 0.3, obs.n.correlation.different.years = within.location.n.error.correlation, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], n.multiplier.cv = 0.1, p.error.variance.term = NULL, p.error.variance.type = NULL, n.error.variance.term = 0.05, n.error.variance.type = "cv", n.error.variance.term.if.estimated = 0.8, n.error.variance.type.if.estimated = "exp.of.variance", ratio.cv = NULL, ratio.correlation = NULL, weights = list(), equalize.weight.by.year = T, partitioning.function, use.lognormal.approximation = T, name = outcome.for.sim )create.time.lagged.comparison.nested.proportion.likelihood.instructions( outcome.for.data, denominator.outcome.for.data, outcome.for.sim, outcome.for.n.multipliers = denominator.outcome.for.data, location.types, minimum.geographic.resolution.type, maximum.locations.per.type = 3, dimensions = NULL, levels.of.stratification = 0:length(dimensions), from.year = -Inf, to.year = Inf, omit.years = NULL, sources.to.use = NULL, exclude.denominator.ontology.names = NULL, location.overall.keep.threshold = 5, location.stratum.keep.threshold = 1, p.bias.inside.location, p.bias.outside.location, p.bias.sd.inside.location, p.bias.sd.outside.location, within.location.p.error.correlation = 0.5, within.location.n.error.correlation = 0.5, minimum.error.sd = 0, correlation.different.locations = 0, correlation.different.years = 0.5, correlation.different.strata = 0.1, correlation.different.sources = 0.3, correlation.same.source.different.details = 0.3, obs.n.correlation.different.years = within.location.n.error.correlation, observation.correlation.form = c("compound.symmetry", "autoregressive.1")[1], n.multiplier.cv = 0.1, p.error.variance.term = NULL, p.error.variance.type = NULL, n.error.variance.term = 0.05, n.error.variance.type = "cv", n.error.variance.term.if.estimated = 0.8, n.error.variance.type.if.estimated = "exp.of.variance", ratio.cv = NULL, ratio.correlation = NULL, weights = list(), equalize.weight.by.year = T, partitioning.function, use.lognormal.approximation = T, name = outcome.for.sim )
outcome.for.data |
A single character vector specifying the outcome that data managers will use to find data. |
outcome.for.sim |
A single character vector specifying the simulation outcome to use. |
location.types |
The types of the locations that contain or are contained by the model location. These should be in order of decreasing preference since in the case that two locations have the same contained 'minimum.geographic.resolution.type', such as county "11001" and state "DC", only the higher priority type location will be used. |
minimum.geographic.resolution.type |
The type of location used to partition locations. The type of the model location AND 'location.types' types must all completely enclose regions of this type |
dimensions |
A character vector of dimensions, excluding year, from which stratifications will be generated. |
levels.of.stratification |
An integer vector specifying how the dimensions should be combined to form strata. '0' indicates totals (not stratified) while '1' indicates strata that are each stratified by one dimension at a time, '2' indicates strat that are each stratified by a combination of two dimensions at a time, etc. May not exceed the number of dimensions. Defaults to NULL, which is equivalent to '0'. |
from.year |
-Inf or a single integer value specifying the earliest year for which data should be pulled. |
to.year |
Inf or a single integer value specifying the latest year for which data should be pulled. |
omit.years |
(Optional) An integer vector of years to ignore. |
sources.to.use |
A character vector of sources from which to pull data. |
location.overall.keep.threshold, location.stratum.keep.threshold
|
How many data points a location must offer beyond what is found for the main location to justify being retained. Either overall (across ALL strata in total) or on a stratum-by-stratum basis. If a location doesn't meet the overall threshold, it will be ignored entirely. If it does, but fails to meet the stratum threshold for a certain stratum, it will be ignored only in that stratum. |
p.bias.inside.location, p.bias.outside.location, p.bias.sd.inside.location, p.bias.sd.outside.location
|
A single numeric value specifying the bias in the outcome proportion between locations inside (or outside) the model location and the model location itself, and their associated standard deviations. Each of these may alternatively be a function that takes only arguments 'version' and 'location' and returns an acceptable numeric value. For the estimates, values should be between -1 and 1, inclusive. For sd, should be non-negative and non-infinite. The bias should = outside/inside location MINUS main location (eg, state - MSA or county - MSA) |
within.location.p.error.correlation, within.location.n.error.correlation
|
Single numeric values specifying the correlation between p or n values from the same location and stratum |
minimum.error.sd |
A single, positive numeric value. If any standard deviations are calculated to a value below this, they will be replaced with this value. This can help keep the likelihood from computing to negative infinity. |
correlation.different.locations |
A single numeric value specifying the correlation between observations of different locations. |
correlation.different.years |
A single numeric value specifying the correlation between observations of different years. |
correlation.different.strata |
A single numeric value specifying the correlation between observations from different strata. |
correlation.different.sources |
A single numeric value specifying the correlation between observations from different sources. |
correlation.same.source.different.details |
A single numeric value specifying the correlation between observations of the same source but which have different 'details'. |
obs.n.correlation.different.years |
Single numeric value specifying the correlation between different calculated obs n values |
observation.correlation.form |
Which correlation form to use in building the measurement error covariance matrix. May be 'compound.symmetry' or 'autoregressive.1'. |
n.multiplier.cv |
A single numeric value specifying the covariance term used to find the n.multipliers. |
p.error.variance.type, p.error.variance.term
|
The type of error variance(s) to be used for the outcome proportion and the corresponding value or function required for each. See details for the allowable values. For more than one type, supply them in a vector. If you therefore need more than one term, supply these in a list. |
n.error.variance.type |
The 'p.error.variance.type/term' analog for the denominator outcome. Has fewer options of type. See details for more information. |
weights |
A list containing only numeric vectors and objects of class 'jheem.likelihood.weights', which are generated by |
equalize.weight.by.year |
A Boolean indicating whether every year should be weighted equally before the weights from 'weights' are applied. |
partitioning.function |
A function that partitions values in the data ontology into values in the model ontology. Must have two arguments, "arr" and "version" and return an array with the same dimnames as the input array. |
use.lognormal.approximation |
A single logical value. |
P error variance may be specified in a variety of ways, and more than one can be used in the same likelihood. 'error.variance.type' is a vector containing single character values describing the type(s) of variance to use, and there is one 'error.variance.term' corresponding to each. The types "sd" (standard deviation), "variance", "cv" (covariance), and "exp.of.variance" (exponent of variance) require a single numeric value as their term. The types "data.sd", "data.variance", and "data.cv" indicate that error data will be pulled from the data manager and matched directly to data points, and they require NULL as their term. Finally, the type "function.sd" requires as its term a function that takes only arguments "data", "details", "version", and "location" and returns a numeric array of the same dimensions as "data". Supplying multiple types (and therefore terms) results in the variances created by each being summed prior to use in the measurement error covariance matrix.
As an example, one type could be specified with a 'p.error.variance.type' of "cv" and a 'p.error.variance.term' of 0.13 (or list(0.13)). Two or more types might look like a 'p.error.variance.type' of 'c("data.sd", "function.sd") and a 'p.error.variance.term' of list(NULL, my_sd_function). It is possible to use the same type multiple times, although this is not recommended.
N error variance works the same way but only one type is currently supported: "cv" (covariance).
Other Nested Proportion Likelihoods:
create.nested.proportion.likelihood.instructions(),
create.nested.proportion.likelihood.instructions.with.included.multiplier(),
get.p.bias.estimates()
While a kernel for this specification's version is built under a binding, the binding must contain every declared name, and resolving any other name is an error. With no binding active, the declaration is not checked.
declare.data.managers(specification, names)declare.data.managers(specification, names)
specification |
A jheem.specification object |
names |
The names of the data managers its functions use, for example c('census', 'syphilis') |
NULL, invisibly
Create a Target Population that is the DIFFERENCE between two other Target Populations
## S3 method for class 'target.populations' diff(pop1, pop2, name = NULL)## S3 method for class 'target.populations' diff(pop1, pop2, name = NULL)
pop1, pop2
|
Target Population Objects |
The resulting target population contains everyone who IS in pop1 but NOT in pop2
Other Functions to create Target Populations:
create.target.population(),
intersect.target.populations(),
union.target.populations()
Disable JHEEM Solver Tracking
disable.jheem.solver.tracking()disable.jheem.solver.tracking()
This function redistributes certain values in a dimension across the remaining values in that dimension. This is useful to remove problematic dimension values – like race = 'unknown' – while keeping the marginal sums and the relevant ratios between the remaining dimension values the same as they were before.
distribute.dimension.values( arr, dimension.values.to.distribute, round.distributed.dimension.values )distribute.dimension.values( arr, dimension.values.to.distribute, round.distributed.dimension.values )
arr |
An array – no validation is performed |
dimension.values.to.distribute |
A named list of the dimensions and their values which should be redistributed |
round.distributed.dimension.values |
Should distributed quantities be rounded? |
If multiple dimensions should be redistributed, they will be redistributed in the order that they exist in 'dimension.values.to.distribute'. This can result in different outputs for different orders.
An array with the same number of dimensions as 'arr', but without the dimension values specified in 'dimension.values.to.distribute'.
Enable JHEEM Solver Tracking
enable.jheem.solver.tracking()enable.jheem.solver.tracking()
For use in figuring out why a call to get.mappings.to.align.ontologies did not work
If no mappings can be found, prints detailed information on why we were unable to find mappings
examine.get.mappings.to.align.ontologies( ontology.1, ontology.2, align.on.dimensions = intersect(names(ontology.1), names(ontology.2)), allow.non.overlapping.incomplete.dimensions = F, include.dim.names = NULL, print.ontologies = T )examine.get.mappings.to.align.ontologies( ontology.1, ontology.2, align.on.dimensions = intersect(names(ontology.1), names(ontology.2)), allow.non.overlapping.incomplete.dimensions = F, include.dim.names = NULL, print.ontologies = T )
ontology.1, ontology.2
|
The ontologies of two data elements to be transformed |
align.on.dimensions |
The dimensions which should match in the transformed data |
allow.non.overlapping.incomplete.dimensions |
Logical indicating whether, when we map to an incomplete dimension, there can be no overlap in the from and to values for that dimension |
include.dim.names |
Optional argument, specifying specific dimension values that must be present in the transformed data |
print.ontologies |
Whether to print the full ontologies in the details |
For use in figuring out why a call to get.ontology.mapping did not work
If no mapping can be found, prints detailed information on why we were unable to find a mapping
examine.get.ontology.mapping( from.ontology, to.ontology, allow.non.overlapping.incomplete.dimensions = F, print.ontologies = T )examine.get.ontology.mapping( from.ontology, to.ontology, allow.non.overlapping.incomplete.dimensions = F, print.ontologies = T )
from.ontology |
The ontology to which the data to be transformed conform. Must be an 'ontology' object as created by |
to.ontology |
The ontology to which the transformed data should conform. Must be an 'ontology' object as created by |
allow.non.overlapping.incomplete.dimensions |
Logical indicating whether, when we map to an incomplete dimension, there can be no overlap in the from and to values for that dimension |
print.ontologies |
Whether to print the full ontologies in the details |
Prints detailed information on why we were unable to find a mapping
examine.recent.failed.ontology.mapping(which = 1, print.ontologies = T)examine.recent.failed.ontology.mapping(which = 1, print.ontologies = T)
which |
The index of the recent failure. 1 denotes the most recent failed attempt, 2 the second most recent, and so on |
print.ontologies |
Whether to print the full ontologies in the details |
Execute Plotly Plot A utility that performs the plot-rendering half of the plot simulations in plotly operation for applications like webtools that need the step to be separate.
execute.plotly.plot( prepared.plot.data, outcomes = NULL, split.by = NULL, facet.by = NULL, plot.which = "sim.and.data", summary.type = c("individual.simulation", "mean.and.interval", "median.and.interval")[1], plot.year.lag.ratio = F, n.facet.rows = NULL, style.manager = get.default.style.manager(), debug = F, hide.legend = FALSE )execute.plotly.plot( prepared.plot.data, outcomes = NULL, split.by = NULL, facet.by = NULL, plot.which = "sim.and.data", summary.type = c("individual.simulation", "mean.and.interval", "median.and.interval")[1], plot.year.lag.ratio = F, n.facet.rows = NULL, style.manager = get.default.style.manager(), debug = F, hide.legend = FALSE )
Execute Simplot A utility that performs the plot-rendering half of the simplot operation for applications like webtools that need the step to be separate.
execute.simplot( prepared.plot.data, outcomes = NULL, split.by = NULL, facet.by = NULL, plot.which = c("sim.and.data", "sim.only", "data.only")[1], summary.type = c("individual.simulation", "mean.and.interval", "median.and.interval")[1], plot.year.lag.ratio = F, n.facet.rows = NULL, style.manager = get.default.style.manager(), debug = F )execute.simplot( prepared.plot.data, outcomes = NULL, split.by = NULL, facet.by = NULL, plot.which = c("sim.and.data", "sim.only", "data.only")[1], summary.type = c("individual.simulation", "mean.and.interval", "median.and.interval")[1], plot.year.lag.ratio = F, n.facet.rows = NULL, style.manager = get.default.style.manager(), debug = F )
prepared.plot.data |
The named list output by "prepare.plot" |
outcomes |
A character vector of which simulation outcomes to plot |
split.by |
At most one dimension |
facet.by |
Any number of dimensions but cannot include the split.by dimension |
plot.which |
Should simulation data and calibration data be plotted ('sim.and.data'), or only simulation data ('sim.only') |
n.facet.rows |
An optional argument to specify how many rows the figure should facet plots into |
style.manager |
We are going to have to define this down the road. It's going to govern how we do lines and sizes and colors. For now, just hard code those in, and we'll circle back to it |
Expand an Array to Greater Dimensions
expand.array(to.expand, target.dim.names)expand.array(to.expand, target.dim.names)
to.expand |
The value to be expanded. Can be either (1) an array or matrix with named dimensions and dimnames set, (2) a scalar value, or (3) a named vector whose names are a superset of one of the elements of target.dim.names |
target.dim.names |
A named list containing the values of dimensions to subset for. The names of dimension.values should correspond to the names of dimnames. The elements of dimension.values should be character, integer, or logical vectors |
Extract the Last Simulation From A Calibration
extract.last.simulation.from.calibration( version, location, calibration.code, root.dir = get.jheem.root.directory("Cannot set up calibration: "), allow.incomplete = T, include.first.sim = F, chains = NULL )extract.last.simulation.from.calibration( version, location, calibration.code, root.dir = get.jheem.root.directory("Cannot set up calibration: "), allow.incomplete = T, include.first.sim = F, chains = NULL )
version |
The version of the model specification (must have been previously registered) |
location |
A single character value representing the location for the calibration |
include.first.sim |
Whether to also pull the first simulation from the calibration (will then return a 2-simulation simset) |
chains |
Find Ontology Mapping
find.ontology.mapping( from.ontology, to.ontology, required.dimensions, required.dim.names, get.two.way.alignment, allow.non.overlapping.incomplete.dimensions, from.ontology.name = ifelse(get.two.way.alignment, "ontology.1", "the from.ontology"), to.ontology.name = ifelse(get.two.way.alignment, "ontology.2", "the to.ontology"), get.details = F )find.ontology.mapping( from.ontology, to.ontology, required.dimensions, required.dim.names, get.two.way.alignment, allow.non.overlapping.incomplete.dimensions, from.ontology.name = ifelse(get.two.way.alignment, "ontology.1", "the from.ontology"), to.ontology.name = ifelse(get.two.way.alignment, "ontology.2", "the to.ontology"), get.details = F )
from.ontology, to.ontology
|
The ontologies of the from and to arrays |
required.dimensions |
The dimensions that should be present in the aligned product |
required.dim.names |
Any specific dimension values that should be present in the aligned product |
get.two.way.alignment |
Logical indicating whether we need one mapping, that maps from.dim.names such that |
allow.non.overlapping.incomplete.dimensions |
Logical indicating whether, when we map to an incomplete dimension, there can be no overlap in the from and to values for that dimension |
If get.two.way.alignment is false, returns a list of one or more ontology.mapping objects, such that applying these mappings to an array with from.dim.names ('from.arr') would yield an array with dimnames ('to.dim.names')
If get.two.way.alignment is true, returns a list with two elements, each of which is itself a list of one or more ontology.mapping objects, such that applying the first set of mappings to an array with from.dimnames and applying the second set of mappings to an array with to.dimnames would both yield arrays with dimensions 'align.on.dimensions', both with the same dimnames
Summarize the progress of a calibration task
get.calibration.progress( version, locations, calibration.code, root.dir = get.jheem.root.directory(), round.to.digits = ifelse(as.pct, 0, 2), as.pct = T )get.calibration.progress( version, locations, calibration.code, root.dir = get.jheem.root.directory(), round.to.digits = ifelse(as.pct, 0, 2), as.pct = T )
version, calibration.code, locations
|
The version, locations, and calibration code for which to gauge progress |
root.dir |
The root directory from which to search for calibrations |
round.to.digits |
How many digits to round progress to |
as.pct |
Whether the progress should be shown as a percentage instead of a fraction |
Get a Set of Indices to Collapse One Array into Another
get.collapse.array.indices(large.arr.dim.names, small.arr.dim.names)get.collapse.array.indices(large.arr.dim.names, small.arr.dim.names)
large.arr.dim.names |
The dimnames of the source array |
small.arr.dim.names |
the dimnames of the target array |
A list with four elements: $large.indices, $small.indices, $large.n, $small.n large.indices and small.indices are integer vectors of equal length, such that the value at large.indices[i] goes into the value at small.indices[i] if collapsing
Get a function that produces a cubic spline over the *cumulative* counts by age up to a given age
get.cumulative.age.counts.smoother( counts, given.age.brackets, smooth.infinite.age.to = Inf, allow.extrapolation = F, method = c("monoH.FC", "hyman")[1], error.prefix = "" )get.cumulative.age.counts.smoother( counts, given.age.brackets, smooth.infinite.age.to = Inf, allow.extrapolation = F, method = c("monoH.FC", "hyman")[1], error.prefix = "" )
allow.extrapolation |
Get the active data binding
get.data.binding()get.data.binding()
The binding made active most recently by using.data.binding or a jheem2
function building under it; otherwise the session binding if set.data.binding
was called; otherwise NULL
Get the identity of a data binding
get.data.binding.identity(binding)get.data.binding.identity(binding)
binding |
A 'jheem.data.binding' object |
A data frame with one row per name: name, data.manager.name, and the file, release,
repository, sha256, md5, and modified status of the data manager bound to it (NA where unknown;
see get.data.manager.provenance)
The data managers that were in use when a kernel, likelihood, simulation set,
or calibration was built: those registered by name, the default data manager, a manager
passed in explicitly, and every manager loaded with load.data.manager in the
session. The record can include managers the artifact did not use.
get.data.inputs(x)get.data.inputs(x)
x |
A jheem.kernel, jheem.likelihood, or jheem.simulation.set, or the path of a calibration directory or of the data_inputs.dcf file in one. If missing, the record an artifact built now would get (under a data binding, with no names used yet). |
NULL if nothing was recorded (for example, for artifacts built by earlier versions of jheem2). Otherwise a list with
'declared' if any managers were registered by name, 'loaded', 'bound' if the artifact was built under a data binding, and 'unknown' if any listed manager has no identity (it was not loaded from a file)
When the record was made
The JHEEM_RUN_RECORD environment variable at that time, if it was set: a pointer to the run's own record, for example a container run's records directory
A data frame with one row per data manager: registered.as (the registered names, NA if none), default, passed, data.manager.name, file, release, repository, sha256, md5, modified (whether its contents had changed since loading; NA when not known) and loaded.at; and, for an artifact built under a data binding, bound.as (the names it was bound under, NA if none) and used (whether the build resolved any of those names; NA if not bound)
With a data binding active (see get.data.binding), the data manager
bound to the name, and the name is recorded as used by any model object being built.
Otherwise, the data manager registered under the name.
get.data.manager(name)get.data.manager(name)
name |
The name it was bound or registered under |
A jheem.data.manager
Where a data manager came from: the file it was loaded from, an MD5 digest of that file, the release it belongs to when the loader supplied it, when it was loaded, and whether its contents have changed since.
get.data.manager.provenance(data.manager)get.data.manager.provenance(data.manager)
data.manager |
A jheem.data.manager object |
A list with elements file, md5, sha256, release, repository, loaded.at and modified, or NULL for a data manager that was not loaded from a file (or was loaded by an earlier version of jheem2)
Get pretty names for outcomes
get.data.outcome.pretty.names( data.manager = get.default.data.manager(), outcomes ) get.data.outcome.labels(data.manager = get.default.data.manager(), outcomes) get.data.outcome.descriptions( data.manager = get.default.data.manager(), outcomes )get.data.outcome.pretty.names( data.manager = get.default.data.manager(), outcomes ) get.data.outcome.labels(data.manager = get.default.data.manager(), outcomes) get.data.outcome.descriptions( data.manager = get.default.data.manager(), outcomes )
data.manager |
A jheem.data.manager object |
outcomes |
A character vector with the names of outcomes previously registered to this data manager |
Gets the pretty.names, labels, or descriptions registered for the outcomes with the data manager
A character vector of pretty names, labels, or descriptions
get.data.outcome.labels(): Get the labels for outcomes
get.data.outcome.descriptions(): Get descriptions for outcomes
Get full names for data sources
get.data.source.full.names(data.manager = get.default.data.manager(), sources) get.data.source.short.names(data.manager = get.default.data.manager(), sources)get.data.source.full.names(data.manager = get.default.data.manager(), sources) get.data.source.short.names(data.manager = get.default.data.manager(), sources)
data.manager |
A jheem.data.manager object |
sources |
A character vector with the names of sources previously registered to this data manager |
Gets the full.names or short.names for the data sources in the data manager
A character vector of full names or short names
get.data.source.short.names(): Get short names for data sources
Get the default data manager
get.default.data.manager()get.default.data.manager()
Get the Default Style Manager
get.default.style.manager(type = c("ggplot", "plotly")[1])get.default.style.manager(type = c("ggplot", "plotly")[1])
Get the Array Indices Under Expanded Dim-names
get.expand.array.indices(to.expand.dim.names, target.dim.names, index.from = 1)get.expand.array.indices(to.expand.dim.names, target.dim.names, index.from = 1)
Get a Set of Indices to Collapse One Array into Another, expanding the first array if needed to add dimensions
get.expand.then.collapse.array.indices( large.arr.dim.names, small.arr.dim.names )get.expand.then.collapse.array.indices( large.arr.dim.names, small.arr.dim.names )
large.arr.dim.names |
The dimnames of the source array |
small.arr.dim.names |
the dimnames of the target array |
A list with four elements: $large.indices, $small.indices, $large.n, $small.n large.indices and small.indices are integer vectors of equal length, such that the value at large.indices[i] goes into the value at small.indices[i] if collapsing
Get an "Identity" Ontology Mapping (that does not change data structure when applied)
get.identity.ontology.mapping()get.identity.ontology.mapping()
An object of class "ontology.mapping"
Other Functions to identify why ontologies fail to map:
apply.ontology.mapping(),
map.value.ontology()
Get JHEEM Root Directory #' @description Gets the directory that calibration directories and files will be written into, if it has been set with "set.jheem.root.directory"
get.jheem.root.directory(error.prefix = "")get.jheem.root.directory(error.prefix = "")
Get JHEEM Solver Tracked Info
get.jheem.solver.tracked.info()get.jheem.solver.tracked.info()
Get locations with data for an outcome
get.locations.with.data( data.manager = get.default.data.manager(), outcome, metric = "estimate", years, exclude.ontology.names = NULL )get.locations.with.data( data.manager = get.default.data.manager(), outcome, metric = "estimate", years, exclude.ontology.names = NULL )
outcome |
The outcome for which to find earliest and latest years of data (must be registered in the data manager) |
metric |
The type of measurement to find earliest and latest years of data within the outcome. The default value is "estimate", but other options include "cv", "variance", and "sd". |
years |
The years to include. May be NULL to search all available years, or a numeric vector with no NA's or duplicates. |
exclude.ontology.names |
The names of ontologies to exclude from this search. Must be NULL or a character vector with no NA's or empty values. |
Get locations that have data for a given outcome, metric and set of years. Searches all sources and all ontologies that haven't been specifcally excluded
Get a Pair of Ontology Mappings that Aligns two Data Elements
get.mappings.to.align.ontologies( ontology.1, ontology.2, align.on.dimensions = intersect(names(ontology.1), names(ontology.2)), allow.non.overlapping.incomplete.dimensions = F, include.dim.names = NULL )get.mappings.to.align.ontologies( ontology.1, ontology.2, align.on.dimensions = intersect(names(ontology.1), names(ontology.2)), allow.non.overlapping.incomplete.dimensions = F, include.dim.names = NULL )
ontology.1, ontology.2
|
The ontologies of two data elements to be transformed |
align.on.dimensions |
The dimensions which should match in the transformed data |
allow.non.overlapping.incomplete.dimensions |
Logical indicating whether, when we map to an incomplete dimension, there can be no overlap in the from and to values for that dimension |
include.dim.names |
Optional argument, specifying specific dimension values that must be present in the transformed data |
Either a (1) NULL - if no mappings could align the ontologies or (2) a list with two elements, each an ontology.mapping object, such that applying the first to data conforming to ontology.1 and applying the second to data conforming to ontology.2 yields two data objects with the same dim.names
For one chain, the mixing statistic is the variance in the first quarter of simulations divided by the variance in the last quarter of simulations.
get.mcmc.mixing.statistic( simset, match.names = NULL, chains = simset$unique.chains, sort = T )get.mcmc.mixing.statistic( simset, match.names = NULL, chains = simset$unique.chains, sort = T )
match.names |
(Optional) A regex on parameter names for which to compute the mixing statistic. If NULL, all parameters are used. |
chains |
(Optional) Which chains to use, defaulting to all chains. |
sort |
(Optional) Whether to sort the output in decreasing order by mixing statistic value, defaulting to TRUE. |
Returns information useful for debugging ontology mapping errors
get.ontology.error.debug.info()get.ontology.error.debug.info()
Get an Ontology Mapping to Transform Data
get.ontology.mapping( from.ontology, to.ontology, allow.non.overlapping.incomplete.dimensions = F )get.ontology.mapping( from.ontology, to.ontology, allow.non.overlapping.incomplete.dimensions = F )
from.ontology |
The ontology to which the data to be transformed conform. Must be an 'ontology' object as created by |
to.ontology |
The ontology to which the transformed data should conform. Must be an 'ontology' object as created by |
allow.non.overlapping.incomplete.dimensions |
Logical indicating whether, when we map to an incomplete dimension, there can be no overlap in the from and to values for that dimension |
Either an object of class 'ontology.mapping' or NULL if no mapping that would bridge the differences is found
Get a Matrix that Applies an Ontology Mapping
get.ontology.mapping.matrix( ontology.mapping, from.dim.names, to.dim.names = NULL, error.prefix = "" )get.ontology.mapping.matrix( ontology.mapping, from.dim.names, to.dim.names = NULL, error.prefix = "" )
ontology.mapping |
An object of class 'ontology.mapping' - obtained either through register.ontology.mapping, get.ontology.mapping, get.mappings.to.align.ontologies |
to.dim.names |
The dimnames that the resulting transformed data should have (can represent a subset of the dimnames that the ontology mapping knows how to transform). If NULL, the ontology mapping will keep the dimnames in from.arr except for dimensions that are transformed |
error.prefix |
A character value to be prepended to any error messages thrown by the function |
Get P Bias Estimates
get.p.bias.estimates( data.manager = get.default.data.manager(), dimensions, levels.of.stratification, outcome.for.p, outcome.for.n, sub.location.type, super.location.type, main.location.type = "CBSA", minimum.sample.size = 12, from.year = NULL, to.year = NULL, main.location.type.p.source = NULL, sub.location.type.p.source = NULL, super.location.type.p.source = NULL, main.location.type.n.source = NULL, sub.location.type.n.source = NULL, super.location.type.n.source = NULL, debug = F )get.p.bias.estimates( data.manager = get.default.data.manager(), dimensions, levels.of.stratification, outcome.for.p, outcome.for.n, sub.location.type, super.location.type, main.location.type = "CBSA", minimum.sample.size = 12, from.year = NULL, to.year = NULL, main.location.type.p.source = NULL, sub.location.type.p.source = NULL, super.location.type.p.source = NULL, main.location.type.n.source = NULL, sub.location.type.n.source = NULL, super.location.type.n.source = NULL, debug = F )
data.manager |
The name of the data manager |
dimensions |
A character vector of dimensions, excluding year, from which stratifications will be generated. |
levels.of.stratification |
An integer vector specifying how the dimensions should be combined to form strata. '0' indicates totals (not stratified) while '1' indicates strata that are each stratified by one dimension at a time, '2' indicates strat that are each stratified by a combination of two dimensions at a time, etc. May not exceed the number of dimensions. Defaults to NULL, which is equivalent to '0'. |
outcome.for.p, outcome.for.n
|
Outcome names for proportion and denominator data, respectively, as found in the data manager |
sub.location.type |
Used to find p-bias "inside" estimates by comparing data for this type against that of the main location type. If NULL, no p-bias "inside" estimates are found. |
super.location.type |
Used to find p-bias "outside" estimates by comparing data for this type against that of the main location type. If NULL, no p-bias "outside" estimates are found. |
main.location.type |
The location type that serves as the basis of comparison. |
minimum.sample.size |
Numeric value specifying the minimum number of sub-main location pairs (or super-main location pairs) that must be found in order to calculate p-bias estimates |
from.year, to.year
|
Both NULL or both single numeric values |
A list containing mean and sd for p-bias "inside" and p-bias "outside" estimates. Some or all of these may be NA if 'sub.location.type' and/or 'super.location.type' were left NULL.
Other Nested Proportion Likelihoods:
create.nested.proportion.likelihood.instructions(),
create.nested.proportion.likelihood.instructions.with.included.multiplier(),
create.time.lagged.comparison.nested.proportion.likelihood.instructions()
Get Prior JHEEM Model Versions
get.prior.versions(version, recursive = T)get.prior.versions(version, recursive = T)
Other JHEEM Version Management Functions:
get.specification.for.version(),
register.model.specification(),
version.has.been.registered()
param ontology.name The name of an ontology (must be registered in the data manager)
get.registered.ontology( data.manager = get.default.data.manager(), ontology.name )get.registered.ontology( data.manager = get.default.data.manager(), ontology.name )
Get Simulation Data
get.simset.data( simset, outcomes, output = c("value", "numerator", "denominator")[[1]], keep.dimensions = NULL, dimension.values = list(), ..., check.consistency = T, drop.single.outcome.dimension = T, error.prefix = "Error getting simulation results: " )get.simset.data( simset, outcomes, output = c("value", "numerator", "denominator")[[1]], keep.dimensions = NULL, dimension.values = list(), ..., check.consistency = T, drop.single.outcome.dimension = T, error.prefix = "Error getting simulation results: " )
outcomes |
A character vector with one or more outcomes for which to pull data. Must be a subset of sim$outcomes |
keep.dimensions |
Which dimensions should be retained in the resulting array |
dimension.values |
A set of dimension values according to which to subset the data (will be combined with ...) |
... |
The parameters in ... are interpreted as additional dimension values according to which to subset the data. Each must be named, and either a character, integer, or logical vector |
check.consistency |
Whether to check the consistency of arguments. Setting to FALSE will yield faster performance but unintelligible error messages |
error.prefix |
A character value to prepend to any errors generating in getting these data |
drop.single.outcome.dimensions |
When set to FALSE, the resulting array will have 'outcome' as its last dimension regardless of how many outcomes we are getting data for. If TRUE, the returned array will omit that dimension when only one outcome is requested |
Returns an array whose dimensions are keep.dimensions - plus (if there is more than one outcome or drop.single.outcome.dimensions==FALSE) an 'outcome' dimension at the end
Get Simset Filename
get.simset.filename( version, location, calibration.code, n.sim, intervention.code = NULL, sub.version = NULL, include.path = T, root.dir = get.jheem.root.directory("Cannot get.simset.filename(): "), error.prefix = "" )get.simset.filename( version, location, calibration.code, n.sim, intervention.code = NULL, sub.version = NULL, include.path = T, root.dir = get.jheem.root.directory("Cannot get.simset.filename(): "), error.prefix = "" )
Get Simset Filename and Directory
get.simset.filename.and.dir( version, location, calibration.code, n.sim, intervention.code = NULL, sub.version = NULL, root.dir = get.jheem.root.directory("Cannot get.simset.filename(): "), error.prefix = "" )get.simset.filename.and.dir( version, location, calibration.code, n.sim, intervention.code = NULL, sub.version = NULL, root.dir = get.jheem.root.directory("Cannot get.simset.filename(): "), error.prefix = "" )
Get Simulation Set Paramater Values
get.simset.params( simset, match.names = NULL, simulation.indices = simset$n.sim, drop = T )get.simset.params( simset, match.names = NULL, simulation.indices = simset$n.sim, drop = T )
match.names |
A regex to select parameters by name. If NULL, all parameters are used. |
simulation.indices |
An integer or logical vector specifying which simulations to show in output. Defaults to the last simulation. |
drop |
If the default TRUE, then an output with only one simulation will be coerced to a vector. |
Get a Simulation Metadata Object
get.simulation.metadata( version, location, from.year = NULL, to.year = NULL, n.sim = 1, sub.version = NULL, jheem.kernel = NULL, update.labels = T, error.prefix = paste0("Error deriving the simulation-metadata for '", version, "' and location '", location, "': ") )get.simulation.metadata( version, location, from.year = NULL, to.year = NULL, n.sim = 1, sub.version = NULL, jheem.kernel = NULL, update.labels = T, error.prefix = paste0("Error deriving the simulation-metadata for '", version, "' and location '", location, "': ") )
version |
The version of the model specification (must have been previously registered) for which to get metadata |
location |
A single character value representing the location for the metadata |
from.year, to.year
|
The years which a corresponding simulation will have data for |
jheem.kernel |
Optional: the jheem.kernel on which to base the simulation metadata |
update.labels |
If jheem.kernel is not NULL, whether to get updated labels from the latest specification (vs the specification as it was when the kernel was created) |
error.prefix |
A string to prepend to any errors generated in getting the metadata object |
A simulation.metadata object contains metadata, such as the dim.names to which its contents will conform
Get a JHEEM Specification Object
get.specification.for.version(version)get.specification.for.version(version)
version |
The name of the version under which the specification was registered |
An object of class 'jheem.specification'
Other JHEEM Version Management Functions:
get.prior.versions(),
register.model.specification(),
version.has.been.registered()
Get a Specification Metadata Object
get.specification.metadata(version, location, error.prefix = "")get.specification.metadata(version, location, error.prefix = "")
version |
The version of the model specification (must have been previously registered) for which to get metadata |
location |
A single character value representing the location for the metadata |
error.prefix |
A string to prepend to any errors generated in getting the metadata object |
A specification.metadata object contains metadata, such as dim.names of quantities, for a specification
Get year bounds for outcome
get.year.bounds.for.outcome( data.manager = get.default.data.manager(), outcome, metric = "estimate", exclude.ontology.names = NULL )get.year.bounds.for.outcome( data.manager = get.default.data.manager(), outcome, metric = "estimate", exclude.ontology.names = NULL )
outcome |
The outcome for which to find earliest and latest years of data (must be registered in the data manager) |
metric |
The type of measurement to find earliest and latest years of data within the outcome. The default value is "estimate", but other options include "cv", "variance", and "sd". |
exclude.ontology.names |
The names of ontologies to exclude from this search. Must be NULL or a character vector with no NA's or empty values. |
Gets the earliest and latest years for which a data manager has data for a given outcome and metric. Searches all sources and all ontologies that haven't been specifically excluded
Import data from another JHEEM Data Manager
import.data(to.data.manager = get.default.data.manager(), from.data.manager)import.data(to.data.manager = get.default.data.manager(), from.data.manager)
to.data.manager |
A jheem.data.manager object |
from.data.manager |
A jheem.data.manager object |
Get an ontology's incomplete dimensions
incomplete.dimensions(x)incomplete.dimensions(x)
ontology |
An ontology, as created by |
A vector containing the names of the ontology's incomplete dimensions
Get an ontology's incomplete dimensions
## S3 method for class 'ontology' incomplete.dimensions(x)## S3 method for class 'ontology' incomplete.dimensions(x)
ontology |
An ontology, as created by |
A vector containing the names of the ontology's incomplete dimensions
Compares the percentage difference between the marginal sums of more stratified data and the data it corresponds to in more aggregated stratifications of the same source and ontology.
inspect.marginals( data.manager = get.default.data.manager, outcome = NULL, source = NULL, ontology = NULL, sub.stratification = NULL, super.stratification = NULL, years = NULL, locations = NULL, threshold.percent = 10, threshold.magnitude = 50, check.up.to.n.way.stratified = 1 )inspect.marginals( data.manager = get.default.data.manager, outcome = NULL, source = NULL, ontology = NULL, sub.stratification = NULL, super.stratification = NULL, years = NULL, locations = NULL, threshold.percent = 10, threshold.magnitude = 50, check.up.to.n.way.stratified = 1 )
data.manager |
A jheem.data.manager object |
outcome |
The outcome type for the data. Must be an outcome previously registered with |
source |
The (single) character name of the source from which these data derive. Must be a source previously registered with |
ontology |
The name of a registered ontology |
sub.stratification |
The name of a less-aggregated stratification |
super.stratification |
The name of a more-aggregated stratification |
years, locations
|
Show results for certain years (numeric, non-NA vector) or locations (character, non-NA vector) |
threshold.percent |
A percentage below which discrepancies will not be reported (default 10). |
threshold.magnitude |
A magnitude of difference between marginal sums and more-aggregated data below which discrepancies will not be reported (default 50). |
check.up.to.n.way.stratified |
An integer greater than 0 indicating the highest level of stratification to report marginal sum discrepancies for (default 1). |
Instantiate Likelihood
instantiate.likelihood( instructions, version, location, sub.version = NULL, data.manager = get.default.data.manager(), verbose = F, throw.error.if.no.data = F, error.prefix = "Error instantiating likelihood from instructions: " )instantiate.likelihood( instructions, version, location, sub.version = NULL, data.manager = get.default.data.manager(), verbose = F, throw.error.if.no.data = F, error.prefix = "Error instantiating likelihood from instructions: " )
instructions |
A 'jheem.likelihood.instructions' object |
data.manager |
A jheem.data.manager object, or the name of one in the active data binding (see |
verbose |
Should detailed messages be printed out as we go |
throw.error.if.no.data |
Should an error be thrown if no relevant data is found? |
Interpolate Values
interpolate(values, value.times, desired.times)interpolate(values, value.times, desired.times)
Create a Target Population that is the INTERSECTION of Other Target Populations
intersect.target.populations(..., name = NULL)intersect.target.populations(..., name = NULL)
... |
One or more target.population objects or lists of target populations |
name |
A short (<= 20 characters) descriptive name for the target population. Should be nicely formatted for public display |
Other Functions to create Target Populations:
create.target.population(),
diff.target.populations(),
union.target.populations()
Get indicators of which dimensions in an ontology are complete
is_complete(x) is.complete(x)is_complete(x) is.complete(x)
ontology |
An ontology, as created by |
A named logical vector - the corresponding to names(ontology) - indicating whether each dimension is complete
Get indicators of which dimensions in an ontology are complete
## S3 method for class 'ontology' is_complete(x)## S3 method for class 'ontology' is_complete(x)
ontology |
An ontology, as created by |
A named logical vector - the corresponding to names(ontology) - indicating whether each dimension is complete
Test if an object is of type 'ontology'
is.ontology(x)is.ontology(x)
x |
Object to be tested |
A single logical T/F value
Still need to flesh out this interface
Still need to flesh out this interface
jheem2::jheem.entity -> jheem
check()
JHEEM$check()
new()
JHEEM$new( jheem.kernel, sub.version, transmute.from.kernel, transmute.from.sub.version, error.prefix = "Cannot create JHEEM Instance: " )
crunch()
JHEEM$crunch( start.year, end.year, keep.from.year, keep.to.year, prior.simulation.set, prior.sim.index, solver.metadata, check.consistency = !self$has.been.crunched() )
run()
JHEEM$run( start.year, end.year, check.consistency, max.run.time.seconds, prior.simulation.set, prior.sim.index, keep.from.year, keep.to.year, simulation.chain, solver.metadata, finalize )
crunch.for.transmutation()
JHEEM$crunch.for.transmutation( keep.from.year, keep.to.year, prior.simulation.set, prior.sim.index, check.consistency = !self$has.been.crunched() )
transmute()
JHEEM$transmute( prior.simulation.set, prior.sim.index, keep.from.year, keep.to.year, simulation.chain, finalize, check.consistency )
test()
JHEEM$test()
extract.quantity.values()
JHEEM$extract.quantity.values()
extract.diffeq.settings()
JHEEM$extract.diffeq.settings()
set.element.value()
JHEEM$set.element.value( element.name, value, check.consistency = !self$has.been.crunched(), wrt.version = self$version )
set.element.functional.form.main.effect.alphas()
JHEEM$set.element.functional.form.main.effect.alphas( element.name, alpha.name, values, dimension, applies.to.dimension.values = names(values), check.consistency = !self$has.been.crunched(), wrt.version = self$version )
set.element.functional.form.interaction.alphas()
JHEEM$set.element.functional.form.interaction.alphas( element.name, alpha.name, value, applies.to.dimension.values, check.consistency = !self$has.been.crunched(), wrt.version = self$version )
set.quantity.foreground()
JHEEM$set.quantity.foreground( foreground, check.consistency = !self$has.been.crunched() )
set.parameters()
JHEEM$set.parameters(parameters, check.consistency, wrt.version = self$version)
set.element.functional.form.from.time()
JHEEM$set.element.functional.form.from.time( element.name, from.time, check.consistency = !self$has.been.crunched(), wrt.version = self$version )
set.element.functional.form.to.time()
JHEEM$set.element.functional.form.to.time( element.name, to.time, check.consistency = !self$has.been.crunched(), wrt.version = self$version )
set.element.ramp.times()
JHEEM$set.element.ramp.times( element.name, times, indices = 1:length(times), check.consistency = !self$has.been.crunched(), wrt.version = self$version )
set.element.ramp.values()
JHEEM$set.element.ramp.values( element.name, values, indices = 1:length(values), check.consistency = !self$has.been.crunched(), wrt.version = self$version )
set.element.taper.times()
JHEEM$set.element.taper.times( element.name, times, indices = 1:length(times), check.consistency = !self$has.been.crunched(), wrt.version = self$version )
set.element.taper.values()
JHEEM$set.element.taper.values( element.name, values, indices = 1:length(values), check.consistency = !self$has.been.crunched(), wrt.version = self$version )
set.element.functional.form.future.slope()
JHEEM$set.element.functional.form.future.slope( element.names, slope, check.consistency = !self$has.been.crunched(), wrt.version = self$version )
set.element.functional.form.future.slope.after.time()
JHEEM$set.element.functional.form.future.slope.after.time( element.names, after.time, check.consistency = !self$has.been.crunched(), wrt.version = self$version )
set.intervention()
JHEEM$set.intervention(intervention.code)
set.calibration.code()
JHEEM$set.calibration.code(calibration.code, outcome.location.mapping)
has.been.crunched()
JHEEM$has.been.crunched()
clone()
The objects of this class are cloneable with this method.
JHEEM$clone(deep = FALSE)
deepWhether to make a deep clone.
The engine for the JHEEM (Joint HIV Epidemiology and Economic Model) family of compartmental models of HIV and STI transmission. Provides tools to specify versioned model structures, compile and run them as differential-equation simulations, manage surveillance data, map between data ontologies, define interventions, and calibrate models to data via likelihoods.
The jheem2 functions ...
JHEEM Data Manager Parameters
metric |
The type of measurement. The default value is "estimate", but other options include "cv", "variance", and "sd". |
ont |
An ontology object as created by |
outcomes |
A character vector with the names of outcomes previously registered to this data manager |
sources |
A character vector with the names of sources previously registered to this data manager |
JHEEM Likelihood Parameters
log |
Whether to use log likelihood |
instructions |
A 'jheem.likelihood.instructions' object |
JHEEM Parameters
version |
The version of the model specification (must have been previously registered) |
data.manager |
A jheem.data.manager object |
error.prefix |
(Optional) A message to prepend to error messages. |
sim |
A 'jheem.simulation.set' object |
simset |
A 'jheem.simulation.set' object |
likelihood |
A 'jheem.likelihood' object |
likelihood.instructions |
A 'jheem.likelihood.instructions' object |
debug |
(dev argument) |
JHEEM Simulation Set Parameters
match.names |
A regex to select parameters by name. If NULL, all parameters are used. |
chains |
Which chains to use, defaulting to all. |
Join Multiple Interventions into a Single Intervention
join.interventions( ..., code = NULL, name = NULL, parameters = NULL, parameter.distribution = NULL, overwrite.existing.intervention = F, sequential = F )join.interventions( ..., code = NULL, name = NULL, parameters = NULL, parameter.distribution = NULL, overwrite.existing.intervention = F, sequential = F )
... |
One or more interventions to join. These may be either objects of class jheem.intervention or lists which contain only objects of class jheem.intervention |
code |
A brief (2-30 character) string that will uniquely identify this intervention |
parameter.distribution |
|
sequential |
Make a single (joint) set of likelihood instructions out of two or more likelihood instructions objects
join.likelihood.instructions(..., additional.weights = NULL)join.likelihood.instructions(..., additional.weights = NULL)
... |
One or more jheem.likelihood.instructions objects or lists which contain only jheem.likelihood.instructions objects #OR it could just be codes |
additional.weights |
A single numeric value that applies weight to all instructions. |
Join Outcome Location Mappings
join.outcome.location.mappings(mappings.to.join)join.outcome.location.mappings(mappings.to.join)
mappings.to.join |
A list of outcome.location.mappings objects |
Join multiple simulation sets into a single set
join.simulation.sets(...)join.simulation.sets(...)
... |
One or more jheem.simulation.set objects or lists that contain only jheem.simulation.set objects |
A jheem.simulation.set object
List registered data managers
list.data.managers()list.data.managers()
A data frame with one row per registered name: the name, the data manager's own name, and its file, release, MD5 digest and whether it was modified (NA where unknown)
Load a cached data manager
load.data.manager( file, name = NULL, description = NULL, set.as.default = F, provenance = NULL )load.data.manager( file, name = NULL, description = NULL, set.as.default = F, provenance = NULL )
file |
A file storing a cached data manager object (only) |
name |
A name for the local data manager. If NULL, the name of the cached data manager. |
description |
A description for the local data manager. If NULL, the description of the cached data manager. |
set.as.default |
Should the loaded data manager be set as the default data manager |
provenance |
Optional: what the caller knows about the file's release, as a named list
with any of 'sha256', 'release' and 'repository'. Kept with the file's name and MD5 digest;
see |
Load a Simulation Set
load.simulation.set(file)load.simulation.set(file)
file |
The file containing the saved simulation set |
Make Names for a Set of Age Strata
make.age.strata.names(endpoints = NULL, lowers = NULL, uppers = NULL)make.age.strata.names(endpoints = NULL, lowers = NULL, uppers = NULL)
endpoints |
A numeric vector of at least two points. endpoints[1] is the lower bound (inclusive) of the first stratum, endpoints[2] is the upper bound (exclusive) for the first stratum and the lower bound for the second stratum, etc. |
A character vector with length(endpoints)-1 values
Map Value's Ontology
map.value.ontology( value, target.dim.names, fun = "sum", allow.expand.values = T, allow.map.to.subset.of.target = T, allow.restratify.ages = T, allow.age.extrapolation = F, na.rm = T, smooth.infinite.age.to = 101, error.prefix = "" )map.value.ontology( value, target.dim.names, fun = "sum", allow.expand.values = T, allow.map.to.subset.of.target = T, allow.restratify.ages = T, allow.age.extrapolation = F, na.rm = T, smooth.infinite.age.to = 101, error.prefix = "" )
allow.map.to.subset.of.target |
|
error.prefix |
Other Functions to identify why ontologies fail to map:
apply.ontology.mapping(),
get.identity.ontology.mapping()
Create Traceplot of MCMC
mcmc.traceplot(simset, match.names, chains = simset$unique.chains, burn = 0)mcmc.traceplot(simset, match.names, chains = simset$unique.chains, burn = 0)
match.names |
A regex to select parameters by name. If NULL, all parameters are used. |
chains |
Which chains to use, defaulting to all. |
burn |
How many iterations to burn and thus ignore on the plot, defaulting to 0. |
Modify an Ontology's Names
## S3 replacement method for class 'ontology' names(ont) <- value## S3 replacement method for class 'ontology' names(ont) <- value
Create an ontology object
ontology(..., incomplete.dimensions = NULL)ontology(..., incomplete.dimensions = NULL)
... |
One or more character vectors which must be NAMED |
incomplete.dimensions |
A character vector indicating which dimensions are incomplete. Must be a subset of the names of ... |
An ontology is a set of dimnames with specific characteristics: (1) the dimnames must be named, (2) some of the dimensions may be noted as "incomplete". An incomplete dimension is one for which the given values for a dimension may not represent all possible values for that dimension
The Constructor
The Constructor
The Print Function
A test for equality - to be overwritten in subclass –#
Test if this ontology.mapping can apply to the given dim.names
Test if this ontology.mapping can apply to the given ontology
Get the dimnames that would be generated after applying this mapping to some data with the given dim.names
Get the ontology that would be generated after applying this mapping to some data
Get the dimnames that would be generated after applying this mapping to some data with the given dim.names
new()
ONTOLOGY.MAPPING$new(name, component.names = name)
print()
ONTOLOGY.MAPPING$print(...)
equals()
ONTOLOGY.MAPPING$equals(other)
can.apply.to.dim.names()
ONTOLOGY.MAPPING$can.apply.to.dim.names( from.dim.names, to.dim.names = NULL, thorough.validation = T, throw.errors = F, error.prefix = "" )
can.apply.to.ontology()
ONTOLOGY.MAPPING$can.apply.to.ontology( from.ontology, to.ontology = NULL, thorough.validation = T, throw.errors = F, error.prefix = "" )
apply.to.dim.names()
ONTOLOGY.MAPPING$apply.to.dim.names( from.dim.names, thorough.validation = T, error.prefix = "Cannot apply ontology.mapping to dim names: " )
apply.to.ontology()
ONTOLOGY.MAPPING$apply.to.ontology( ontology, thorough.validation = T, error.prefix = "Cannot apply ontology.mapping to ontology: " )
An alias of the apply.to.dim.names function (which appropriately handles if dim.names is additionally an ontology)
reverse.apply.to.dim.names()
ONTOLOGY.MAPPING$reverse.apply.to.dim.names( to.dim.names, error.prefix = "Cannot apply ontology.mapping from dim names: " )
apply()
ONTOLOGY.MAPPING$apply( from.arr, to.dim.names = NULL, fun = "sum", na.rm = F, error.prefix = "Cannot apply ontology.mapping: " )
reverse.apply()
ONTOLOGY.MAPPING$reverse.apply( to.arr, from.dim.names = NULL, na.rm = F, error.prefix = "Cannot reverse-apply ontology.mapping: " )
get.matrix()
ONTOLOGY.MAPPING$get.matrix( from.dim.names, to.dim.names, error.prefix = "Cannot get matrix from ontology.mapping: " )
get.mapping.indices()
ONTOLOGY.MAPPING$get.mapping.indices( from.dim.names, to.dim.names, error.prefix = "Cannot get mapping indices from ontology.mapping: " )
A list, with length the same as the length that would be generated by applying the ontology mapping to data with the given from.dim.names The ith element of the return value is an integer vector containing the indices into the from data which are combined ie - to[i] would be equal to fun(from[ get.mapping.indices()[[i]] ])
get.mapping.vector()
ONTOLOGY.MAPPING$get.mapping.vector( from.values = character(), from.dimension = self$from.dimensions[1], to.dimension = self$to.dimensions[1] )
get.reverse.mapping.vector()
ONTOLOGY.MAPPING$get.reverse.mapping.vector( to.values = character(), from.dimension = self$from.dimensions[1], to.dimension = self$to.dimensions[1] )
get.reverse.mapping.indices()
ONTOLOGY.MAPPING$get.reverse.mapping.indices( from.dim.names, to.dim.names, error.prefix = "Cannot get mapping indices from ontology.mapping: " )
get.required.from.dim.names()
ONTOLOGY.MAPPING$get.required.from.dim.names(to.dim.names)
get.required.from.dimensions()
ONTOLOGY.MAPPING$get.required.from.dimensions(to.dimensions)
clone()
The objects of this class are cloneable with this method.
ONTOLOGY.MAPPING$clone(deep = FALSE)
deepWhether to make a deep clone.
Join multiple dim.names lists
outer.join.dim.names(..., error.prefix = "")outer.join.dim.names(..., error.prefix = "")
... |
can be either (1) dim.names or (2) lists of dim.names |
A named list, with an element for each name that appears in any of the dim.names in ... - rv[[d]] is the union of all values in the d dimension of any dim.names in ...
Convert Age Strata Names into Lower and Upper Bounds for Each Stratum
parse.age.strata.names(strata.names, allow.partial.parsing = F)parse.age.strata.names(strata.names, allow.partial.parsing = F)
strata.names |
Names of age brackets. The function knows how to parse names generated in the format given by make.age.strata.names, as well as some other common formats |
allow.partial.parsing |
Whether to parse if only SOME of the age brackets are parseable |
A list with two elements, $lowers and $uppers, representing the lower (inclusive) and upper (exclusive) bounds of each age stratum
Parses the calibration information that was compressed into the filename of a properly saved calibration simset.
parse.simset.filename(filename, throw.error.if.malformed = T)parse.simset.filename(filename, throw.error.if.malformed = T)
Parse Year Names
parse.year.names(years, allow.partial.parsing = F)parse.year.names(years, allow.partial.parsing = F)
Get Percentage of Run Cache Completed
percentage.cache.complete(version, calibration.code, locations, chains)percentage.cache.complete(version, calibration.code, locations, chains)
Matrix of percentages shape [chain x location]
Cleaning and verifying the plotting data so it can be properly plotted
## S3 method for class 'data.validation' plot( simset.args, deparsed.substituted.args.simset.args, outcomes, corresponding.data.outcomes, plot.which, summary.type, simset.names = NULL )## S3 method for class 'data.validation' plot( simset.args, deparsed.substituted.args.simset.args, outcomes, corresponding.data.outcomes, plot.which, summary.type, simset.names = NULL )
simset.args |
A list of the ... parameter in the previous function, containing simset data. Will be processed and returned as $simset.list |
deparsed.substituted.args.simset.args |
The ... parameter with each argument converted to a character exactly as it is, without evaluating any expressions. Used to give un-named simsets names later. |
outcomes |
The outcomes asked for by the plotting function. Will be processed and returned as $outcomes |
corresponding.data.outcomes |
Checked for proper value, not passed out of the function |
plot.which |
Checked for proper value, not passed out of the function |
summary.type |
Checked for proper value, not passed out of the function |
A list containing processed $simset.list and $outcomes (a vector)
Plot Simulations With Plotly
## S3 method for class 'simulations' plot( ..., outcomes, corresponding.data.outcomes = NULL, split.by = NULL, facet.by = NULL, dimension.values = list(), target.ontology = NULL, summary.type = c("individual.simulation", "mean.and.interval", "median.and.interval")[1], plot.year.lag.ratio = F, title = "location", n.facet.rows = NULL, interval.coverate = 0.95, data.manager = get.default.data.manager(), style.manager = get.default.style.manager(), hide.legend = FALSE )## S3 method for class 'simulations' plot( ..., outcomes, corresponding.data.outcomes = NULL, split.by = NULL, facet.by = NULL, dimension.values = list(), target.ontology = NULL, summary.type = c("individual.simulation", "mean.and.interval", "median.and.interval")[1], plot.year.lag.ratio = F, title = "location", n.facet.rows = NULL, interval.coverate = 0.95, data.manager = get.default.data.manager(), style.manager = get.default.style.manager(), hide.legend = FALSE )
... |
One or more of either (1) jheem.simulation.set objects or (2) lists containing only jheem.simulation or jheem.simset objects |
outcomes |
A character vector of which simulation outcomes to plot |
split.by |
A character vector of dimensions for which to make different lines |
facet.by |
A character vector of dimensions for which to make different panels |
data.manager |
The data.manager from which to draw real-world data for the plots |
style.manager |
An object of class 'jheem.style.manager' specifying style attributes |
See "Simplot" for ggplot2-based plotting.
Prepare Plot Data A utility that performs the data-pulling half of the simplot operation for applications like webtools that need the step to be separate.
prepare.plot( simset.list = NULL, outcomes = NULL, locations = NULL, corresponding.data.outcomes = NULL, split.by = NULL, facet.by = NULL, dimension.values = list(), dimension.values.post.mapping = list(), target.ontology = NULL, plot.which = c("sim.and.data", "sim.only", "data.only")[1], summary.type = c("individual.simulation", "mean.and.interval", "median.and.interval")[1], omit.data.years = NULL, data.na.rm = NULL, data.locations = NULL, plot.year.lag.ratio = F, label.function = NULL, title = "location", title.suffix = NULL, append.url = F, data.manager = get.default.data.manager(), style.manager = get.default.style.manager(), show.data.pull.error = F, debug = F )prepare.plot( simset.list = NULL, outcomes = NULL, locations = NULL, corresponding.data.outcomes = NULL, split.by = NULL, facet.by = NULL, dimension.values = list(), dimension.values.post.mapping = list(), target.ontology = NULL, plot.which = c("sim.and.data", "sim.only", "data.only")[1], summary.type = c("individual.simulation", "mean.and.interval", "median.and.interval")[1], omit.data.years = NULL, data.na.rm = NULL, data.locations = NULL, plot.year.lag.ratio = F, label.function = NULL, title = "location", title.suffix = NULL, append.url = F, data.manager = get.default.data.manager(), style.manager = get.default.style.manager(), show.data.pull.error = F, debug = F )
simset.list |
A list of jheem.simulation.set objects |
outcomes |
A character vector of which simulation outcomes to plot |
corresponding.data.outcomes |
Specify directly which data outcomes should be plotted against simulation outcomes. Must be NULL or a character vector with outcomes as names; all of those outcomes must be present in either the 'outcomes' argument or in '...'" |
split.by |
At most one dimension |
facet.by |
Any number of dimensions but cannot include the split.by dimension |
dimension.values.post.mapping |
How to subset data in the form it will take after mappings have been applied to align sim and data ontologies. A list. |
plot.which |
Should simulation data and calibration data be plotted ('sim.and.data'), or only simulation data ('sim.only'), or only calibration data ('data.only') |
omit.data.years |
Years to omit data, for example if data is available but wasn't calibrated to, while still showing simulation values for those years |
data.na.rm |
Sets na.rm = T or F during the data pull step. If NULL, will use T for rates, proportions, and ratios, and F for all other scales. |
data.locations |
Specifies locations for which to pull data. May be 1. NULL, in which case data locations will be inferred from the simsets' likelihoods, 2. a character vector of locations, or 3. a list of character vectors with outcomes as list names. For 3., outcomes not included will have their data locations inferred as in 1. |
label.function |
A function to reformat labels. If NULL, will use the first provided simset's "get.labels" property, or will do no transformation if plotting data only. |
title |
NULL or a single, non-NA character value. If "location", the location of the first provided simset (if any) will be used for the title. |
title.suffix |
NULL or a single, non-NA character value. Something to append to the end of the title that would be generated automatically based on the 'title' argument. Note that this pastes with no space, so add the space in if you want it. |
data.manager |
The data.manager from which to draw real-world data for the plots |
style.manager |
We are going to have to define this down the road. It's going to govern how we do lines and sizes and colors. For now, just hard code those in, and we'll circle back to it |
show.data.pull.error |
Not finding data does not block the plot from showing simulation projections, but if you'd like to see in error when data doesn't appear, set this to TRUE. |
Print an ontology
## S3 method for class 'ontology' print(ont)## S3 method for class 'ontology' print(ont)
ontology |
An ontology, as created by ontology |
Pull data from a data manager
pull.data( data.manager = get.default.data.manager(), outcome, metric = "estimate", keep.dimensions = NULL, dimension.values = NULL, sources = NULL, from.ontology.names = NULL, exclude.ontology.names = NULL, target.ontology = NULL, allow.mapping.from.target.ontology = T, append.attributes = NULL, metadata.collapse = " | ", append.metrics = NULL, allow.other.sources.for.denominator = F, na.rm = F, ignore.ontologies.without.requested.locations = T, check.arguments = T, debug = F, ... )pull.data( data.manager = get.default.data.manager(), outcome, metric = "estimate", keep.dimensions = NULL, dimension.values = NULL, sources = NULL, from.ontology.names = NULL, exclude.ontology.names = NULL, target.ontology = NULL, allow.mapping.from.target.ontology = T, append.attributes = NULL, metadata.collapse = " | ", append.metrics = NULL, allow.other.sources.for.denominator = F, na.rm = F, ignore.ontologies.without.requested.locations = T, check.arguments = T, debug = F, ... )
data.manager |
A jheem.data.manager object |
outcome |
The outcome type for the data. Must be an outcome previously registered to this data manager with |
metric |
The type of measurement. The default value is "estimate", but other options include "cv", "variance", and "sd". |
keep.dimensions |
The dimensions that should be retained in the returned value |
dimension.values |
A named list, indicating which values for specific dimensions to pull data for. Each element must be a named character, numeric, or logical vector. |
sources |
The data sources from which to pull data (if available). If NULL, will pull from all data sources that have any relevant data |
from.ontology.names |
The names of the ontologies from which to pull data (if available). If NULL, will pull from all ontologies that have any relevant data and can be mapped to the requested ontology. Must refer to ontologies previously registered to this data manager with |
target.ontology |
Optional argument, indicating the ontology according to which results are desired. The data manager will apply an ontology mapping (if it can) to align its data to the desired ontology |
allow.mapping.from.target.ontology |
A logical indicator. If TRUE, if target.ontology is specified, but the data manager does not have data that can be mapped to the target ontology, it will search for data such that an ontology.mapping can be applied to data in the target.ontology that make those data align with the data pulled |
append.attributes |
A character vector indicating requested data attributes to include with the result. May contain "url", "details", the name of any other registered metadata field, and/or "metadata" |
metadata.collapse |
A single character value used to separate multiple metadata values (eg several URLs) within one element of the appended attributes. Defaults to " | ", which cannot appear in a valid URL. Use "__" to get the separator used before this argument existed |
na.rm |
Whether to disregard NA values when aggregating out dimensions not in keep.dimensions |
ignore.ontologies.without.requested.locations |
If 'dimension.values' includes a location dimension, should ontologies that don't have any of those locations for the requested outcome be ignored? See detailed documentation about how ontologies factor into the output. (NOT YET WRITTEN) |
... |
Optional alternative way to specify dimension.values. Each element must be a named character, numeric, or logical vector. |
include.sources.without.data.in.output |
When 'sources' is not NULL, include all sources in 'sources' in the output array even if no data was found for some, or even all, sources. If 'sources' is NULL, will include all registered sources for the outcome in the output array. |
A numeric array with named dimnames, with one dimension for each value of 'keep.dimensions', plus an additional dimension, "source" at the beginning, with one value for each source from which data were pulled The return value may have several attributes: (1) If target.ontology is not-NULL and allow.mapping.from.target.ontology==T, 'ontology.mapping' with refer to an ontology.mapping object that can be applied to data in the target.ontology to make them align with the returned array (2) If append.attributes includes "url", an array with the same dimensions as the returned array, where each element is one or more URLs separated by 'metadata.collapse' (3) If append.attributes includes "details", an array with the same dimensions as the returned array, where each element is one or more details about data collection separated by 'metadata.collapse' (4) For any other metadata field named in append.attributes (eg "author"), a character array of the same form as for "url" (5) If append.attributes includes "metadata", 'metadata.ids', a list array with the same dimensions as the returned array where each element is an integer vector of metadata record IDs (NA where the data are NA), and 'metadata', a data frame of the records those IDs refer to (as returned by the data manager's get.metadata.records() method) For all of these, an element is NA wherever the returned data are NA
Put data into a data manager
put.data( data.manager = get.default.data.manager(), data, outcome, metric, source, ontology.name, dimension.values = NULL, url = NULL, details = NULL, metadata = NULL, allow.na.to.overwrite = F, dimension.values.to.distribute = list(), allow.distributing.on.proportion.scale = F, round.distributed.dimension.values = T, debug = F, printouts = F )put.data( data.manager = get.default.data.manager(), data, outcome, metric, source, ontology.name, dimension.values = NULL, url = NULL, details = NULL, metadata = NULL, allow.na.to.overwrite = F, dimension.values.to.distribute = list(), allow.distributing.on.proportion.scale = F, round.distributed.dimension.values = T, debug = F, printouts = F )
data.manager |
A jheem.data.manager object |
data |
A numeric array or scalar value containing the data to store. If it is an array, it must have named dimnames set |
outcome |
The outcome type for the data. Must be an outcome previously registered with |
metric |
The type of measurement. The default value is "estimate", but other options include "cv", "variance", and "sd". |
source |
The (single) character name of the source from which these data derive. Must be a source previously registered with |
ontology.name |
The name of the ontology which the data follow. Must be an ontology previously registered with |
dimension.values |
A named list that indicates what subset of a bigger data element these particular data should be stored into. Each element must be a named character, numeric, or logical vector. |
url |
A character vector with at least one element giving one or more URLs indicating where the data derive from |
details |
A character vector with at least one element giving one or more URLs giving data collection details. In general, data collected and tabulated using the same approach should have the same details, whereas data with different methods/tabulation should have different details |
metadata |
A named list of metadata describing every data point in this put, such as list(url=..., details=..., author="CDC", year="2021"). Names must be fields registered with |
allow.na.to.overwrite |
A logical indicator for whether NA values in data should be allowed to overwrite previous values put to the data manager (if data have been put previously) |
dimension.values.to.distribute |
A named list of the dimensions and their values which should be redistributed |
round.distributed.dimension.values |
Should distributed quantities be rounded? |
Put long-form data into a data manager
#'@inheritParams distribute.dimension.values
put.data.long.form( data.manager = get.default.data.manager(), data, outcome, metric, source, ontology.name, dimension.values = NULL, url = NULL, details = NULL, metadata = NULL, allow.na.to.overwrite = F, dimension.values.to.distribute = list(), allow.distributing.on.proportion.scale = F, round.distributed.dimension.values = T, debug = F, printouts = F )put.data.long.form( data.manager = get.default.data.manager(), data, outcome, metric, source, ontology.name, dimension.values = NULL, url = NULL, details = NULL, metadata = NULL, allow.na.to.overwrite = F, dimension.values.to.distribute = list(), allow.distributing.on.proportion.scale = F, round.distributed.dimension.values = T, debug = F, printouts = F )
data.manager |
A jheem.data.manager object |
data |
A data frame or other 2-dimensional data structure with named columns. Must contain a column named 'value' of numeric values. If the 'source' argument is NULL, then data must also have a column named 'source' that gives the source for each row. May contain additional columns with names matching the specified ontology, which have the dimension values for each row. Any other columns are ignored |
outcome |
The outcome type for the data. Must be an outcome previously registered with |
metric |
The type of measurement. The default value is "estimate", but other options include "cv", "variance", and "sd". |
source |
The (single) character name of the source from which these data derive. Must be a source previously registered with |
ontology.name |
The name of the ontology which the data follow. Must be an ontology previously registered with |
dimension.values |
A named list that indicates what subset of a bigger data element these particular data should be stored into. Each element must be a named character, numeric, or logical vector. |
url |
A character vector with at least one element giving one or more URLs indicating where the data derive from |
details |
A character vector with at least one element giving one or more URLs giving data collection details. In general, data collected and tabulated using the same approach should have the same details, whereas data with different methods/tabulation should have different details |
metadata |
A named list of metadata describing every data point in this put, such as list(url=..., details=..., author="CDC", year="2021"). Names must be fields registered with |
allow.na.to.overwrite |
A logical indicator for whether NA values in data should be allowed to overwrite previous values put to the data manager (if data have been put previously) |
dimension.values.to.distribute |
A named list of the dimensions and their values which should be redistributed |
round.distributed.dimension.values |
Should distributed quantities be rounded? |
Loads each recorded data manager through the release resolver (see
set.data.release.resolver) and checks it against the recorded digests.
rebuild.data.binding(x)rebuild.data.binding(x)
x |
A record from |
A 'jheem.data.binding' object with the recorded names
Register Information about Aging for a Model Specification
register.aging( specification, aging.rate.value, tag = "aging", groups = c("uninfected", "infected"), applies.to = list() )register.aging( specification, aging.rate.value, tag = "aging", groups = c("uninfected", "infected"), applies.to = list() )
specification |
The jheem.specification object to modify |
aging.rate.value |
The values for the aging rate. Either: (1) a numeric object, (2) a character string giving the name of a model quantity or a model element, (3) an 'call' or 'expression' object (generated by expression() or expr()) containing an expression comprising other model quantities or model elements, and the operators +, -, *, /, ^, sqrt, log, and exp, or (4) a function whose arguments are some subset of 'specification.metadata', 'location', other model quantities and model elements, and ... |
tag |
A tag used to follow track this component |
groups |
The group(s) to which the aging apply. Either 'infected' or 'uninfected' or both |
applies.to |
A named list of character or integer vectors, denoting what subset of the group aging applies to |
Other Defining Core Components for a Model Specification:
register.model.mechanism(),
register.mortality(),
register.natality(),
register.remission(),
register.transition(),
register.transmission()
Register Parameters to Be Used in Calibrating a JHEEM Version
register.calibrated.parameters.for.version( version, distribution, sampling.blocks, apply.function, join.with.previous.version, calibrate.to.year )register.calibrated.parameters.for.version( version, distribution, sampling.blocks, apply.function, join.with.previous.version, calibrate.to.year )
version |
The name of an EHE version for which a specification has been registered with |
distribution |
An object of class 'distribution' that specifies the prior distribution for the parameters |
sampling.blocks |
A list (which may optionally be named) of character vectors. Each element (a character vector) denotes a subset of the parameters to be sampled as a single block during the calibration process. These elements must contain ONLY values present in [email protected], and every value in [email protected] must be present in at least one of the blocks |
apply.function |
A function that knows how to apply parameter values to a jheem.model.settings object. The function should take two arguments: (1) 'model.settings', an object of class jheem.model.settings, and (2) 'parameters', a named numeric vector |
join.with.previous.version |
Whether the distribution, apply.function, and sampling blocks should be merged with those of the previous version |
calibrate.to.year |
The year to which the calibration should be run before sampling parameters |
*Calibrated* parameters have their values fitted though a Bayesian calibration process
Register Calibration Info
register.calibration.info( code, likelihood.instructions, is.preliminary, end.year, parameter.names, parameter.aliases = NULL, n.iter, thin, description, special.case.likelihood.instructions = list(), fixed.initial.parameter.values = numeric(), max.run.time.seconds = Inf, solver.metadata = NULL, n.chains = if (is.preliminary) 1 else 4, n.burn = if (is.preliminary) 0 else floor(n.iter/2), data.manager = get.default.data.manager(), preceding.calibration.codes = character(), draw.from.parent.version = F, weight.to.preceding.variance.estimates = 0.5, error.prefix = "Error registering calibration info: " )register.calibration.info( code, likelihood.instructions, is.preliminary, end.year, parameter.names, parameter.aliases = NULL, n.iter, thin, description, special.case.likelihood.instructions = list(), fixed.initial.parameter.values = numeric(), max.run.time.seconds = Inf, solver.metadata = NULL, n.chains = if (is.preliminary) 1 else 4, n.burn = if (is.preliminary) 0 else floor(n.iter/2), data.manager = get.default.data.manager(), preceding.calibration.codes = character(), draw.from.parent.version = F, weight.to.preceding.variance.estimates = 0.5, error.prefix = "Error registering calibration info: " )
parameter.aliases |
A named list of character vectors. Each character vector must be one or more parameter names from the parameter distribution, and the names represent the aliases to be used in sampling |
data.manager |
The data manager the likelihood is instantiated with, or its name in the data binding. Under a binding, a data manager bound under a name is stored as that name, and the name is resolved in the binding active when the calibration is set up |
error.prefix |
Makes a data manager available as get.data.manager(name). Registering a name again replaces the earlier manager.
register.data.manager(name, data.manager)register.data.manager(name, data.manager)
name |
A name for the data manager, such as 'census': letters, digits, '.' and '_', starting with a letter |
data.manager |
A jheem.data.manager object |
The data manager, invisibly, so the result can also be assigned
Register a metadata field to a data manager
register.data.metadata.field( data.manager = get.default.data.manager(), name, required = F )register.data.metadata.field( data.manager = get.default.data.manager(), name, required = F )
data.manager |
A jheem.data.manager object |
name |
The name (a single character value) of the field, such as "author" or "year" |
required |
A logical indicating whether every subsequent put must supply a value for this field. Data already in the data manager are not affected |
Every data manager starts with the fields "url" and "details", both required
Register a new data ontology to a data manager before putting data to it
register.data.ontology(data.manager = get.default.data.manager(), name, ont)register.data.ontology(data.manager = get.default.data.manager(), name, ont)
data.manager |
A jheem.data.manager object |
name |
The name of the data group |
ont |
An ontology object as created by |
Register an outcome to a data manager before putting data for that outcome
register.data.outcome( data.manager = get.default.data.manager(), outcome, metadata, denominator.outcome = NULL, denominator.lags.by.one.year = F, overwrite = F, allow.missing.denominator.outcome = F )register.data.outcome( data.manager = get.default.data.manager(), outcome, metadata, denominator.outcome = NULL, denominator.lags.by.one.year = F, overwrite = F, allow.missing.denominator.outcome = F )
data.manager |
A jheem.data.manager object |
outcome |
The name (a single character value) of the outcome. This is the 'internal' name by which the outcome will be referenced in accessing the data manager |
metadata |
An object of class 'outcome.metadata', as created by |
denominator.outcome |
The denominator outcome type that should be used when aggregating data (taking a weighted average) for this outcome type. Must be a previously registered outcome with scale='non.negative.number'. Only applies if scale is 'rate', 'proportion', or 'time' |
denominator.lags.by.one.year |
Flag indicating whether the denominator data is shifting one year earlier than this outcome's data. For example, data for this outcome in year 2020 will use the 2019 denominator data if this flag is set to TRUE. |
overwrite |
A logical indicating whether the information on this outcome should overwrite previously-registered information about this outcome. However, this registration must include the same metadata$scale and denominator.outcome (ie, can't change the structure of the outcome, only the display 'trappings') |
allow.missing.denominator.outcome |
A logical allowing the user to register an outcome of scale 'rate', 'proportion' or 'time' without supplying a denominator outcome |
Register a data source to a data manager before putting data from that source
register.data.source( data.manager = get.default.data.manager(), source, parent.source, full.name, short.name = full.name )register.data.source( data.manager = get.default.data.manager(), source, parent.source, full.name, short.name = full.name )
data.manager |
A jheem.data.manager object |
source |
The name (a single character value) of the source. This is the 'internal' name by which the source will be referenced in accessing the data manager |
parent.source |
A parent source registered with this data manager that reflects the origin of the data this source uses |
full.name |
A descriptive, fully-formatted and capitalized name to use in generating figures and tables (eg in popovers). Avoid abbreviations. Should be unique to the data source (although this is not enforced) |
short.name |
A name for the data source to use in setting where brevity is important. Ideal to use abbreviations, but can be the same as full.name |
Note: a source is conceived such that one source cannot contain two sets of data for the same set of dimension values
Register Default Parameter Values
register.default.parameter.values(specification, parameter.values)register.default.parameter.values(specification, parameter.values)
Set Whether to Fix Strata Sizes During a Time Period
register.fixed.model.strata( specification, applies.after.time, applies.before.time, fix.strata = T, dimensions.to.fix = NULL )register.fixed.model.strata( specification, applies.after.time, applies.before.time, fix.strata = T, dimensions.to.fix = NULL )
specification |
The jheem.specification object |
applies.after.time, applies.before.time
|
Single numeric values giving the time frame over whether this setting applies |
fix.strata |
A single logical value indicating whether strata should be fixed during this time frame |
dimensions.to.fix |
A character vector denoting which dimensions should be fixed. These should be dimensions common to both infected and uninfected groups. These are only used if fix.strata==TRUE |
Set The Initial Model Population
register.initial.population(specification, value, group)register.initial.population(specification, value, group)
specification |
The jheem.specification object |
value |
Either: (1) a numeric object, (2) a character string giving the name of a model quantity or a model element, (3) an 'call' or 'expression' object (generated by expression() or expr()) containing an expression comprising other model quantities or model elements, and the operators +, -, *, /, ^, sqrt, log, and exp, or (4) a function whose arguments are some subset of 'specification.metadata', 'location', other model quantities and model elements, and ... |
group |
Which group ("infected" or "uninfected") this initial population is for |
Register a Model Element
register.model.element( specification, name, scale, dimensions = NULL, dimension.values = NULL, resolve.dimension.values.against.model = T, value = NULL, get.value.function = NULL, functional.form = NULL, get.functional.form.function = NULL, functional.form.scale = scale, functional.form.from.time = NULL, functional.form.to.time = Inf, get.functional.form.function.name = NULL, get.value.function.name = NULL, ..., ramp.scale = scale, ramp.times = numeric(), ramp.values = numeric(), ramp.value.application = c("multiplier", "absolute")[1], ramp.interpolate.links = "identity", taper.scale = scale, taper.times = numeric(), taper.values = numeric(), taper.value.application = c("multiplier", "absolute")[1], taper.interpolate.links = "identity" )register.model.element( specification, name, scale, dimensions = NULL, dimension.values = NULL, resolve.dimension.values.against.model = T, value = NULL, get.value.function = NULL, functional.form = NULL, get.functional.form.function = NULL, functional.form.scale = scale, functional.form.from.time = NULL, functional.form.to.time = Inf, get.functional.form.function.name = NULL, get.value.function.name = NULL, ..., ramp.scale = scale, ramp.times = numeric(), ramp.values = numeric(), ramp.value.application = c("multiplier", "absolute")[1], ramp.interpolate.links = "identity", taper.scale = scale, taper.times = numeric(), taper.values = numeric(), taper.value.application = c("multiplier", "absolute")[1], taper.interpolate.links = "identity" )
specification |
The jheem.specification object |
name |
The name of the model element. Cannot overlap with the names of model quantities |
scale |
The scale for this model.element. Can be 'rate', 'ratio', 'proportion', 'time', 'number', 'non.negative.number' |
dimensions |
Optional parameter to specify which dimensions the model.element is expected to take |
dimension.values |
Optional parameter to specify which dimension.values the model.element will use in its dimension names |
value |
A numeric value that serves as the value for this element if it is not otherwise specified. If NULL, then a value must be specified either by a get.value.function (a function which returns a value), or by a functional.form |
get.value.function |
An alternative to passing value directly, if the value needs to be different by location. This should be a function that takes arguments location, specification, and ... |
functional.form |
An object of class 'functional.form' that produces the background values for this element. Pass NULL if no functional.form is to be used, or if it is to be obtained by get.functional.form.function |
get.functional.form.function |
An alternative to passing background functional.form directly, if the background functional.form needs to be different by location. This should be a function that takes arguments location, specification, and ... |
functional.form.scale |
The scale of values produced by the background functional.form |
functional.form.from.time, functional.form.to.time
|
The time frame over which the functional.form applies |
get.value.function.name, get.functional.form.function.name
|
Optional - the actual names of the functions passed to 'get.value.function' or 'get.functional.form.function' - used to make error messages more informative |
... |
Arguments to be passed to either get.functional.form.function or get.value.function |
ramp.scale, taper.scale
|
If the ramp or taper operates on a different scale than the element evaluates to, specified here |
ramp.times, taper.times
|
The (default) times at which to ramp up to taper down |
ramp.values, taper.values
|
The (default) multipliers for ramp or taper times |
ramp.value.application, taper.value.application
|
How to interpret ramp and taper values. 'multiplier' multiplies the ramp by the first functional.form-generated value (and taper by the last functional.form-generated value). 'absolute' just plugs in the value directly |
ramp.interpolate.links, taper.interpolate.links
|
The name(s) of link function (either 'identity', 'log', or 'exp') denoting the scale at which to interpolate values for the ramp or taper. Can be either a single value (applied to all elements in the ramp), or a vector of length(ramp.times) or length(taper.times) |
resolve.dimension.values.against.model.ontologies |
A logical indicating whether, if dimension.values are supplied, they should be resolved against model ontologies and have compartment.value.aliases for the model specification applied to them |
A convenience function to streamline registering multiple model.elements for which we only need to specify a value
register.model.element.values(specification, ..., scale)register.model.element.values(specification, ..., scale)
specification |
The jheem.specification object to modify |
... |
A set of named values. The names correspond to the names of the model elements, and the values should be either (1) numeric objects or (2) functions that take arguments 'location' and 'settings' and returns a numeric value |
scale |
The scale at which the elements apply |
Register a Foreground for a Model Specification
register.model.foreground(specification, foreground, name)register.model.foreground(specification, foreground, name)
specification |
The jheem.specification object to modify |
foreground |
An object of class 'jheem.model.foreground', as created by |
name |
A single character value giving the name by which the foreground can be referred to |
Register Information about Disease Transmission for a Model Specification
register.model.mechanism( specification, type, value, tags, groups, from.groups, to.groups, dimension, from.compartments, to.compartments, na.replacement = as.numeric(NA), ... )register.model.mechanism( specification, type, value, tags, groups, from.groups, to.groups, dimension, from.compartments, to.compartments, na.replacement = as.numeric(NA), ... )
type |
The type of the model mechanism. Must be one of 'mortality.rate', 'fertility.rate', 'birth.proportions', 'aging.rate', 'transition.rate', 'susceptibility', 'transmissibility', 'contact', 'new.infection.proportions', 'remission.rate', 'remission.proportions' |
dimension |
The name of the dimension in which this transition operates |
from.compartments, to.compartments
|
The compartments from and to which this transition applies. May be (1) one or more names of compartments, (2) one or more character compartment.value.aliases, (3) one or more integers denoting compartments, (4) a logical vector, which, when applied to the dimension names, denotes the compartments |
group |
The group(s) to which this transition applies. Either 'uninfected', 'infected', or both |
Other Defining Core Components for a Model Specification:
register.aging(),
register.mortality(),
register.natality(),
register.remission(),
register.transition(),
register.transmission()
Register a Model Quantity
register.model.quantity( specification, name, value, scale = NULL, dimensions = names(dimension.values), dimension.values = NULL, resolve.dimension.values.against.model = T, ..., na.replacement = as.numeric(NA) )register.model.quantity( specification, name, value, scale = NULL, dimensions = names(dimension.values), dimension.values = NULL, resolve.dimension.values.against.model = T, ..., na.replacement = as.numeric(NA) )
specification |
The jheem.specification object to modify |
name |
The name of the model quantity. Cannot overlap with names of model elements |
value |
Either: (1) a numeric object, (2) a character string giving the name of a model quantity or a model element, (3) an 'call' or 'expression' object (generated by expression() or expr()) containing an expression comprising other model quantities or model elements, and the operators +, -, *, /, ^, sqrt, log, and exp, or (4) a function whose arguments are some subset of 'specification.metadata', 'location', other model quantities and model elements, and ... |
scale |
An optional parameter, indicating the scale for this model.quantity. If specified, running the model will throw an error if evaluating the quantity results in an invalid value for the scale (eg a negative rate or a proportion > 1). Can be 'rate', 'ratio', 'proportion', 'time', 'number', 'non.negative.number' |
dimensions |
An optional parameter, indicating the dimensions the quantity is expected to have (if dim.names is not specified, the specific values of the dimensions will be inferred automatically) |
dimension.values |
An optional parameter, indicating (some of) the elements that the dimnames of the quantity are supposed to contain. This must be a named list of character vectors (whose names are a subset of dimensions if dimensions are specified). |
... |
Additional parameters to be passed to value if a function is passed as the value |
na.replacement |
A single numeric value that should be used to replace NA values generated in calculating the quantity's value (note, if na.replacement==NA, no handling of NAs is performed and NAs will cause an error in model execution) |
Register a Value to a Subset of a Model Quantity or Transition
register.model.quantity.subset( specification, name, value, applies.to, na.replacement = as.numeric(NA), apply.function = c("overwrite", "add", "subtract", "divide", "multiply")[1], ... )register.model.quantity.subset( specification, name, value, applies.to, na.replacement = as.numeric(NA), apply.function = c("overwrite", "add", "subtract", "divide", "multiply")[1], ... )
specification |
The jheem.specification object to modify |
name |
The name of the model quantity or transition to which to register a subset |
value |
Either: (1) a numeric object, (2) a character string giving the name of a model quantity or a model element, (3) an 'call' or 'expression' object (generated by expression() or expr()) containing an expression comprising other model quantities or model elements, and the operators +, -, *, /, ^, sqrt, log, and exp, or (4) a function whose arguments are some subset of 'specification.metadata', 'location', other model quantities and model elements, and ... |
applies.to |
A named list representing the subset of value in question. The names of applies.to should correspond to dimensions of value, and the values must be either character, integer, or logical vectors accessing values in each dimension |
na.replacement |
A single numeric value that should be used to replace NA values generated in calculating the quantity's value (note, if na.replacement==NA, no handling of NAs is performed and NAs will cause an error in model execution) |
apply.function |
A character value indicating how the value for this subset should be incorporated into the main quantity. Options are 'overwrite' (the value for the subset overwrites the value in the quantity), 'add' (subset value is added to the quantity), 'subtract' (subset value subtracted from the quantity), 'multiply' (subset value multiplied by the quantity), or 'divide' (quantity is divided by the subset value) |
... |
Additional parameters to be passed to value if a function is passed as the value |
Register a JHEEM Model Specification
register.model.specification(specification)register.model.specification(specification)
specification |
A jheem.specification object, as created by |
Once a specification object is registered, it can no longer be modified
Other JHEEM Version Management Functions:
get.prior.versions(),
get.specification.for.version(),
version.has.been.registered()
Register Information about Mortality for a Model Specification
register.mortality( specification, mortality.rate.value, groups = c("uninfected", "infected"), tag = "mortality", applies.to = list() )register.mortality( specification, mortality.rate.value, groups = c("uninfected", "infected"), tag = "mortality", applies.to = list() )
specification |
The jheem.specification object to modify |
mortality.rate.value |
The mortality.rate. Either: (1) a numeric object, (2) a character string giving the name of a model quantity or a model element, (3) an 'call' or 'expression' object (generated by expression() or expr()) containing an expression comprising other model quantities or model elements, and the operators +, -, *, /, ^, sqrt, log, and exp, or (4) a function whose arguments are some subset of 'specification.metadata', 'location', other model quantities and model elements, and ... |
groups |
The group(s) to which the mortality apply. Either 'infected' or 'uninfected' or both |
tag |
A tag used to follow track this component |
applies.to |
A named list of character or integer vectors, denoting what subset of the groups the component apply to |
Other Defining Core Components for a Model Specification:
register.aging(),
register.model.mechanism(),
register.natality(),
register.remission(),
register.transition(),
register.transmission()
Register Information about Natality (Births) for a Model Specification
register.natality( specification, parent.groups, child.groups, fertility.rate.value, birth.proportions.value, parent.child.concordant.dimensions = character(), all.births.from.compartments = list(), all.births.into.compartments = character(), tag = "natality", applies.to = list() )register.natality( specification, parent.groups, child.groups, fertility.rate.value, birth.proportions.value, parent.child.concordant.dimensions = character(), all.births.from.compartments = list(), all.births.into.compartments = character(), tag = "natality", applies.to = list() )
specification |
The jheem.specification object to modify |
parent.groups |
The group representing parents (infected or uninfected) |
child.groups |
The group into which births are distributed (infected or uninfected) |
fertility.rate.value, birth.proportions.value
|
The values for the fertility rate and the proportions by which births are distributed into the to.group. Either: (1) a numeric object, (2) a character string giving the name of a model quantity or a model element, (3) an 'call' or 'expression' object (generated by expression() or expr()) containing an expression comprising other model quantities or model elements, and the operators +, -, *, /, ^, sqrt, log, and exp, or (4) a function whose arguments are some subset of 'specification.metadata', 'location', other model quantities and model elements, and ... |
parent.child.concordant.dimensions |
A character vector of the dimensions for which all new births share the same value as their parents |
all.births.from.compartments |
A named list of character or integer values. The names represent dimensions, and the elements represent the compartments from those dimensions that can give birth |
all.births.into.compartments |
A named list of single character or integer values. The names represent dimensions and the elements represent the single compartment in that dimension into which all births go |
tag |
A tag used to follow track this component |
applies.to |
A named list of character or integer vectors, denoting what subset of the from.group fertility applies to |
Other Defining Core Components for a Model Specification:
register.aging(),
register.model.mechanism(),
register.mortality(),
register.remission(),
register.transition(),
register.transmission()
Create and register a mapping that allows transformations of arrays
register.ontology.mapping( name, mappings, from.dimensions, to.dimensions = from.dimensions )register.ontology.mapping( name, mappings, from.dimensions, to.dimensions = from.dimensions )
name |
A descriptive single character value |
mappings |
A character matrix, with a number of columns == length(from.dimensions) + length(to.dimensions). The first length(from.dimensions) columns represent values for the from.dimensions (in the same order as from.dimensions), and the last length(to.dimensions) colums represent values for to.dimensions (in the order of to.dimensions). Each row represents a mapping from a set of values for from.dimension to a set of values for to.dimensions. NB: any dimnames on mappings will be ignored |
from.dimensions |
A character vector of names of the dimensions we are mapping from |
to.dimensions |
A character vector of names of the dimensions we are mapping to |
The mappings must contain every possible combination of 'from' values (ie, every combo of from values must map to something). A row of 'mappings' may have NA values in ALL the 'from' columns (indicating there is no set of 'from' values that maps to the corresponding 'to' values), or may have NA values in ALL the 'to' columns (indicating the that the given set of 'from' values will be discarded in the transformation)
Register a parent data source to a data manager
register.parent.data.source( data.manager = get.default.data.manager(), parent.source, full.name, short.name = full.name )register.parent.data.source( data.manager = get.default.data.manager(), parent.source, full.name, short.name = full.name )
data.manager |
A jheem.data.manager object |
parent.source |
The name (a single character value) of the parent source. This is the 'internal' name by which the parent source will be referenced in accessing the data manager |
full.name |
A descriptive, fully-formatted and capitalized name to use in generating figures and tables (eg in popovers). Avoid abbreviations. Should be unique to the parent data source (although this is not enforced) |
short.name |
A name for the parent data source to use in setting where brevity is important. Ideal to use abbreviations, but can be the same as full.name |
Register Information about Remission from Infection for a Model Specification
register.remission( specification, remission.rate.value, remission.proportions.value, tag = "remission", applies.to = list(), all.remissions.into.compartments = character() )register.remission( specification, remission.rate.value, remission.proportions.value, tag = "remission", applies.to = list(), all.remissions.into.compartments = character() )
specification |
The jheem.specification object to modify |
remission.rate.value, remission.proportions.value
|
The values for the remission rate and the proportions by which remitted cases are distributed into the uninfected group. Either: (1) a numeric object, (2) a character string giving the name of a model quantity or a model element, (3) an 'call' or 'expression' object (generated by expression() or expr()) containing an expression comprising other model quantities or model elements, and the operators +, -, *, /, ^, sqrt, log, and exp, or (4) a function whose arguments are some subset of 'specification.metadata', 'location', other model quantities and model elements, and ... |
tag |
A tag used to follow track this component |
applies.to |
A named list of character or integer vectors, denoting what subset of the infected group remissions apply to |
Other Defining Core Components for a Model Specification:
register.aging(),
register.model.mechanism(),
register.mortality(),
register.natality(),
register.transition(),
register.transmission()
Register Parameters to Be Sampled Prior to Making Projections from a JHEEM Version
register.sampled.parameters.for.version( version, distribution, apply.function, join.with.previous.version )register.sampled.parameters.for.version( version, distribution, apply.function, join.with.previous.version )
version |
The name of an EHE version for which a specification has been registered with |
distribution |
An object of class 'distribution' that specifies the prior distribution for the parameters |
apply.function |
A function that knows how to apply parameter values to a jheem.model.settings object. The function should take two arguments: (1) 'model.settings', an object of class jheem.model.settings, and (2) 'parameters', a named numeric vector |
join.with.previous.version |
Whether the distribution and apply.function should be merged with those of the previous version |
*Sampled* parameters have their values randomly chosen from a distribution prior to running projections PAST the calibration period
Register Parameters to Be Set for Running a Simulation
register.set.parameters.for.version( version, parameter.names, apply.function, join.with.previous.version )register.set.parameters.for.version( version, parameter.names, apply.function, join.with.previous.version )
version |
The name of an EHE version for which a specification has been registered with |
parameter.names |
A character vector giving the names of parameters which will be set |
apply.function |
A function that knows how to apply parameter values to a jheem.model.settings object. The function should take two arguments: (1) 'model.settings', an object of class jheem.model.settings, and (2) 'parameters', a named numeric vector |
join.with.previous.version |
Whether the parameter.names and apply.function should be merged with those of the previous version |
*Set* parameters have their values set explicitly (neither sampled nor calibrated)
Register Information about Disease Transmission for a Model Specification
register.transition( specification, dimension, from.compartments, to.compartments, value, groups, applies.to = list(), tag = "transition", na.replacement = as.numeric(NA), ... )register.transition( specification, dimension, from.compartments, to.compartments, value, groups, applies.to = list(), tag = "transition", na.replacement = as.numeric(NA), ... )
dimension |
The name of the dimension in which this transition operates |
from.compartments, to.compartments
|
The compartments from and to which this transition applies. May be (1) one or more names of compartments, (2) one or more character compartment.value.aliases, (3) one or more integers denoting compartments, (4) a logical vector, which, when applied to the dimension names, denotes the compartments |
groups |
The group(s) to which this transition applies. Either 'uninfected', 'infected', or both |
Other Defining Core Components for a Model Specification:
register.aging(),
register.model.mechanism(),
register.mortality(),
register.natality(),
register.remission(),
register.transmission()
Register Information about Disease Transmission for a Model Specification
register.transmission( specification, contact.value, susceptibility.value, transmissibility.value, new.infection.proportions.value, tag = "transmission", all.new.infections.into.compartments = list(), from.applies.to = list(), to.applies.to = list(), transmission.applies.to = list(), new.infections.applies.to = list() )register.transmission( specification, contact.value, susceptibility.value, transmissibility.value, new.infection.proportions.value, tag = "transmission", all.new.infections.into.compartments = list(), from.applies.to = list(), to.applies.to = list(), transmission.applies.to = list(), new.infections.applies.to = list() )
specification |
The jheem.specification object to modify |
contact.value, susceptibility.value, transmissibility.value, new.infection.proportions.value
|
The values for the contact matrix, susceptibility, transmissibility, and proportions by which new infections are distributed into the infected group. Either: (1) a numeric object, (2) a character string giving the name of a model quantity or a model element, (3) an 'call' or 'expression' object (generated by expression() or expr()) containing an expression comprising other model quantities or model elements, and the operators +, -, *, /, ^, sqrt, log, and exp, or (4) a function whose arguments are some subset of 'specification.metadata', 'location', other model quantities and model elements, and ... |
tag |
A tag used to follow track this component |
from.applies.to |
A named list of character or integer vectors, denoting what subset of the population PARTNERS may come from (regardless of whether or not they actually transmit). Must be a subset of compartments.for.infected.and.uninfected |
to.applies.to |
A named list of character or integer vectors, denoting what subset of the uninfected group are susceptible to infection. Must be a subset of compartments.for.infected.and.uninfected + compartments.for.uninfected.only |
transmission.applies.to |
A named list of character or integer vectors, denoting what subset of the infected group may transmit infection. Must be a subset of compartments.for.infected.and.uninfected + compartments.for.infected.only |
new.infections.applies.to |
A named list of character or integer vectors, denoting what subset of the infected group new infections may enter into. Must be a subset of compartments.for.infected.only |
Other Defining Core Components for a Model Specification:
register.aging(),
register.model.mechanism(),
register.mortality(),
register.natality(),
register.remission(),
register.transition()
Register Transmute Calibration Info
register.transmute.calibration.info( transmute.code, from.version, to.version, n.iter.first.sim, n.iter.subsequent.sims, likelihood.instructions, prior.distribution, sampling.blocks, fixed.initial.parameter.values = numeric(), from.sub.version = NULL, to.sub.version = NULL, max.lookback.attempts = 20 )register.transmute.calibration.info( transmute.code, from.version, to.version, n.iter.first.sim, n.iter.subsequent.sims, likelihood.instructions, prior.distribution, sampling.blocks, fixed.initial.parameter.values = numeric(), from.sub.version = NULL, to.sub.version = NULL, max.lookback.attempts = 20 )
Replaces data with NA if data exists
remove.data( data.manager, outcome, source, ontology.name, dimension.values, metric = "estimate", details.for.removal = "removed", url.for.removal = "url" )remove.data( data.manager, outcome, source, ontology.name, dimension.values, metric = "estimate", details.for.removal = "removed", url.for.removal = "url" )
data.manager |
A jheem.data.manager object |
outcome |
The outcome type for the data. Must be an outcome previously registered with |
source |
The (single) character name of the source from which these data derive. Must be a source previously registered with |
ontology.name |
The name of the ontology which the data follow. Must be an ontology previously registered with |
dimension.values |
A named list that indicates what subset of a bigger data element these particular data should be stored into. Each element must be a named character, numeric, or logical vector. |
metric |
The type of measurement. The default value is "estimate", but other options include "cv", "variance", and "sd". |
details.for.removal, url.for.removal
|
Single character values to use for these points' 'details' and 'url' |
Rerun a Simulation Set
rerun.simulations( simset, max.run.time.seconds = Inf, sub.version = simset$sub.version, from.year = simset$from.year, to.year = simset$to.year, verbose = T )rerun.simulations( simset, max.run.time.seconds = Inf, sub.version = simset$sub.version, from.year = simset$from.year, to.year = simset$to.year, verbose = T )
simset |
The JHEEM simulation set to re-run |
max.run.time.seconds |
The maximum amount of time to run simulations before terminating |
sub.version |
The sub-version to run |
from.year, to.year
|
The years to keep in the simulation object |
verbose |
Whether to print updates as simulations are run |
Helpful if the specification has changed
#@export
resolve.intervention.effect(intervention.effect, bindings, error.prefix = "")resolve.intervention.effect(intervention.effect, bindings, error.prefix = "")
Resolve dimension.values into a set of dimnames for an ontology
resolve.ontology.dimension.values( ont, dimension.values, error.prefix, throw.error.if.unresolvable = T )resolve.ontology.dimension.values( ont, dimension.values, error.prefix, throw.error.if.unresolvable = T )
ont |
An ontology, as created by |
dimension.values |
A list of dimension.values (ie, a named list of either character, integer, or logical vectors that indexes into the dimnames given in ont) |
error.prefix |
Text to prepend to any error messages that are thrown |
throw.error.if.unresolvable |
A logical indicating what to do if unable to resolve against the ontology. When FALSE, will return NULL if unresolvable |
If the dimension.values can be resolved against ontology ont, returns a list of dimnames (ie, a named list of character vectors). If cannot resolve will either throw an error (if throw.error.if.unresolvable) or return NULL (NB, if passed dimension.values==NULL, will also return NULL)
Re-distribute counts according to one set of age brackets into a different set of age brackets
restratify.age.counts( counts, desired.age.brackets, given.age.brackets = NULL, smooth.infinite.age.to = Inf, allow.extrapolation = F, na.rm = F, method = c("pclm", "monoH.FC", "hyman")[2], error.prefix = "" )restratify.age.counts( counts, desired.age.brackets, given.age.brackets = NULL, smooth.infinite.age.to = Inf, allow.extrapolation = F, na.rm = F, method = c("pclm", "monoH.FC", "hyman")[2], error.prefix = "" )
counts |
Either (a) a dimensionless numeric vector, or (b) a numeric array, with one dimension named "age". The "given" age brackets according to which these counts are distributed must be continuous - with no gaps between them |
desired.age.brackets, given.age.brackets
|
The age brackets according to which the ages in counts are given or desired to be restratified to. Either (1) a character vector giving names of brackets, with one name for each age bracket value or (b) a numeric vector of age endpoints, with one more element than the number of age bracket values. given.age.brackets should be present only if names(counts) is absent (if counts is a vector) or if dimnames(counts)$age is null (if counts is an array) |
smooth.infinite.age.to |
In building a spline over counts, what value should an infinite bound in an age range be replaced with |
allow.extrapolation |
A logical value indicating whether extrapolation should be allowed in restratifying. Extrapolating is required when one of the desired age brackets includes ages not present in any of the given age brackets |
na.rm |
Whether NAs should be ignored in counts |
method |
The method to be passed to the smoother. Options are 'pclm' (default, uses Penalized Composite Link Model), 'monoH.FC' (Fritsch-Carlson monotonic splines), or 'hyman' (Hyman's monotonic splines) |
error.prefix |
A character value to be prepended to any error messages |
Loads a simulation set that has been properly saved in JHEEM's calibration file structure.
retrieve.simulation.set( version, location, calibration.code, n.sim, intervention.code = NULL, sub.version = NULL, root.dir = get.jheem.root.directory("Cannot get.simset.filename(): "), error.prefix = "", throw.error.if.missing = T )retrieve.simulation.set( version, location, calibration.code, n.sim, intervention.code = NULL, sub.version = NULL, root.dir = get.jheem.root.directory("Cannot get.simset.filename(): "), error.prefix = "", throw.error.if.missing = T )
Run A Calibration
run.calibration( version, location, calibration.code, root.dir = get.jheem.root.directory("Cannot set up calibration: "), chains, update.frequency = 500, update.detail = "low" )run.calibration( version, location, calibration.code, root.dir = get.jheem.root.directory("Cannot set up calibration: "), chains, update.frequency = 500, update.detail = "low" )
version |
The version of the model specification (must have been previously registered) |
location |
A single character value representing the location for the calibration |
update.detail |
An MCMC object
Run a Simulations from a Set of Parameters
run.simulations.from.parameters( version, location, parameters, end.year, sub.version = NULL, max.run.time.seconds = Inf, calibration.code = NULL, solver.metadata = create.solver.metadata(), keep.from.year = start.year, keep.to.year = end.year, verbose = F )run.simulations.from.parameters( version, location, parameters, end.year, sub.version = NULL, max.run.time.seconds = Inf, calibration.code = NULL, solver.metadata = create.solver.metadata(), keep.from.year = start.year, keep.to.year = end.year, verbose = F )
version, location, sub.version
|
The JHEEM version, sub.version, and location for which to run simulations |
parameters |
The parameters to run simulations for. Can be either (a) a matrix with parameters on the rows, and one column for each set of parameters/simulation to run, with named rows or (b) a named numeric vector of parameters for a single simulation |
end.year |
The year to run simulations to |
max.run.time.seconds |
The maximum amount of time to run simulations before terminating |
calibration.code |
If parameters were derived from a previous calibration, the calibration code that should be attached to the resulting simulation set |
solver.metadata |
A solver.metadata object, as created by |
Run Transmute Calibration
run.transmute.calibration( transmute.code, location, n.sim, chunks = NULL, verbose = T, update.frequency = 500, update.detail = "low", ignore.errors = T, rerun = T, root.dir = get.jheem.root.directory() )run.transmute.calibration( transmute.code, location, n.sim, chunks = NULL, verbose = T, update.frequency = 500, update.detail = "low", ignore.errors = T, rerun = T, root.dir = get.jheem.root.directory() )
Save a JHEEM Simulation Set
save.simulation.set( simset, root.dir = get.jheem.root.directory("Cannot save simulation set: ") )save.simulation.set( simset, root.dir = get.jheem.root.directory("Cannot save simulation set: ") )
simset |
A jheem.simulation.set object |
root.dir |
The directory in which the folder tree for saving the simset will be rooted |
Registers each data manager in the binding under its name, replacing the
registry's contents (see register.data.manager), and makes the registry the
active binding for the session. Data managers registered later join it.
set.data.binding(binding)set.data.binding(binding)
binding |
A 'jheem.data.binding' object, or NULL to stop using a session binding (the registry is kept) |
The binding, invisibly
jheem2 does not fetch releases. rebuild.data.binding calls this
function to load the data manager each recorded name was bound to.
set.data.release.resolver(resolver)set.data.release.resolver(resolver)
resolver |
A function taking one argument, a list with data.manager.name, file, release,
repository, sha256 and md5 (NA where not recorded), and returning the data manager loaded with
its provenance (see |
NULL, invisibly
Set the default data manager
set.default.data.manager(data.manager)set.default.data.manager(data.manager)
Set the Default Style Manager
set.default.style.manager(style.manager, type = c("ggplot", "plotly")[1])set.default.style.manager(style.manager, type = c("ggplot", "plotly")[1])
Set multiple functional form main effect alphas from parameters
set.element.functional.form.alphas.from.parameters( model.settings, element.name, alpha.name, parameters, parameter.name.prefix, parameter.name.suffix, dimensions.with.values.referred.to.by.name = character(), dimensions.with.values.referred.to.by.index = character(), throw.error.if.no.parameters = T, wrt.version = model.settings$version )set.element.functional.form.alphas.from.parameters( model.settings, element.name, alpha.name, parameters, parameter.name.prefix, parameter.name.suffix, dimensions.with.values.referred.to.by.name = character(), dimensions.with.values.referred.to.by.index = character(), throw.error.if.no.parameters = T, wrt.version = model.settings$version )
model.settings |
An object of class 'jheem.model.settings' |
element.name |
The name of the model element whose functional form we wish to modify |
alpha.name |
The name of the functional form parameter that we want to set alphas for |
parameters |
A named numeric vector with values for interaction terms |
parameter.name.prefix, parameter.name.suffix
|
Character values to be prepended and addended to names of specific dimension values to generate specific parameter names |
dimensions.with.values.referred.to.by.name |
Dimensions for which we should look for main effects in parameters, and make parameter names by combining parameter.name.prefix and parameter.name.suffix with the actual dimension values for the dimension |
dimensions.with.values.referred.to.by.index |
Dimensions for which we should look for main effects in parameters, and make parameter names by combining parameter.name.prefix and parameter.name.suffix with indices of the values in each dimension |
throw.error.if.no.parameters |
A logical indicator - if no parameter names match the pattern parameter.name.prefix<x>parameter.name.suffix, whether an error should be thrown |
wrt.version |
The version relative to which the element name is resolved (if an element.name is overwritten in a descendant version, using wrt.version can be used to select which specification's model element is to be modified) |
This function will search for parameters with names in the format of either parameter.name.prefix<dimension values for dimensions.with.values.referred.to.by.name>parameter.name.suffix OR parameter.name.prefix<dimension in dimension.values.referred.to.by.name><1:length of dimension>parameter.name.suffix
The names of parameters that were used
Set the Times From and To Which the Functional Form Determines a Model Element's Value
set.element.functional.form.from.time( model.settings, element.name, from.time, wrt.version = model.settings$version ) set.element.functional.form.to.time( model.settings, element.name, to.time, wrt.version = model.settings$version )set.element.functional.form.from.time( model.settings, element.name, from.time, wrt.version = model.settings$version ) set.element.functional.form.to.time( model.settings, element.name, to.time, wrt.version = model.settings$version )
model.settings |
An object of class 'jheem.model.settings' |
element.name |
The name of the model element to set functional.form times for |
from.time, to.time
|
The time from or to which the functional form is active |
wrt.version |
The version relative to which the element name is resolved (if an element.name is overwritten in a descendant version, using wrt.version can be used to select which specification's model element is to be modified) |
set.element.functional.form.to.time():
Other Functions to create and modify a model settings:
set.element.functional.form.future.slope(),
set.element.functional.form.interaction.alphas(),
set.element.ramp.times()
Set a "Future Slope" and the time after which it applies, for a model element
set.element.functional.form.future.slope( model.settings, element.names, slope, wrt.version = model.settings$version ) set.element.functional.form.future.slope.after.time( model.settings, element.names, after.time, wrt.version = model.settings$version )set.element.functional.form.future.slope( model.settings, element.names, slope, wrt.version = model.settings$version ) set.element.functional.form.future.slope.after.time( model.settings, element.names, after.time, wrt.version = model.settings$version )
model.settings |
An object of class 'jheem.model.settings' |
element.names |
One or more names of the model element to set the future.slope for |
slope |
A single numeric value representing the slope |
wrt.version |
The version relative to which the element name is resolved (if an element.name is overwritten in a descendant version, using wrt.version can be used to select which specification's model element is to be modified) |
after.time |
The year after which the additional slope takes effect |
A future slope is applied to model elements with a functional.form set AFTER a given point in time
set.element.functional.form.future.slope.after.time():
Other Functions to create and modify a model settings:
set.element.functional.form.from.time(),
set.element.functional.form.interaction.alphas(),
set.element.ramp.times()
Set Interaction Alpha Values for a Functional Form for a Model Element
set.element.functional.form.interaction.alphas( model.settings, element.name, alpha.name, value, applies.to.dimension.values, wrt.version = model.settings$version )set.element.functional.form.interaction.alphas( model.settings, element.name, alpha.name, value, applies.to.dimension.values, wrt.version = model.settings$version )
model.settings |
An object of class 'jheem.model.settings' |
element.name |
The name of the model element whose functional form we wish to modify |
alpha.name |
The name of the functional form parameter that we want to set alphas for |
value |
A single numeric value, which will apply to every combination of applies.to.dimension.values which are from different dimensions |
applies.to.dimension.values |
Either a character vector where each element is either a character vector. Must be named with the dimension to which each dimension value applies |
wrt.version |
The version relative to which the element name is resolved (if an element.name is overwritten in a descendant version, using wrt.version can be used to select which specification's model element is to be modified) |
Alphas for an 'interaction' will apply to every combination of applies.to.dimension.values from different dimensions (as opposed to 'main effect' apply to all values in a dimension
Other Functions to create and modify a model settings:
set.element.functional.form.from.time(),
set.element.functional.form.future.slope(),
set.element.ramp.times()
Set Main Effect Alpha Values for a Functional Form for a Model Element
set.element.functional.form.main.effect.alphas( model.settings, element.name, alpha.name, values, dimension, applies.to.dimension.values = names(values), wrt.version = model.settings$version )set.element.functional.form.main.effect.alphas( model.settings, element.name, alpha.name, values, dimension, applies.to.dimension.values = names(values), wrt.version = model.settings$version )
model.settings |
An object of class 'jheem.model.settings' |
element.name |
The name of the model element whose functional form we wish to modify |
alpha.name |
The name of the functional form parameter that we want to set alphas for |
values |
A numeric vector of values (either a single value applied to all dimension values OR a vector of the same length as applies.to.dimension.values) |
dimension |
The dimension to which values in applies.to.dimension.values apply |
applies.to.dimension.values |
A character vector of values within the given dimension to which the alphas should apply |
wrt.version |
The version relative to which the element name is resolved (if an element.name is overwritten in a descendant version, using wrt.version can be used to select which specification's model element is to be modified) |
Alphas for a 'main effect' apply to all values in a dimension (as opposed to 'interaction effects', which apply to combinations of values)
Set a ramp or taper (times and values) for a model element
set.element.ramp.times( model.settings, element.name, times, indices = 1:length(times), wrt.version = model.settings$version ) set.element.ramp.values( model.settings, element.name, values, indices = 1:length(values), wrt.version = model.settings$version ) set.element.taper.times( model.settings, element.name, times, indices = 1:length(times), wrt.version = model.settings$version ) set.element.taper.values( model.settings, element.name, values, indices = 1:length(values), wrt.version = model.settings$version )set.element.ramp.times( model.settings, element.name, times, indices = 1:length(times), wrt.version = model.settings$version ) set.element.ramp.values( model.settings, element.name, values, indices = 1:length(values), wrt.version = model.settings$version ) set.element.taper.times( model.settings, element.name, times, indices = 1:length(times), wrt.version = model.settings$version ) set.element.taper.values( model.settings, element.name, values, indices = 1:length(values), wrt.version = model.settings$version )
model.settings |
An object of class 'jheem.model.settings' |
element.name |
The name of the model element to set the ramp/taper for |
times, values
|
The times or values to set for the ramp/taper |
indices |
The indices of the ramp/taper to set times or values for. Can be either numeric indices, character indices (if the ramp/taper was named when setting up the specification), or logical indices |
wrt.version |
The version relative to which the element name is resolved (if an element.name is overwritten in a descendant version, using wrt.version can be used to select which specification's model element is to be modified) |
A ramp is a set of multipliers which are multiplied by the first functional.form value (ie, the value produced at functional.form.from.time) for an element. A taper is a set of multipliers which are multiplied by the last functional.form value (ie, the value produced at functional.form.to.time) for an element
set.element.ramp.values():
set.element.taper.times():
set.element.taper.values():
Other Functions to create and modify a model settings:
set.element.functional.form.from.time(),
set.element.functional.form.future.slope(),
set.element.functional.form.interaction.alphas()
Set the Value of a Model Element
set.element.value( model.settings, element.name, value, wrt.version = model.settings$version )set.element.value( model.settings, element.name, value, wrt.version = model.settings$version )
model.settings |
An object of class 'jheem.model.settings' |
element.name |
The name of the model element to update a value for |
value |
The new value for the model element |
wrt.version |
The version relative to which the element name is resolved (if an element.name is overwritten in a descendant version, using wrt.version can be used to select which specification's model element is to be modified) |
Set the directory that calibration directories and files will be written into.
set.jheem.root.directory(dir)set.jheem.root.directory(dir)
Set Up Calibration
set.up.calibration( version, location, calibration.code, root.dir = get.jheem.root.directory("Cannot set up calibration: "), sub.version = NULL, cache.frequency = 500, allow.overwrite.cache = F, verbose = T )set.up.calibration( version, location, calibration.code, root.dir = get.jheem.root.directory("Cannot set up calibration: "), sub.version = NULL, cache.frequency = 500, allow.overwrite.cache = F, verbose = T )
version |
The version of the model specification (must have been previously registered) |
location |
A single character value representing the location for the calibration |
verbose |
The calibration's control saves the functions a chain calls. By default they keep
everything this function built, including the calibration's data manager. With
options(jheem2.lean.calibration.controls = TRUE) they keep only what a chain uses (the
engine and the instantiated likelihood, which holds the data it pulled), and the data manager is
kept only if it was not loaded from a release. Chains are the same either way.
Set Up Transmute Calibration
set.up.transmute.calibration( transmute.code, from.calibration.code, location, n.sim, n.chunks, allow.overwrite.cache = F, root.dir = get.jheem.root.directory(), return.simulations = F, verbose = T )set.up.transmute.calibration( transmute.code, from.calibration.code, location, n.sim, n.chunks, allow.overwrite.cache = F, root.dir = get.jheem.root.directory(), return.simulations = F, verbose = T )
Plot Simulations And Data
simplot( ..., outcomes = NULL, corresponding.data.outcomes = NULL, split.by = NULL, facet.by = NULL, dimension.values = list(), dimension.values.post.mapping = list(), target.ontology = NULL, plot.which = c("sim.and.data", "sim.only")[1], summary.type = c("individual.simulation", "mean.and.interval", "median.and.interval")[1], omit.data.years = NULL, data.na.rm = NULL, data.locations = NULL, label.function = NULL, plot.year.lag.ratio = F, title = "location", title.suffix = NULL, n.facet.rows = NULL, append.url = F, data.manager = get.default.data.manager(), style.manager = get.default.style.manager(), show.data.pull.error = F, simset.names = NULL, debug = F )simplot( ..., outcomes = NULL, corresponding.data.outcomes = NULL, split.by = NULL, facet.by = NULL, dimension.values = list(), dimension.values.post.mapping = list(), target.ontology = NULL, plot.which = c("sim.and.data", "sim.only")[1], summary.type = c("individual.simulation", "mean.and.interval", "median.and.interval")[1], omit.data.years = NULL, data.na.rm = NULL, data.locations = NULL, label.function = NULL, plot.year.lag.ratio = F, title = "location", title.suffix = NULL, n.facet.rows = NULL, append.url = F, data.manager = get.default.data.manager(), style.manager = get.default.style.manager(), show.data.pull.error = F, simset.names = NULL, debug = F )
... |
One or more jheem.simulation.set objects and at most one character vector of outcomes (as an alternative to the 'outcomes' argument) |
outcomes |
A character vector of which simulation outcomes to plot |
corresponding.data.outcomes |
Specify directly which data outcomes should be plotted against simulation outcomes. Must be NULL or a character vector with outcomes as names; all of those outcomes must be present in either the 'outcomes' argument or in '...'" |
split.by |
At most one dimension |
facet.by |
Any number of dimensions but cannot include the split.by dimension |
dimension.values.post.mapping |
How to subset data in the form it will take after mappings have been applied to align sim and data ontologies. A list. |
plot.which |
Should simulation data and calibration data be plotted ('sim.and.data'), or only simulation data ('sim.only') |
omit.data.years |
Years to omit data, for example if data is available but wasn't calibrated to, while still showing simulation values for those years |
data.na.rm |
Sets na.rm = T or F during the data pull step. If NULL, will use T for rates, proportions, and ratios, and F for all other scales. |
data.locations |
Specifies locations for which to pull data. May be 1. NULL, in which case data locations will be inferred from the simsets' likelihoods, 2. a character vector of locations, or 3. a list of character vectors with outcomes as list names. For 3., outcomes not included will have their data locations inferred as in 1. |
label.function |
A function to reformat labels. If NULL, will use the first provided simset's "get.labels" property, or will do no transformation if plotting data only. |
title |
NULL or a single, non-NA character value. If "location", the location of the first provided simset (if any) will be used for the title. |
title.suffix |
NULL or a single, non-NA character value. Something to append to the end of the title that would be generated automatically based on the 'title' argument. Note that this pastes with no space, so add the space in if you want it. |
data.manager |
The data.manager from which to draw real-world data for the plots |
style.manager |
We are going to have to define this down the road. It's going to govern how we do lines and sizes and colors. For now, just hard code those in, and we'll circle back to it |
show.data.pull.error |
Not finding data does not block the plot from showing simulation projections, but if you'd like to see in error when data doesn't appear, set this to TRUE. |
simset.names |
A functional argument to help make sure the sims have names when they were plopped in by some other function that used them as variables. |
Returns a ggplot object: - With one panel for each combination of outcome x facet.by - x-axis is year - y-axis is outcome
Simplot Data Only
simplot.data.only( outcomes, locations, split.by = NULL, facet.by = NULL, dimension.values = list(), dimension.values.post.mapping = list(), target.ontology = NULL, data.na.rm = NULL, label.function = NULL, plot.year.lag.ratio = F, title = "location", title.suffix = NULL, n.facet.rows = NULL, append.url = F, data.manager = get.default.data.manager(), style.manager = get.default.style.manager(), show.data.pull.error = F, debug = F )simplot.data.only( outcomes, locations, split.by = NULL, facet.by = NULL, dimension.values = list(), dimension.values.post.mapping = list(), target.ontology = NULL, data.na.rm = NULL, label.function = NULL, plot.year.lag.ratio = F, title = "location", title.suffix = NULL, n.facet.rows = NULL, append.url = F, data.manager = get.default.data.manager(), style.manager = get.default.style.manager(), show.data.pull.error = F, debug = F )
outcomes |
A character vector of which simulation outcomes to plot |
locations |
A character vector of locations for which to pull data. |
split.by |
At most one dimension |
facet.by |
Any number of dimensions but cannot include the split.by dimension |
dimension.values.post.mapping |
How to subset data in the form it will take after mappings have been applied to align sim and data ontologies. A list. |
data.na.rm |
Sets na.rm = T or F during the data pull step. If NULL, will use T for rates, proportions, and ratios, and F for all other scales. |
label.function |
A function to reformat labels. If NULL, will use the first provided simset's "get.labels" property, or will do no transformation if plotting data only. |
title |
NULL or a single, non-NA character value. If "location", the location of the first provided simset (if any) will be used for the title. |
title.suffix |
NULL or a single, non-NA character value. Something to append to the end of the title that would be generated automatically based on the 'title' argument. Note that this pastes with no space, so add the space in if you want it. |
data.manager |
The data.manager from which to draw real-world data for the plots |
style.manager |
We are going to have to define this down the road. It's going to govern how we do lines and sizes and colors. For now, just hard code those in, and we'll circle back to it |
show.data.pull.error |
Not finding data does not block the plot from showing simulation projections, but if you'd like to see in error when data doesn't appear, set this to TRUE. |
Convert Age Strata Names to a Standard Form
standardize.age.strata.names(strata.names)standardize.age.strata.names(strata.names)
strata.names |
A character vector of names of age strata |
Calls parse.age.strata.names and feeds the output into make.age.strata.names
Create an Static (Time-Invariant) Functional Form
Create an Static (Time-Invariant) Functional Form
jheem2::functional.form -> static.functional.form
new()
STATIC.FUNCTIONAL.FORM$new(
value,
link = c("identity", "log", "logistic")[1],
min = NA,
max = NA,
value.name = "value",
value.is.on.transformed.scale = F,
overwrite.parameters.with.alphas = F,
error.prefix = "Cannot create static functional.form: "
)valuearray representing the value
linkThe name of the transformation to the scale on which alphas are added to the value. One of "identity", "log", "logistic"
min, maxThe minimum and maximum values this functional form can create. The default (NA) sets to the min/max for the link specified (eg, 0-Inf for a log link, 0-1 for a logistic link)
value.is.on.transformed.scaleLogical indicating whether the the value is already on the transformed scale at which alphas apply
overwrite.parameters.with.alphasLogical indicating whether, when alphas are applied, they OVERWRITE values. If F, alphas are added to the transformed value (on the transformed scale)
clone()
The objects of this class are cloneable with this method.
STATIC.FUNCTIONAL.FORM$clone(deep = FALSE)
deepWhether to make a deep clone.
Subset a JHEEM Data Manager
subset_data( data.manager = get.default.data.manager(), outcomes.to.keep = NULL, sources.to.keep = NULL, ontologies.to.keep = NULL, incomplete.dimension.values.to.keep = NULL, retain.ontology.registrations = T )subset_data( data.manager = get.default.data.manager(), outcomes.to.keep = NULL, sources.to.keep = NULL, ontologies.to.keep = NULL, incomplete.dimension.values.to.keep = NULL, retain.ontology.registrations = T )
outcomes.to.keep, sources.to.keep, ontologies.to.keep
|
Character vectors of which outcomes, sources, and/or ontologies to retain data for. |
incomplete.dimension.values.to.keep |
A list of which years, locations, etc. to retain data for. Must be character vectors with the dimensions as names. |
retain.ontology.registrations |
Should registered ontologies be un-registered if no data remains that uses them? |
A |
jheem.data.manager object |
Subset a Simulation Set
## S3 method for class 'simset' subset(simset, simulation.indices)## S3 method for class 'simset' subset(simset, simulation.indices)
simulation.indices |
An integer or logical vector specifying which simulations to keep. |
Subset a simulation set either by keeping every Nth simulation or keeping a fraction of all simulations. One of 'n' or 'keep' can be specified, with the other left as NULL.
thin.simset(simset, n = NULL, keep = NULL, allow.expand = F)thin.simset(simset, n = NULL, keep = NULL, allow.expand = F)
n |
Every Nth simulation will be kept, counting backwards from the last sim (ie., if n=3, the last simulation and the fourth-to-last simulation will be kept, etc.). |
allow.expand |
Whether to duplicate simulations if keep > simset$n.sim |
k |
Either a number of simulations to keep or a fraction to keep (between 0 and 1). Simulations will be drawn uniformly from the set. |
Decimal values above 1 are rounded down to the nearest whole number.
Track a Combination of Cumulative Outcomes
track.cumulative.outcome( specification, name, outcome.metadata, value, value.is.numerator = F, denominator.outcome = NULL, corresponding.data.outcome = NULL, keep.dimensions = NULL, exclude.dimensions = NULL, subset.dimension.values = NULL, rename.dimension.values = NULL, force.dim.names.to.keep.dimensions = F, allow.expand.dimensions = NULL, allow.expand.denominator.dimensions = NULL, dimension.aliases = NULL, dimension.alias.suffix = NULL, scale = NULL, from.year = -Inf, to.year = Inf, save = T )track.cumulative.outcome( specification, name, outcome.metadata, value, value.is.numerator = F, denominator.outcome = NULL, corresponding.data.outcome = NULL, keep.dimensions = NULL, exclude.dimensions = NULL, subset.dimension.values = NULL, rename.dimension.values = NULL, force.dim.names.to.keep.dimensions = F, allow.expand.dimensions = NULL, allow.expand.denominator.dimensions = NULL, dimension.aliases = NULL, dimension.alias.suffix = NULL, scale = NULL, from.year = -Inf, to.year = Inf, save = T )
specification |
The jheem.specification object to modify |
name |
The name by which to access the outcome value after the simulation runs. Cannot be 'infected', 'uninfected' or the name of another outcome |
outcome.metadata |
An object created by |
value |
Either (1) a single character value referencing a separately-registered cumulative outcome or a static (value does not change over time) quantity, or (2) an expression that includes only the names of cumulative outcomes and static model quantities and operators +, -, *, /, ^, sqrt, log, and exp |
value.is.numerator |
In the case where the outcome's scale is proportion, rate, or ratio (any scale that results from a numerator or a denominator), an indicator of whether the value represents just the numerator or the actual proportion/rate/ratio |
denominator.outcome |
A denominator for aggregating the outcome or calculating proportions. Required if the scale of this outcome is not 'number' or 'non.negative.number', otherwise optional. Must be the name of a separately registered cumulative outcome that has type 'non.negative.number' |
corresponding.data.outcome |
The (optional) name of a real-world outcome (with observations registered to a data.manager) to which this model outcome corresponds |
keep.dimensions |
The dimensions which to keep in storing outcome values. All other dimensions are marginalized. Either keep.dimensions OR exclude.dimensions but not both can be set; if both are NULL, will keep all possible dimensions for the outcome. |
exclude.dimensions |
Dimensions to be marginalized out when storing outcome values. Either keep.dimensions OR exclude.dimensions but not both can be set; if both are NULL, will keep all possible dimensions for the outcome. |
subset.dimension.values |
A list of dimension values indicating for which values of which dimensions the outcome should be tracked |
rename.dimension.values |
A list of names character vectors indicating which dimension values should be renamed in the outcome ontology |
force.dim.names.to.keep.dimensions |
A logical indicating whether the dim.names of the outcome should be forced to match keep.dimensions (based on dimension values in compartments.for.infected.only, compartments.for.uninfected.only, and compartments.for.infected.and.uninfected) regardless of the dimensions of the underlying model quantities that it comprises. |
allow.expand.dimensions, allow.expand.denominator.dimensions
|
A character vector of dimensions which can be added to the outcome (or outcome's denominator) even if not present in its component outcomes or quantities. The outcome will have the same value for all values in that dimension |
dimension.aliases |
A named character vector indicating what dimensions in the inputs to the outcome (the names of the vector) should be converted to (the values of the vector) |
dimension.alias.suffix |
A single character value, indicating a suffix that should be removed from the dimensions of the inputs to the outcome. Eg, if ".to" is specified, then dimension "race.to" in outcome inputs becomes "race" in the outcome |
scale |
The scale of this outcome. Can be NULL when outcome.metadata is not NULL (only required when not saving and not using outcome.metadata) |
from.year, to.year
|
The time span during which the outcome should be recorded |
save |
A logical indicator of whether this outcome should be stored in simulations. If FALSE, the outcome will be available for calculating other outcomes (with |
Creates a cumulative outcome to track by combining other cumulative outcomes and static quantities
Track an Outcome Formed by Integrating a Time-Varying Rate into a Proportion
track.cumulative.proportion.from.rate( specification, name, outcome.metadata, rate.value, denominator.outcome, corresponding.data.outcome = NULL, calculate.proportion.leaving = T, keep.dimensions = NULL, exclude.dimensions = NULL, subset.dimension.values = NULL, rename.dimension.values = NULL, force.dim.names.to.keep.dimensions = F, allow.expand.dimensions = NULL, allow.expand.denominator.dimensions = NULL, dimension.aliases = NULL, dimension.alias.suffix = NULL, from.year = -Inf, to.year = Inf, save = T )track.cumulative.proportion.from.rate( specification, name, outcome.metadata, rate.value, denominator.outcome, corresponding.data.outcome = NULL, calculate.proportion.leaving = T, keep.dimensions = NULL, exclude.dimensions = NULL, subset.dimension.values = NULL, rename.dimension.values = NULL, force.dim.names.to.keep.dimensions = F, allow.expand.dimensions = NULL, allow.expand.denominator.dimensions = NULL, dimension.aliases = NULL, dimension.alias.suffix = NULL, from.year = -Inf, to.year = Inf, save = T )
specification |
The jheem.specification object to modify |
name |
The name by which to access the outcome value after the simulation runs. Cannot be 'infected', 'uninfected' or the name of another outcome |
outcome.metadata |
An object created by |
rate.value |
The rate to be integrated. Either (1) a single character value referencing a separately-registered "point" (non-cumulative) outcome or a quantity, or (2) an expression that includes only the names of point outcomes and model quantities and operators +, -, *, /, ^, sqrt, log, and exp |
denominator.outcome |
A denominator for aggregating the outcome or calculating proportions. Required if the scale of this outcome is not 'number' or 'non.negative.number', otherwise optional. Must be the name of a separately registered cumulative outcome that has type 'non.negative.number' |
corresponding.data.outcome |
The (optional) name of a real-world outcome (with observations registered to a data.manager) to which this model outcome corresponds |
calculate.proportion.leaving |
If TRUE, integrates to get the proportion of those who "leave" the imaginary compartment at the given rate. If FALSE, calculates the proportion who have not left (ie 1-proportion.leaving) |
keep.dimensions |
The dimensions which to keep in storing outcome values. All other dimensions are marginalized. Either keep.dimensions OR exclude.dimensions but not both can be set; if both are NULL, will keep all possible dimensions for the outcome. |
exclude.dimensions |
Dimensions to be marginalized out when storing outcome values. Either keep.dimensions OR exclude.dimensions but not both can be set; if both are NULL, will keep all possible dimensions for the outcome. |
subset.dimension.values |
A list of dimension values indicating for which values of which dimensions the outcome should be tracked |
rename.dimension.values |
A list of names character vectors indicating which dimension values should be renamed in the outcome ontology |
force.dim.names.to.keep.dimensions |
A logical indicating whether the dim.names of the outcome should be forced to match keep.dimensions (based on dimension values in compartments.for.infected.only, compartments.for.uninfected.only, and compartments.for.infected.and.uninfected) regardless of the dimensions of the underlying model quantities that it comprises. |
allow.expand.dimensions, allow.expand.denominator.dimensions
|
A character vector of dimensions which can be added to the outcome (or outcome's denominator) even if not present in its component outcomes or quantities. The outcome will have the same value for all values in that dimension |
dimension.aliases |
A named character vector indicating what dimensions in the inputs to the outcome (the names of the vector) should be converted to (the values of the vector) |
dimension.alias.suffix |
A single character value, indicating a suffix that should be removed from the dimensions of the inputs to the outcome. Eg, if ".to" is specified, then dimension "race.to" in outcome inputs becomes "race" in the outcome |
from.year, to.year
|
The time span during which the outcome should be recorded |
save |
A logical indicator of whether this outcome should be stored in simulations. If FALSE, the outcome will be available for calculating other outcomes (with |
Calculates a proportion derived from having a 'compartment' which people leave at a given rate, and calculates the proportion who either leave or remain in that compartment over time
Mark a Transition for Tracking
track.dynamic.outcome( specification, name, outcome.metadata, dynamic.quantity.name, denominator.outcome = NULL, include.tags = NULL, exclude.tags = NULL, groups = NULL, multiply.by = NULL, corresponding.data.outcome = NULL, keep.dimensions = NULL, exclude.dimensions = NULL, subset.dimension.values = NULL, rename.dimension.values = NULL, allow.expand.dimensions = NULL, allow.expand.denominator.dimensions = NULL, dimension.aliases = NULL, dimension.alias.suffix = NULL, scale = NULL, from.year = -Inf, to.year = Inf, save = T )track.dynamic.outcome( specification, name, outcome.metadata, dynamic.quantity.name, denominator.outcome = NULL, include.tags = NULL, exclude.tags = NULL, groups = NULL, multiply.by = NULL, corresponding.data.outcome = NULL, keep.dimensions = NULL, exclude.dimensions = NULL, subset.dimension.values = NULL, rename.dimension.values = NULL, allow.expand.dimensions = NULL, allow.expand.denominator.dimensions = NULL, dimension.aliases = NULL, dimension.alias.suffix = NULL, scale = NULL, from.year = -Inf, to.year = Inf, save = T )
specification |
The jheem.specification object to modify |
name |
The name by which to access the outcome value after the simulation runs. Cannot be 'infected', 'uninfected' or the name of another outcome |
outcome.metadata |
An object created by |
dynamic.quantity.name |
The name of the dynamic quantity to track for the outcome. Must be one of 'population', 'mortality', 'births', 'births.from', 'births.to', 'incidence', 'incidence.to', 'incidence.from', 'incidence.by', 'remission', 'remission.from', 'remission.to' |
denominator.outcome |
Optional: A denominator for calculating proportions. Must be the name of a separately registered cumulative outcome that has type 'non.negative.number' |
include.tags |
The tags to track for (as given in the call to |
exclude.tags |
Tags to exclude from tracking. |
groups |
The groups to track for ('infected' or 'uninfected'). Choosing NULL (the default value) tracks for all groups for which the outcome could apply |
multiply.by |
An optional quantity to multiply the outcome value by at each time step before storing. Can be either (1) a numeric value, (2) a single character value referencing a model quantity or element, or (3) an expression that includes only the names of model quantities and elements and operators +, -, *, /, ^, sqrt, log, and exp |
corresponding.data.outcome |
The (optional) name of a real-world outcome (with observations registered to a data.manager) to which this model outcome corresponds |
keep.dimensions |
The dimensions which to keep in storing outcome values. All other dimensions are marginalized. Either keep.dimensions OR exclude.dimensions but not both can be set; if both are NULL, will keep all possible dimensions for the outcome. |
exclude.dimensions |
Dimensions to be marginalized out when storing outcome values. Either keep.dimensions OR exclude.dimensions but not both can be set; if both are NULL, will keep all possible dimensions for the outcome. |
subset.dimension.values |
A list of dimension values indicating for which values of which dimensions the outcome should be tracked |
rename.dimension.values |
A list of names character vectors indicating which dimension values should be renamed in the outcome ontology |
allow.expand.dimensions, allow.expand.denominator.dimensions
|
A character vector of dimensions which can be added to the outcome (or outcome's denominator) even if not present in its component outcomes or quantities. The outcome will have the same value for all values in that dimension |
dimension.aliases |
A named character vector indicating what dimensions in the inputs to the outcome (the names of the vector) should be converted to (the values of the vector) |
dimension.alias.suffix |
A single character value, indicating a suffix that should be removed from the dimensions of the inputs to the outcome. Eg, if ".to" is specified, then dimension "race.to" in outcome inputs becomes "race" in the outcome |
scale |
The scale of this outcome. Can be NULL when outcome.metadata is not NULL (only required when not saving and not using outcome.metadata) |
from.year, to.year
|
The time span during which the outcome should be recorded |
save |
A logical indicator of whether this outcome should be stored in simulations. If FALSE, the outcome will be available for calculating other outcomes (with |
Integrates the dynamic quantity (or the product of the dynamic quantity x multiply by), such that the simulation stores, for each year y, the integral from y to y+1 of (dynamic quantity * multiply.by)
Mark an Outcome to Be Integrated and Tracked
track.integrated.outcome( specification, name, outcome.metadata, value.to.integrate, value.is.numerator = F, multiply.by = NULL, denominator.outcome = NULL, corresponding.data.outcome = NULL, keep.dimensions = NULL, exclude.dimensions = NULL, subset.dimension.values = NULL, rename.dimension.values = NULL, force.dim.names.to.keep.dimensions = F, allow.expand.dimensions = NULL, allow.expand.denominator.dimensions = NULL, dimension.aliases = NULL, dimension.alias.suffix = NULL, scale = NULL, from.year = -Inf, to.year = Inf, save = T )track.integrated.outcome( specification, name, outcome.metadata, value.to.integrate, value.is.numerator = F, multiply.by = NULL, denominator.outcome = NULL, corresponding.data.outcome = NULL, keep.dimensions = NULL, exclude.dimensions = NULL, subset.dimension.values = NULL, rename.dimension.values = NULL, force.dim.names.to.keep.dimensions = F, allow.expand.dimensions = NULL, allow.expand.denominator.dimensions = NULL, dimension.aliases = NULL, dimension.alias.suffix = NULL, scale = NULL, from.year = -Inf, to.year = Inf, save = T )
specification |
The jheem.specification object to modify |
name |
The name by which to access the outcome value after the simulation runs. Cannot be 'infected', 'uninfected' or the name of another outcome |
outcome.metadata |
An object created by |
value.to.integrate |
Either (1) a single character value referencing a separately-registered "point" (non-cumulative) outcome or a quantity, or (2) an expression that includes only the names of point outcomes and model quantities and operators +, -, *, /, ^, sqrt, log, and exp |
value.is.numerator |
In the case where the outcome's scale is proportion, rate, or ratio (any scale that results from a numerator or a denominator), an indicator of whether the value.to.integrate represents just the numerator or the actual proportion/rate/ratio |
multiply.by |
An optional quantity to multiply the outcome value by at each time step before storing. Can be either (1) a numeric value, (2) a single character value referencing a model quantity or element, or (3) an expression that includes only the names of model quantities and elements and operators +, -, *, /, ^, sqrt, log, and exp |
denominator.outcome |
Optional: A denominator for calculating proportions. Must be the name of a separately registered cumulative outcome that has type 'non.negative.number' |
corresponding.data.outcome |
The (optional) name of a real-world outcome (with observations registered to a data.manager) to which this model outcome corresponds |
keep.dimensions |
The dimensions which to keep in storing outcome values. All other dimensions are marginalized. Either keep.dimensions OR exclude.dimensions but not both can be set; if both are NULL, will keep all possible dimensions for the outcome. |
exclude.dimensions |
Dimensions to be marginalized out when storing outcome values. Either keep.dimensions OR exclude.dimensions but not both can be set; if both are NULL, will keep all possible dimensions for the outcome. |
subset.dimension.values |
A list of dimension values indicating for which values of which dimensions the outcome should be tracked |
rename.dimension.values |
A list of names character vectors indicating which dimension values should be renamed in the outcome ontology |
force.dim.names.to.keep.dimensions |
A logical indicating whether the dim.names of the outcome should be forced to match keep.dimensions (based on dimension values in compartments.for.infected.only, compartments.for.uninfected.only, and compartments.for.infected.and.uninfected) regardless of the dimensions of the underlying model quantities that it comprises. |
allow.expand.dimensions, allow.expand.denominator.dimensions
|
A character vector of dimensions which can be added to the outcome (or outcome's denominator) even if not present in its component outcomes or quantities. The outcome will have the same value for all values in that dimension |
dimension.aliases |
A named character vector indicating what dimensions in the inputs to the outcome (the names of the vector) should be converted to (the values of the vector) |
dimension.alias.suffix |
A single character value, indicating a suffix that should be removed from the dimensions of the inputs to the outcome. Eg, if ".to" is specified, then dimension "race.to" in outcome inputs becomes "race" in the outcome |
scale |
The scale of this outcome. Can be NULL when outcome.metadata is not NULL (only required when not saving and not using outcome.metadata) |
from.year, to.year
|
The time span during which the outcome should be recorded |
save |
A logical indicator of whether this outcome should be stored in simulations. If FALSE, the outcome will be available for calculating other outcomes (with |
Tracking outcomes with this function allows "point" outcomes to be converted into "cumulative" outcomes without going through the differential equation solver. This function yields an approximation of the outcome that would be generated by using track.dynamic.outcome in a way that is computationally much less expensive when running simulations
Track a Combination of "Point" (Non-Cumulative) Outcomes
track.point.outcome( specification, name, outcome.metadata, value, value.is.numerator = F, denominator.outcome = NULL, corresponding.data.outcome = NULL, keep.dimensions = NULL, exclude.dimensions = NULL, subset.dimension.values = NULL, rename.dimension.values = NULL, force.dim.names.to.keep.dimensions = F, allow.expand.dimensions = NULL, allow.expand.denominator.dimensions = NULL, dimension.aliases = NULL, dimension.alias.suffix = NULL, scale = NULL, from.year = -Inf, to.year = Inf, save = T )track.point.outcome( specification, name, outcome.metadata, value, value.is.numerator = F, denominator.outcome = NULL, corresponding.data.outcome = NULL, keep.dimensions = NULL, exclude.dimensions = NULL, subset.dimension.values = NULL, rename.dimension.values = NULL, force.dim.names.to.keep.dimensions = F, allow.expand.dimensions = NULL, allow.expand.denominator.dimensions = NULL, dimension.aliases = NULL, dimension.alias.suffix = NULL, scale = NULL, from.year = -Inf, to.year = Inf, save = T )
specification |
The jheem.specification object to modify |
name |
The name by which to access the outcome value after the simulation runs. Cannot be 'infected', 'uninfected' or the name of another outcome |
outcome.metadata |
An object created by |
value |
Either (1) a single character value referencing a separately-registered "point" (non-cumulative) outcome or a quantity, or (2) an expression that includes only the names of point outcomes and model quantities and operators +, -, *, /, ^, sqrt, log, and exp |
value.is.numerator |
In the case where the outcome's scale is proportion, rate, or ratio (any scale that results from a numerator or a denominator), an indicator of whether the value represents just the numerator or the actual proportion/rate/ratio |
denominator.outcome |
A denominator for aggregating the outcome or calculating proportions. Required if the scale of this outcome is not 'number' or 'non.negative.number', otherwise optional. Must be the name of a separately registered "point" (non-cumulative) outcome that has type 'non.negative.number' |
corresponding.data.outcome |
The (optional) name of a real-world outcome (with observations registered to a data.manager) to which this model outcome corresponds |
keep.dimensions |
The dimensions which to keep in storing outcome values. All other dimensions are marginalized. Either keep.dimensions OR exclude.dimensions but not both can be set; if both are NULL, will keep all possible dimensions for the outcome. |
exclude.dimensions |
Dimensions to be marginalized out when storing outcome values. Either keep.dimensions OR exclude.dimensions but not both can be set; if both are NULL, will keep all possible dimensions for the outcome. |
subset.dimension.values |
A list of dimension values indicating for which values of which dimensions the outcome should be tracked |
rename.dimension.values |
A list of names character vectors indicating which dimension values should be renamed in the outcome ontology |
force.dim.names.to.keep.dimensions |
A logical indicating whether the dim.names of the outcome should be forced to match keep.dimensions (based on dimension values in compartments.for.infected.only, compartments.for.uninfected.only, and compartments.for.infected.and.uninfected) regardless of the dimensions of the underlying model quantities that it comprises. |
allow.expand.dimensions, allow.expand.denominator.dimensions
|
A character vector of dimensions which can be added to the outcome (or outcome's denominator) even if not present in its component outcomes or quantities. The outcome will have the same value for all values in that dimension |
dimension.aliases |
A named character vector indicating what dimensions in the inputs to the outcome (the names of the vector) should be converted to (the values of the vector) |
dimension.alias.suffix |
A single character value, indicating a suffix that should be removed from the dimensions of the inputs to the outcome. Eg, if ".to" is specified, then dimension "race.to" in outcome inputs becomes "race" in the outcome |
scale |
The scale of this outcome. Can be NULL when outcome.metadata is not NULL (only required when not saving and not using outcome.metadata) |
from.year, to.year
|
The time span during which the outcome should be recorded |
save |
A logical indicator of whether this outcome should be stored in simulations. If FALSE, the outcome will be available for calculating other outcomes (with |
Creates a "point" (non-cumulative) outcome to track by combining other point outcomes and quantities
Track Sub Version Outcomes for a Specification
track.sub.version.outcomes( specification, sub.versions, outcome.names, keep.dimensions = NULL, subset.dimension.values = NULL, ontology.mapping = NULL, from.year = NULL, to.year = NULL )track.sub.version.outcomes( specification, sub.versions, outcome.names, keep.dimensions = NULL, subset.dimension.values = NULL, ontology.mapping = NULL, from.year = NULL, to.year = NULL )
Mark a Transition for Tracking
track.transition( specification, name, outcome.metadata, dimension, from.compartments, to.compartments, denominator.outcome = NULL, include.tags = NULL, exclude.tags = NULL, groups = NULL, multiply.by = NULL, corresponding.data.outcome = NULL, keep.dimensions = NULL, exclude.dimensions = NULL, subset.dimension.values = NULL, rename.dimension.values = NULL, allow.expand.dimensions = NULL, allow.expand.denominator.dimensions = NULL, dimension.aliases = NULL, dimension.alias.suffix = NULL, scale = NULL, from.year = -Inf, to.year = Inf, save = T )track.transition( specification, name, outcome.metadata, dimension, from.compartments, to.compartments, denominator.outcome = NULL, include.tags = NULL, exclude.tags = NULL, groups = NULL, multiply.by = NULL, corresponding.data.outcome = NULL, keep.dimensions = NULL, exclude.dimensions = NULL, subset.dimension.values = NULL, rename.dimension.values = NULL, allow.expand.dimensions = NULL, allow.expand.denominator.dimensions = NULL, dimension.aliases = NULL, dimension.alias.suffix = NULL, scale = NULL, from.year = -Inf, to.year = Inf, save = T )
specification |
The jheem.specification object to modify |
name |
The name by which to access the outcome value after the simulation runs. Cannot be 'infected', 'uninfected' or the name of another outcome |
outcome.metadata |
An object created by |
dimension |
The name of the (single) dimension along which we are tracking a transition |
from.compartments, to.compartments
|
The names (or aliases) of the from and to compartments of the transition to track that gives information about the resulting quantity |
denominator.outcome |
Optional: A denominator for calculating proportions. Must be the name of a separately registered cumulative outcome that has type 'non.negative.number' |
include.tags |
The tags to track for (as given in the call to |
exclude.tags |
Tags to exclude from tracking. |
groups |
The groups to track for ('infected' or 'uninfected'). Choosing NULL (the default value) tracks for all groups for which the outcome could apply |
multiply.by |
An optional quantity to multiply the outcome value by at each time step before storing. Can be either (1) a numeric value, (2) a single character value referencing a model quantity or element, or (3) an expression that includes only the names of model quantities and elements and operators +, -, *, /, ^, sqrt, log, and exp |
corresponding.data.outcome |
The (optional) name of a real-world outcome (with observations registered to a data.manager) to which this model outcome corresponds |
keep.dimensions |
The dimensions which to keep in storing outcome values. All other dimensions are marginalized. Either keep.dimensions OR exclude.dimensions but not both can be set; if both are NULL, will keep all possible dimensions for the outcome. |
exclude.dimensions |
Dimensions to be marginalized out when storing outcome values. Either keep.dimensions OR exclude.dimensions but not both can be set; if both are NULL, will keep all possible dimensions for the outcome. |
subset.dimension.values |
A list of dimension values indicating for which values of which dimensions the outcome should be tracked |
rename.dimension.values |
A list of names character vectors indicating which dimension values should be renamed in the outcome ontology |
allow.expand.dimensions, allow.expand.denominator.dimensions
|
A character vector of dimensions which can be added to the outcome (or outcome's denominator) even if not present in its component outcomes or quantities. The outcome will have the same value for all values in that dimension |
dimension.aliases |
A named character vector indicating what dimensions in the inputs to the outcome (the names of the vector) should be converted to (the values of the vector) |
dimension.alias.suffix |
A single character value, indicating a suffix that should be removed from the dimensions of the inputs to the outcome. Eg, if ".to" is specified, then dimension "race.to" in outcome inputs becomes "race" in the outcome |
scale |
The scale of this outcome. Can be NULL when outcome.metadata is not NULL (only required when not saving and not using outcome.metadata) |
from.year, to.year
|
The time span during which the outcome should be recorded |
save |
A logical indicator of whether this outcome should be stored in simulations. If FALSE, the outcome will be available for calculating other outcomes (with |
Integrates the transition (or the product of transition x multiply by), such that the simulation stores, for each year y, the integral from y to y+1 of (transition * multiply.by)
Get the union of dimension values sets
union.dimension.values(..., error.prefix = "")union.dimension.values(..., error.prefix = "")
... |
can be either (1) dimension values or (2) lists of dimension values |
Create a Target Population that is the UNION Other Target Populations
union.target.populations(..., name = NULL)union.target.populations(..., name = NULL)
... |
One or more target.population objects or lists of target populations |
name |
A short (<= 20 characters) descriptive name for the target population. Should be nicely formatted for public display |
Other Functions to create Target Populations:
create.target.population(),
diff.target.populations(),
intersect.target.populations()
Change the keep.dimensions of an outcome registered to an ancestor specification
## S3 method for class 'outcome.keep.dimensions' update(specification, outcome.name, keep.dimensions, exclude.dimensions = NULL)## S3 method for class 'outcome.keep.dimensions' update(specification, outcome.name, keep.dimensions, exclude.dimensions = NULL)
specification |
The jheem.specification object to modify |
outcome.name |
The name of the outcome to update keep.dimensions for |
keep.dimensions |
The dimensions which to keep in storing outcome values. All other dimensions are marginalized. Either keep.dimensions OR exclude.dimensions but not both can be set; if both are NULL, will keep all possible dimensions for the outcome. |
exclude.dimensions |
Dimensions to be marginalized out when storing outcome values. Either keep.dimensions OR exclude.dimensions but not both can be set; if both are NULL, will keep all possible dimensions for the outcome. |
Makes the binding active while 'expr' is evaluated, and restores the previous active binding afterwards, also on error.
using.data.binding(binding, expr)using.data.binding(binding, expr)
binding |
A 'jheem.data.binding' object |
expr |
The expression to evaluate |
The value of 'expr'
Check Whether a JHEEM Model Specification has been Registered for a Version
version.has.been.registered(version)version.has.been.registered(version)
version |
A character vector with one or more version names |
A logical vector of the same length as 'version'
Other JHEEM Version Management Functions:
get.prior.versions(),
get.specification.for.version(),
register.model.specification()