ModVar {rdecision}R Documentation

A model variable incorporating uncertainty

Description

An R6 class for a variable in a health economic model.

Details

Base class for a variable used in a health economic model. The base class wraps a numerical value which is used in calculations. It provides a framework for creating classes of model variables whose uncertainties are described by statistical distributions parametrized with hyperparameters.

Methods

Public methods


Method new()

Create an object of type ModVar.

Usage
ModVar$new(description, units, D = NULL, k = 1L)
Arguments
description

A character string description of the variable and its role in the model. This description will be used in a tabulation of the variables linked to a model.

units

A character string description of the units, e.g. "GBP", "per year".

D

The distribution representing the uncertainty in the variable. Should inherit from class Distribution, or NULL if none is defined.

k

The index of the dimension of the multivariate distribution that applies to this model variable.

Details

A ModVar is associated with an uncertainty distribution (a "has-a" relationship in object-oriented terminology). There can be a 1-1 mapping of ModVars to Distributions, or several model variables can be linked to the same distribution in a many-1 mapping, e.g. when each transition probability from a Markov state is represented as a ModVar and each can be linked to the k dimensions of a common multivariate Dirichlet distribution.

Returns

A new ⁠ModVar⁠ object.


Method is_expression()

Is this ModVar an expression?

Usage
ModVar$is_expression()
Returns

TRUE if it inherits from ExprModVar, FALSE otherwise.


Method is_probabilistic()

Is the model variable probabilistic?

Usage
ModVar$is_probabilistic()
Details

Tests whether the model variable is probabilistic, i.e. a random variable that follows a distribution, or an expression involving random variables, some of which follow distributions.

Returns

TRUE if probabilistic


Method description()

Accessor function for the description.

Usage
ModVar$description()
Returns

Description of model variable as character string.


Method units()

Accessor function for units.

Usage
ModVar$units()
Returns

Description of units as character string.


Method distribution()

Name and parameters of the uncertainty distribution.

Usage
ModVar$distribution()
Details

If K > 1 the dimension of the distribution associated with this model variable is appended, e.g. Dir(2,3)[1] means that the model variable is associated with the first dimension of a 2D Dirichlet distribution with alpha parameters 2 and 3.

Returns

Distribution name as character string.


Method mean()

Mean value of the model variable.

Usage
ModVar$mean()
Returns

Mean value as a numeric value.


Method mode()

The mode of the variable.

Usage
ModVar$mode()
Details

By default returns NA, which will be the case for most ModVar variables, because arbitrary distributions are not guaranteed to be unimodal.

Returns

Mode as a numeric value.


Method SD()

Standard deviation of the model variable.

Usage
ModVar$SD()
Returns

Standard deviation as a numeric value


Method quantile()

Quantiles of the uncertainty distribution.

Usage
ModVar$quantile(probs)
Arguments
probs

Numeric vector of probabilities, each in range [0,1].

Returns

Vector of numeric values of the same length as probs.


Method r()

Draw a random sample from the model variable.

Usage
ModVar$r()
Details

The same random sample will be returned until set is called to force a resample.

Returns

A sample drawn at random.


Method set()

Sets the value of the ModVar.

Usage
ModVar$set(what = "random", val = NULL)
Arguments
what

Until set is called again, subsequent calls to get will return a value determined by the what parameter as follows:

"random"

a random sample is drawn from the uncertainty distribution;

"expected"

the mean of the uncertainty distribution;

"q2.5"

the lower 95% confidence limit of the uncertainty distribution, i.e. the 2.5th percentile;

"q50"

the median of the uncertainty distribution;

"q97.5"

the upper 95% confidence limit of the uncertainty distribution, i.e. the 97.5th percentile;

"current"

leaves the what parameter of method set unchanged, i.e. the call to set has no effect on the subsequent values returned by get. It is provided as an option to help use cases in which the what parameter is a variable;

"value"

sets the value explicitly to be equal to parameter val. This is not recommended for normal usage because it allows the model variable to be set to an implausible value, based on its defined uncertainty. An example of where this may be needed is in threshold finding.

val

A numeric value, only used with what="value", ignored otherwise.

Returns

Updated ModVar.


Method get()

Get the value of the ModVar.

Usage
ModVar$get()
Details

Returns the value defined by the most recent call to set().

Returns

Value determined by last set().


Method clone()

The objects of this class are cloneable with this method.

Usage
ModVar$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Author(s)

Andrew Sims andrew.sims@newcastle.ac.uk


[Package rdecision version 1.2.0 Index]