Title: | Adjusted Limited Dependent Variable Mixture Models |
---|---|
Description: | The goal of the package 'aldvmm' is to fit adjusted limited dependent variable mixture models of health state utilities. Adjusted limited dependent variable mixture models are finite mixtures of normal distributions with an accumulation of density mass at the limits, and a gap between 100% quality of life and the next smaller utility value. The package 'aldvmm' uses the likelihood and expected value functions proposed by Hernandez Alava and Wailoo (2015) <doi:10.1177/1536867X1501500307> using normal component distributions and a multinomial logit model of probabilities of component membership. |
Authors: | Mark Pletscher [aut, cre, cph], Achim Zeileis [ctb] |
Maintainer: | Mark Pletscher <[email protected]> |
License: | GPL-3 |
Version: | 0.8.8 |
Built: | 2024-11-22 04:22:06 UTC |
Source: | https://github.com/pletschm/aldvmm |
The goal of the package 'aldvmm' is to fit adjusted limited dependent variable mixture models of health state utilities. Adjusted limited dependent variable mixture models are finite mixtures of normal distributions with an accumulation of density mass at the limits, and a gap between 100% quality of life and the next smaller utility value. The package 'aldvmm' uses the likelihood and expected value functions proposed by Hernandez Alava and Wailoo (2015) <doi: 10.1177/1536867X1501500307> using normal component distributions and a multinomial logit model of probabilities of component membership.
data(utility) fit <- aldvmm(eq5d ~ age + female | 1, data = utility, psi = c(0.883, -0.594), ncmp = 2) summary(fit) yhat <- predict(fit)
data(utility) fit <- aldvmm(eq5d ~ age + female | 1, data = utility, psi = c(0.883, -0.594), ncmp = 2) summary(fit) yhat <- predict(fit)
The function aldvmm
fits adjusted limited dependent variable mixture models
of health state utilities. Adjusted limited dependent variable mixture
models are finite mixtures of normal distributions with an accumulation of
density mass at the limits, and a gap between 100% quality of life and
the next smaller utility value. The package aldvmm
uses the
likelihood and expected value functions proposed by Hernandez Alava and
Wailoo (2015) using normal component distributions and a multinomial logit
model of probabilities of component membership.
aldvmm( formula, data, subset = NULL, psi, ncmp = 2, dist = "normal", optim.method = NULL, optim.control = list(trace = FALSE), optim.grad = TRUE, init.method = "zero", init.est = NULL, init.lo = NULL, init.hi = NULL, se.fit = FALSE, model = TRUE, level = 0.95, na.action = "na.omit" )
aldvmm( formula, data, subset = NULL, psi, ncmp = 2, dist = "normal", optim.method = NULL, optim.control = list(trace = FALSE), optim.grad = TRUE, init.method = "zero", init.est = NULL, init.lo = NULL, init.hi = NULL, se.fit = FALSE, model = TRUE, level = 0.95, na.action = "na.omit" )
formula |
an object of class "formula" with a symbolic
description of the model to be fitted. The model formula takes the form
|
data |
a data frame, list or environment (or object coercible to a data
frame by
|
subset |
an optional numeric vector of row indices of the subset of the model
matrix used in the estimation. |
psi |
a numeric vector of minimum and maximum possible utility values
smaller than or equal to 1 (e.g. |
ncmp |
a numeric value of the number of components that are mixed. The
default value is 2. A value of 1 represents a tobit model with a gap
between 1 and the maximum value in |
dist |
an optional character value of the distribution used in the
components. In this release, only the normal distribution is
available, and the default value is set to |
optim.method |
an optional character value of one of the following
|
optim.control |
an optional list of
|
optim.grad |
an optional logical value indicating if an analytical
gradient should be used in
|
init.method |
an optional character value indicating the method for
obtaining initial values. The following values are available:
|
init.est |
an optional numeric vector of user-defined initial values.
User-defined initial values override the |
init.lo |
an optional numeric vector of user-defined lower limits for
constrained optimization. When |
init.hi |
an optional numeric vector of user-defined upper limits for
constrained optimization. When |
se.fit |
an optional logical value indicating whether standard errors
of fitted values are calculated. The default value is |
model |
an optional logical value indicating whether the estimation
data frame is returned in the output object. The default value is
|
level |
a numeric value of the significance level for confidence bands of fitted values. The default value is 0.95. |
na.action |
a character value passed to
argument |
aldvmm
fits
an adjusted limited dependent variable mixture model using the likelihood
and expected value functions from Hernandez Alava and Wailoo (2015). The
model accounts for latent classes, multi-modality, minimum and maximum
utility values and potential gaps between 1 and the next smaller utility
value. Adjusted limited dependent variable mixture models combine
multiple component distributions with a multinomial logit model of the
probabilities of component membership. The standard deviations of normal
distributions are estimated and reported as log-transformed values which
enter the likelihood function as exponentiated values to ensure
non-negative values.
The minimum utility and the largest utility smaller than or equal to 1 are
supplied in the argument 'psi'
. The number of
distributions/components that are mixed is set by the argument
'ncmp'
. When 'ncmp'
is set to 1 the procedure estimates a
tobit model with a gap between 1 and the maximum utility value in
'psi'
. The current version only allows finite mixtures of normal
distributions.
The 'formula'
object can include a |
delimiter to separate
formulae for expected values in components (left) and the multinomial
logit model of probabilities of group membership (right). If no |
delimiter is used, the same formula will be used for expected values in
components and the multinomial logit of the probabilities of component
membership.
aldvmm
uses
optimr
for
maximum likelihood estimation of model parameters. The argument
'optim.method'
accepts the following methods: "Nelder-Mead"
,
"BFGS"
, "CG"
, "L-BFGS-B"
, "nlminb"
,
"Rcgmin"
, "Rvmmin"
and "hjn"
. The default method is
"BFGS"
. The method "nlm"
cannot be used in
aldvmm
because it
requires a different implementation of the likelihood function. The
argument 'optim.control'
accepts a list of
optimr
control parameters. If 'optim.grad'
is set to TRUE
the
function
optimr
uses
analytical gradients during the optimization procedure for all methods
that allow for this approach. If 'optim.grad'
is set to
FALSE
or a method cannot use gradients, a finite difference
approximation is used. The hessian matrix at maximum likelihood parameters
is approximated numerically using
hessian
.
'init.method'
accepts four values of methods for generating initial
values: "zero"
, "random"
, "constant"
, "sann"
.
The method "zero"
sets initial values of all parameters to 0. The
method "random"
draws random starting values from a standard normal
distribution. The method "constant"
estimates a constant-only
model and uses estimates as initial values of intercepts and standard
errors and 0 for all other parameters. The method "sann"
estimates
the full model using the simulated annealing optimization method in
optim
and uses
parameter estimates as initial values. When user-specified initial values
are supplied in 'init.est'
, the argument 'init.method'
is
ignored.
By default, aldvmm
performs unconstrained optimization with upper and lower limits at
-Inf
and Inf
. When user-defined lower and upper limits are
supplied to 'init.lo'
and/or 'init.hi'
, these default limits
are replaced with the user-specified values, and the method
"L-BFGS-B"
is used for box-constrained optimization instead of the
user defined 'optim.method'
. It is possible to only set either
maximum or minimum limits. When initial values supplied to
'init.est'
or from default methods lie outside the limits, the
in-feasible values will be set to the limits using the function
bmchk
.
The function aldvmm()
returns the negative log-likelihood, Akaike
information criterion and Bayesian information criterion. Smaller values
of these measures indicate better fit.
If 'se.fit'
is set to TRUE
, standard errors of fitted values
are calculated using the delta method. The standard errors of fitted
values in the estimation data set are calculated as , where
is the gradient of a fitted value with respect to changes of parameter
estimates, and
is the estimated covariance matrix of
parameters (Dowd et al., 2014). The standard errors of predicted values
in new data sets are calculated as
, where
is the mean squared error of fitted versus observed
outcomes in the original estimation data (Whitmore, 1986).
The generic function
summary
can be
used to obtain or print a summary of the results. The generic function
predict
can
be used to obtain predicted values and standard errors of predictions in
new data.
aldvmm
returns an object of class "aldvmm". An object of class
"aldvmm" is a list containing the following objects.
coef |
a numeric vector of parameter estimates. |
hessian |
a numeric matrix object with second partial derivatives of the likelihood function. |
cov |
a numeric matrix object with covariances of parameters. |
n |
a scalar representing the number of observations that were used in the estimation. |
k |
a scalar representing the number of components that were mixed. |
df.null |
an integer value of the residual degrees of freedom of a null model including intercepts and standard errors. |
df.residual |
an integer value of the residual degrees of freedom.. |
iter |
an integer value of the number of iterations used in optimization. |
convergence |
an integer value indicating convergence. "0" indicates successful completion. |
gof |
a list including the following elements.
|
pred |
a list including the following elements.
|
init |
a list including the following elements.
|
call |
a character value including the model call captured by
|
formula |
an object of class "formula" supplied to argument
|
terms |
a list of objects of class "terms" for the model of component means ("beta"), probabilities of component membership ("delta") and the full model ("full"). |
contrasts |
a nested list of character values showing contrasts of factors used in models of component means ("beta") and probabilities of component membership ("delta"). |
data |
a data frame created by
|
psi |
a numeric vector with the minimum and maximum utility
below 1 in |
dist |
a character value indicating the used component distributions. |
label |
a list including the following elements.
|
optim.method |
a character value of the used
|
level |
a numeric value of the confidence level used for reporting. |
na.action |
an object of class "omit" extracted from the
"na.action" attribute of the data frame created by
|
Alava, M. H. and Wailoo, A. (2015) Fitting adjusted limited dependent variable mixture models to EQ-5D. The Stata Journal, 15(3), 737–750. doi:10.1177/1536867X1501500307
Dowd, B. E., Greene, W. H., and Norton, E. C. (2014) Computation of standard errors. Health services research, 49(2), 731–750. doi:10.1111/1475-6773.12122
Whitmore, G. A. (1986) Prediction limits for a univariate normal observation. The American Statistician, 40(2), 141–143. doi:10.1080/00031305.1986.10475378
data(utility) fit <- aldvmm(eq5d ~ age + female | 1, data = utility, psi = c(0.883, -0.594), ncmp = 2) summary(fit) yhat <- predict(fit)
data(utility) fit <- aldvmm(eq5d ~ age + female | 1, data = utility, psi = c(0.883, -0.594), ncmp = 2) summary(fit) yhat <- predict(fit)
aldvmm
aldvmm.check
runs validity checks of objects supplied to
aldvmm
.
aldvmm.check( formula, data, subset, psi, ncmp, dist, optim.method, optim.control, optim.grad, init.method, init.est, init.lo, init.hi, se.fit, model, level, na.action, lcoef, lcpar, lcmp )
aldvmm.check( formula, data, subset, psi, ncmp, dist, optim.method, optim.control, optim.grad, init.method, init.est, init.lo, init.hi, se.fit, model, level, na.action, lcoef, lcpar, lcmp )
formula |
an object of class "formula" with a symbolic
description of the model to be fitted. The model formula takes the form
|
data |
a data frame, list or environment (or object coercible to a data
frame by
|
subset |
an optional numeric vector of row indices of the subset of the model
matrix used in the estimation. |
psi |
a numeric vector of minimum and maximum possible utility values
smaller than or equal to 1 (e.g. |
ncmp |
a numeric value of the number of components that are mixed. The
default value is 2. A value of 1 represents a tobit model with a gap
between 1 and the maximum value in |
dist |
an optional character value of the distribution used in the
components. In this release, only the normal distribution is
available, and the default value is set to |
optim.method |
an optional character value of one of the following
|
optim.control |
an optional list of
|
optim.grad |
an optional logical value indicating if an analytical
gradient should be used in
|
init.method |
an optional character value indicating the method for
obtaining initial values. The following values are available:
|
init.est |
an optional numeric vector of user-defined initial values.
User-defined initial values override the |
init.lo |
an optional numeric vector of user-defined lower limits for
constrained optimization. When |
init.hi |
an optional numeric vector of user-defined upper limits for
constrained optimization. When |
se.fit |
an optional logical value indicating whether standard errors
of fitted values are calculated. The default value is |
model |
an optional logical value indicating whether the estimation
data frame is returned in the output object. The default value is
|
level |
a numeric value of the significance level for confidence bands of fitted values. The default value is 0.95. |
na.action |
a character value passed to
argument |
lcoef |
a character vector of length 2 with labels of objects including
regression coefficients of component distributions (default |
lcpar |
a character vector with the labels of objects including
constant parameters of component distributions (e.g. the standard
deviation of the normal distribution). The length of |
lcmp |
a character value representing a stub (default |
aldvmm.check
checks the validity of arguments of
aldvmm
.
aldvmm.check
returns warnings or stops the execution of
aldvmm
if validity
checks fail.
aldvmm.cv
performs
a numerical approximation of the covariance matrix of parameter estimates.
aldvmm.cv(ll, par, X, y, dist, psi, ncmp, lcoef, lcpar, lcmp, optim.method)
aldvmm.cv(ll, par, X, y, dist, psi, ncmp, lcoef, lcpar, lcmp, optim.method)
ll |
a function returning the negative log-likelihood of the adjusted
limited dependent variable mixture model as a scalar result
( |
par |
a named numeric vector of parameter values. |
X |
a list of design matrices returned by
|
y |
a numeric vector of observed outcomes from complete observations in
|
dist |
an optional character value of the distribution used in the
components. In this release, only the normal distribution is
available, and the default value is set to |
psi |
a numeric vector of minimum and maximum possible utility values
smaller than or equal to 1 (e.g. |
ncmp |
a numeric value of the number of components that are mixed. The
default value is 2. A value of 1 represents a tobit model with a gap
between 1 and the maximum value in |
lcoef |
a character vector of length 2 with labels of objects including
regression coefficients of component distributions (default |
lcpar |
a character vector with the labels of objects including
constant parameters of component distributions (e.g. the standard
deviation of the normal distribution). The length of |
lcmp |
a character value representing a stub (default |
optim.method |
an optional character value of one of the following
|
aldvmm.cv
uses
hessian
to calculate the hessian matrix of the log-likelihood function supplied to
'll'
at parameter values supplied to 'par'
.
aldvmm.cv
returns a list with the following objects.
hessian |
a numeric matrix with second-order partial
derivatives of the likelihood function |
cv |
a
numeric matrix with covariances/variances of parameters in |
se |
a numeric vector of standard errors of parameters in
|
z |
a numeric vector of z-values of parameters
in |
p |
a numeric vector of p-values of parameter estimates. |
upper |
a numeric vector of upper 95%
confidence limits of parameter estimates in |
lower |
a numeric vector of lower 95% confidence limits of
parameter estimates in |
aldvmm.getnames
creates names of parameter vectors used in
aldvmm
. The order of
the elements in 'lcoef'
and 'lcpar'
determines the order of
parameters and the structure of summary tables returned by
summary.aldvmm
.
aldvmm.getnames(X, names, lcoef, lcpar, lcmp, ncmp)
aldvmm.getnames(X, names, lcoef, lcpar, lcmp, ncmp)
X |
a list of design matrices returned by
|
names |
a character vector of names of considered elements
(distributions |
lcoef |
a character vector of length 2 with labels of objects including
regression coefficients of component distributions (default |
lcpar |
a character vector with the labels of objects including
constant parameters of component distributions (e.g. the standard
deviation of the normal distribution). The length of |
lcmp |
a character value representing a stub (default |
ncmp |
a numeric value of the number of components that are mixed. The
default value is 2. A value of 1 represents a tobit model with a gap
between 1 and the maximum value in |
a character vector of names of parameter vectors used in
aldvmm
.
aldvmm.getpar()
extracts parameters from parameter vectors into nested
lists.
aldvmm.getpar(par, lcoef, lcmp, lcpar, ncmp)
aldvmm.getpar(par, lcoef, lcmp, lcpar, ncmp)
par |
a named numeric vector of parameter values. |
lcoef |
a character vector of length 2 with labels of objects including
regression coefficients of component distributions (default |
lcmp |
a character value representing a stub (default |
lcpar |
a character vector with the labels of objects including
constant parameters of component distributions (e.g. the standard
deviation of the normal distribution). The length of |
ncmp |
a numeric value of the number of components that are mixed. The
default value is 2. A value of 1 represents a tobit model with a gap
between 1 and the maximum value in |
aldvmm.getpar
identifies parameters that belong to coefficients of component distributions
(label "beta"
), coefficients of the multinomial logit model of
probabilities of component membership (label "delta"
), constant
parameters of component distributions (label "lnsigma"
for
dist=="normal"
), and 1:K
components (labels "Comp1" ...
"CompK")) based on parameter names generated by
aldvmm.getnames
.
a named nested list with parameter vectors for "beta"
,
"delta"
and "lnsigma"
within all 1:K
components. The
names of the list correspond to the labels in 'lcoef'
,
'lcpar'
and 'lcmp'
.
aldvmm.gof
calculates residual- and likelihood-based goodness of fit measures.
aldvmm.gof(res, par, ll)
aldvmm.gof(res, par, ll)
res |
a numeric vector of residuals of all observations in the estimation data. |
par |
a named numeric vector of parameter estimates. |
ll |
a numeric value of the log-likelihood. |
aldvmm.gof
calculates mean squared errors as , and mean absolute
errors as
, where
denotes observed
outcomes,
denotes fitted values,
denotes the sample size, and
denotes the number of parameters.
The Akaike information criterion is calculated as
, and the Bayesian information criterion is calculated as
, where
denotes the
log-likelihood.
aldvmm.gof
returns a list including the following objects.
mse |
a numeric value of the mean squared error of observed versus fitted outcomes. |
mae |
a numeric value of the mean absolute error of observed versus fitted outcomes. |
ll |
a numeric value of the negative log-likelihood. |
aic |
a numeric value of the Akaike information criterion. |
bic |
a numeric value of the Bayesian information criterion. |
aldvmm.gr
calculates numerical gradients of the negative log-likelihood of the entire
estimation data with respect to parameter values in 'par'
.
aldvmm.gr(par, X, y, psi, dist, ncmp, lcoef, lcmp, lcpar, optim.method)
aldvmm.gr(par, X, y, psi, dist, ncmp, lcoef, lcmp, lcpar, optim.method)
par |
a named numeric vector of parameter values. |
X |
a list of design matrices returned by
|
y |
a numeric vector of observed outcomes from complete observations in
|
psi |
a numeric vector of minimum and maximum possible utility values
smaller than or equal to 1 (e.g. |
dist |
an optional character value of the distribution used in the
components. In this release, only the normal distribution is
available, and the default value is set to |
ncmp |
a numeric value of the number of components that are mixed. The
default value is 2. A value of 1 represents a tobit model with a gap
between 1 and the maximum value in |
lcoef |
a character vector of length 2 with labels of objects including
regression coefficients of component distributions (default |
lcmp |
a character value representing a stub (default |
lcpar |
a character vector with the labels of objects including
constant parameters of component distributions (e.g. the standard
deviation of the normal distribution). The length of |
optim.method |
an optional character value of one of the following
|
aldvmm.gr
uses aldvmm.sc
to
calculate analytical gradients of the negative log-likelihood.
If 'par'
includes infinite values
aldvmm.gr
returns a
gradient of zero.
a named numeric vector of first derivatives of the negative
log-likelihood of the data with respect to parameters in 'par'
.
aldvmm.init
creates initial values for the minimization of the negative log-likelihood
returned by
aldvmm.ll
using
optimr
.
aldvmm.init( X, y, psi, ncmp, dist, init.method, init.est, init.lo, init.hi, optim.method, optim.control = list(), optim.grad, lcoef, lcpar, lcmp )
aldvmm.init( X, y, psi, ncmp, dist, init.method, init.est, init.lo, init.hi, optim.method, optim.control = list(), optim.grad, lcoef, lcpar, lcmp )
X |
a list of design matrices returned by
|
y |
a numeric vector of observed outcomes from complete observations in
|
psi |
a numeric vector of minimum and maximum possible utility values
smaller than or equal to 1 (e.g. |
ncmp |
a numeric value of the number of components that are mixed. The
default value is 2. A value of 1 represents a tobit model with a gap
between 1 and the maximum value in |
dist |
an optional character value of the distribution used in the
components. In this release, only the normal distribution is
available, and the default value is set to |
init.method |
an optional character value indicating the method for
obtaining initial values. The following values are available:
|
init.est |
an optional numeric vector of user-defined initial values.
User-defined initial values override the |
init.lo |
an optional numeric vector of user-defined lower limits for
constrained optimization. When |
init.hi |
an optional numeric vector of user-defined upper limits for
constrained optimization. When |
optim.method |
an optional character value of one of the following
|
optim.control |
an optional list of
|
optim.grad |
an optional logical value indicating if an analytical
gradient should be used in
|
lcoef |
a character vector of length 2 with labels of objects including
regression coefficients of component distributions (default |
lcpar |
a character vector with the labels of objects including
constant parameters of component distributions (e.g. the standard
deviation of the normal distribution). The length of |
lcmp |
a character value representing a stub (default |
'init.method'
accepts four methods for generating initial
values: "zero"
, "random"
, "constant"
, "sann"
.
The method "zero"
sets initial values of all parameters to 0. The
method "random"
draws random starting values from a standard normal
distribution. The method "constant"
estimates a constant-only
model and uses estimates as initial values for intercepts and constant
distribution parameters and 0 for all other parameters. The method
"sann"
estimates the full model using the simulated annealing
optimization method and uses all parameter estimates as initial values.
When user-specified initial values are supplied in 'init.est'
, the
argument 'init.method'
is ignored.
By default, aldvmm
performs unconstrained optimization with upper and lower limits at
-Inf
and Inf
. When user-defined lower and upper limits are
supplied to 'init.lo'
and/or 'init-hi'
, these default limits
are replaced with the user-specified values, and the method
"L-BFGS-B"
is used for box-constrained optimization instead of the
user defined 'optim.method'
. It is possible to only set either
maximum or minimum limits. When initial values supplied to
'init.est'
or from default methods lie outside the limits, the
in-feasible values will be set to the limits using the function
bmchk
.
aldvmm.init
returns a list with the following objects.
est |
a numeric vector of initial values of parameters. |
lo |
a numeric vector of lower limits of parameters. |
hi |
a numeric vector of upper limits of parameters. |
aldvmm.ll
calculates the negative log-likelihood of 'data'
supplied to
aldvmm
at the
parameter values in 'par'
.
aldvmm.ll(par, X, y, psi, ncmp, dist, lcoef, lcpar, lcmp, optim.method)
aldvmm.ll(par, X, y, psi, ncmp, dist, lcoef, lcpar, lcmp, optim.method)
par |
a named numeric vector of parameter values. |
X |
a list of design matrices returned by
|
y |
a numeric vector of observed outcomes from complete observations in
|
psi |
a numeric vector of minimum and maximum possible utility values
smaller than or equal to 1 (e.g. |
ncmp |
a numeric value of the number of components that are mixed. The
default value is 2. A value of 1 represents a tobit model with a gap
between 1 and the maximum value in |
dist |
an optional character value of the distribution used in the
components. In this release, only the normal distribution is
available, and the default value is set to |
lcoef |
a character vector of length 2 with labels of objects including
regression coefficients of component distributions (default |
lcpar |
a character vector with the labels of objects including
constant parameters of component distributions (e.g. the standard
deviation of the normal distribution). The length of |
lcmp |
a character value representing a stub (default |
optim.method |
an optional character value of one of the following
|
aldvmm.ll
calculates the negative log-likelihood of the adjusted limited dependent
variable mixture model using the likelihood function published in
Hernandez Alava and Wailoo (2015). Constant distribution parameters that
need to be non-negative (i.e. the standard deviations of normal
distributions) enter the likelihood function as log-transformed values.
As the "L-BFGS-B" and "Rcgmin" methods in
optimr
fail
if they encounter infinite values, the log-likelihood function takes the
value -1e+20 if it is infinite during these algorithms.
The names of the parameter vector supplied to 'par'
must be
generated using aldvmm.getnames
because they will be inherited by return values
of other functions in the package 'aldvmm'
. The names will also be
used in the extraction of parameters from parameter vectors into nested
lists using
aldvmm.getpar
.
a scalar of the negative log-likelihood of the data at parameter
values in 'par'
.
Alava, M. H. and Wailoo, A. (2015) Fitting adjusted limited
dependent variable mixture models to EQ-5D. The Stata Journal,
15(3), 737–750. doi:10.1177/1536867X1501500307
aldvmm.mm
creates
a list of two design matrices, one of the model of component distributions
("beta"
) and one of the model of probabilities of component
membership ("delta"
).
aldvmm.mm(mf, Formula, ncmp, lcoef)
aldvmm.mm(mf, Formula, ncmp, lcoef)
mf |
a data frame created by
|
Formula |
an object of class "Formula" created by
|
ncmp |
a numeric value of the number of components that are mixed. The
default value is 2. A value of 1 represents a tobit model with a gap
between 1 and the maximum value in |
lcoef |
a character vector of length 2 with labels of objects including
regression coefficients of component distributions (default |
aldvmm.mm
uses
model.matrix
to create design matrices for models of component distributions
("beta"
) and probabilities of component membership ("delta"
)
based on a "Formula" object created by
Formula
and a model frame created by
model.frame
.
The design matrix for probabilities of group membership is only created if
more than one components are specified in 'ncmp'
.
a named list of numeric matrices.
beta |
a numeric design matrix for the model of component distributions. |
delta |
a numeric design matrix of the multinomial logit model of probabilities of component membership. |
aldvmm.pred
makes
predictions of observations in design matrices in 'X'
using parameter
estimates returned by
aldvmm
.
aldvmm.pred(par, X, y = NULL, psi, ncmp, dist, lcoef, lcpar, lcmp)
aldvmm.pred(par, X, y = NULL, psi, ncmp, dist, lcoef, lcpar, lcmp)
par |
a named numeric vector of parameter values. |
X |
a list of design matrices returned by
|
y |
a numeric vector of observed outcomes from complete observations in
|
psi |
a numeric vector of minimum and maximum possible utility values
smaller than or equal to 1 (e.g. |
ncmp |
a numeric value of the number of components that are mixed. The
default value is 2. A value of 1 represents a tobit model with a gap
between 1 and the maximum value in |
dist |
an optional character value of the distribution used in the
components. In this release, only the normal distribution is
available, and the default value is set to |
lcoef |
a character vector of length 2 with labels of objects including
regression coefficients of component distributions (default |
lcpar |
a character vector with the labels of objects including
constant parameters of component distributions (e.g. the standard
deviation of the normal distribution). The length of |
lcmp |
a character value representing a stub (default |
aldvmm.pred
calculates expected values for observations in design matrices in 'X'
using the expected value function published in Hernandez Alava and Wailoo
(2015). Constant distribution parameters that need to be non-negative (i.e.
standard deviations of normal distributions) enter the expected value
function as log-transformed values.
a list of of predicted outcomes including the following elements.
y |
a numeric vector of observed outcomes in |
yhat |
a numeric vector of fitted values. |
res |
a numeric vector of residuals. |
prob |
a numeric matrix of expected
probabilities of group membership per individual in |
aldvmm.sc
calculates analytical gradients of the negative log-likelihood with respect
to parameter values in 'par'
for each observation in the estimation
data.
aldvmm.sc( par, X, y, psi, dist, ncmp, lcoef = lcoef, lcmp = lcmp, lcpar = lcpar, optim.method )
aldvmm.sc( par, X, y, psi, dist, ncmp, lcoef = lcoef, lcmp = lcmp, lcpar = lcpar, optim.method )
par |
a named numeric vector of parameter values. |
X |
a list of design matrices returned by
|
y |
a numeric vector of observed outcomes from complete observations in
|
psi |
a numeric vector of minimum and maximum possible utility values
smaller than or equal to 1 (e.g. |
dist |
an optional character value of the distribution used in the
components. In this release, only the normal distribution is
available, and the default value is set to |
ncmp |
a numeric value of the number of components that are mixed. The
default value is 2. A value of 1 represents a tobit model with a gap
between 1 and the maximum value in |
lcoef |
a character vector of length 2 with labels of objects including
regression coefficients of component distributions (default |
lcmp |
a character value representing a stub (default |
lcpar |
a character vector with the labels of objects including
constant parameters of component distributions (e.g. the standard
deviation of the normal distribution). The length of |
optim.method |
an optional character value of one of the following
|
aldvmm.sc
calculates gradients of the negative log-likelihood.
a named numeric matrix of first derivatives of the negative
log-likelihood of the data with respect to parameters in 'par'
.
aldvmm.sefit
calculates standard errors of fitted and predicted outcomes using the delta
method.
aldvmm.sefit( par, yhat, X, type, psi, cv, mse = NA, ncmp, dist, level, lcoef, lcmp, lcpar )
aldvmm.sefit( par, yhat, X, type, psi, cv, mse = NA, ncmp, dist, level, lcoef, lcmp, lcpar )
par |
a named numeric vector of parameter values. |
yhat |
a numeric vector of predicted outcomes returned by
|
X |
a list of design matrices returned by
|
type |
a character value of either 'fit' or 'pred' indicating whether the standard error of the fit ('fit') or the standard error of predictions in new data ('pred') are calculated. |
psi |
a numeric vector of minimum and maximum possible utility values
smaller than or equal to 1 (e.g. |
cv |
a numeric matrix with covariances/variances of parameter estimates
returned by
|
mse |
a numeric value of the mean squared error of observed versus
predicted outcomes |
ncmp |
a numeric value of the number of components that are mixed. The
default value is 2. A value of 1 represents a tobit model with a gap
between 1 and the maximum value in |
dist |
an optional character value of the distribution used in the
components. In this release, only the normal distribution is
available, and the default value is set to |
level |
a numeric value of the significance level for confidence bands of fitted values. The default value is 0.95. |
lcoef |
a character vector of length 2 with labels of objects including
regression coefficients of component distributions (default |
lcmp |
a character value representing a stub (default |
lcpar |
a character vector with the labels of objects including
constant parameters of component distributions (e.g. the standard
deviation of the normal distribution). The length of |
aldvmm.sefit
calculates standard errors of fitted values using the delta method. Standard
errors of fitted values in the estimation data set are calculated as
,
where
is the gradient of a fitted value with respect to changes of
parameter estimates, and
is the estimated covariance matrix of
parameters (Dowd et al., 2014). Standard errors of predicted values in new
data sets are calculated as
, where
is the
mean squared error of fitted versus observed outcomes in the original
estimation data (Whitmore, 1986). The gradients of fitted values with
respect to parameter estimates are approximated numerically using
jacobian
.
a named numeric vector of standard errors of fitted or predicted
outcomes. The names of the elements in the vector are identical to the row
names of design matrices in 'X'
Whitmore, G. A. (1986). Prediction limits for a univariate
normal observation. The American Statistician, 40(2), 141-143.
https://doi.org/10.1080/00031305.1986.10475378
Dowd, B. E., Greene, W. H., and Norton, E. C. (2014) Computation of standard errors. Health services research, 49(2), 731–750. doi:10.1111/1475-6773.12122
aldvmm.sum
creates a summary table of regression results.
aldvmm.sum(object, digits = max(3L, getOption("digits") - 3L), level = 0.95)
aldvmm.sum(object, digits = max(3L, getOption("digits") - 3L), level = 0.95)
object |
an |
digits |
a numeric value of the number of digits in the reporting table. |
level |
a numeric value of the confidence level. |
a data.frame
object with a summary table of regression results.
aldvmm.tm
creates
a list of up to three "terms" objects, one of the model of component distributions
("beta"
), one of the model of probabilities of component
membership ("delta"
) and one for the full model ("full"
).
aldvmm.tm(mf, Formula, ncmp, lcoef)
aldvmm.tm(mf, Formula, ncmp, lcoef)
mf |
a data frame created by
|
Formula |
an object of class "Formula" created by
|
ncmp |
a numeric value of the number of components that are mixed. The
default value is 2. A value of 1 represents a tobit model with a gap
between 1 and the maximum value in |
lcoef |
a character vector of length 2 with labels of objects including
regression coefficients of component distributions (default |
aldvmm.tm
uses
terms
to create "terms" objects based on a "Formula" object
created by
Formula
and a model frame created by
model.frame
.
The "terms" object for probabilities of group membership is only created if
more than one components are specified in 'ncmp'
.
a named list of objects of class "terms".
beta |
a "terms" object for the model of component distributions. |
delta |
a "terms" object of the multinomial logit model of probabilities of component membership. |
full |
a "terms" object of the full model. |
The method coef.aldvmm
for the generic function
coef
extracts the
vector of coefficients from an object of class "aldvmm".
## S3 method for class 'aldvmm' coef(object, ...)
## S3 method for class 'aldvmm' coef(object, ...)
object |
an object inheriting from class "aldvmm". |
... |
further arguments passed to or from other methods. |
a named numeric vector of parameter estimates.
The method estfun.aldvmm
for the generic function
estfun
calculates the gradient of the aldvmm
log-likelihood using with respect to parameter values for each observation
aldvmm.sc
.
## S3 method for class 'aldvmm' estfun(x, ...)
## S3 method for class 'aldvmm' estfun(x, ...)
x |
an object inheriting from class "aldvmm". |
... |
further arguments passed to or from other methods. |
a numeric matrix of gradients with one row per observation and one column per parameter.
The method formula.aldvmm
for the generic function
formula
returns the
formula object from an object of class "aldvmm".
## S3 method for class 'aldvmm' formula(x, ...)
## S3 method for class 'aldvmm' formula(x, ...)
x |
an object inheriting from class "aldvmm". |
... |
further arguments passed to or from other methods. |
an object of class "formula"
The method
model.matrix.aldvmm
for the generic function model.matrix
extracts a list of model matrices from an object
of class "aldvmm" using the function
aldvmm.mm
.
## S3 method for class 'aldvmm' model.matrix(object, ...)
## S3 method for class 'aldvmm' model.matrix(object, ...)
object |
an object inheriting from class "aldvmm". |
... |
further arguments passed to or from other methods. |
a named list of numeric matrices.
beta |
a numeric design matrix for the model of component distributions. |
delta |
a numeric design matrix of the multinomial logit model of probabilities of component membership. |
The method nobs.aldvmm
for the generic function
nobs
extracts the
number of observations from an object of class "aldvmm".
## S3 method for class 'aldvmm' nobs(object, ...)
## S3 method for class 'aldvmm' nobs(object, ...)
object |
an object inheriting from class "aldvmm". |
... |
further arguments passed to or from other methods. |
a scalar of the number of complete observations.
The method predict.aldvmm
for the generic function
predict
calls
aldvmm.pred
and aldvmm.sefit
to
predict outcomes and their standard errors in new data.
## S3 method for class 'aldvmm' predict( object, newdata = NULL, se.fit = FALSE, type = "pred", level = 0.95, ... )
## S3 method for class 'aldvmm' predict( object, newdata = NULL, se.fit = FALSE, type = "pred", level = 0.95, ... )
object |
an object inheriting from class 'aldvmm'. |
newdata |
a data frame, list or environment (or object coercible to a
data frame by |
se.fit |
an optional logical value indicating whether standard errors
of fitted values are calculated. The default value is |
type |
a character value of either 'fit' or 'pred' indicating whether the standard error of the fit ('fit') or the standard error of predictions in new data ('pred') are calculated. |
level |
a numeric value of the significance level for confidence bands of fitted values. The default value is 0.95. |
... |
further arguments passed to or from other methods. |
a named list of numeric vectors of predicted outcomes, standard errors and confidence or prediction intervals.
The method print.aldvmm
for the generic function
print
prints a
summary of an object of class "aldvmm".
## S3 method for class 'aldvmm' print(x, digits = max(3L, getOption("digits") - 3L), ...)
## S3 method for class 'aldvmm' print(x, digits = max(3L, getOption("digits") - 3L), ...)
x |
an object inheriting from class "aldvmm". |
digits |
an integer value of the number of digits in the printed output. |
... |
further arguments passed to or from other methods. |
The method print.summary.aldvmm
for the generic function
print
prints a
summary of an object of class "summary.aldvmm".
## S3 method for class 'summary.aldvmm' print(x, digits = max(3L, getOption("digits") - 3L), ...)
## S3 method for class 'summary.aldvmm' print(x, digits = max(3L, getOption("digits") - 3L), ...)
x |
an object inheriting from class 'summary.aldvmm'. |
digits |
an integer value of the number of digits in the output table. |
... |
further arguments passed to or from other methods. |
The method residuals.aldvmm
for the generic function
residuals
returns the
covariance matrix from an object of class "aldvmm".
## S3 method for class 'aldvmm' residuals(object, ...)
## S3 method for class 'aldvmm' residuals(object, ...)
object |
an object inheriting from class "aldvmm". |
... |
further arguments passed to or from other methods. |
a numeric vector of residuals.
The method summary.aldvmm
for the generic function
summary
creates
an object of class "summary.aldvmm" including key results from an object of
class "aldvmm".
## S3 method for class 'aldvmm' summary(object, digits = max(3L, getOption("digits") - 3L), level = 0.95, ...)
## S3 method for class 'aldvmm' summary(object, digits = max(3L, getOption("digits") - 3L), level = 0.95, ...)
object |
an object inheriting from class 'aldvmm'. |
digits |
an integer value of the number of digits in the output table. |
level |
a numeric value of the confidence interval between 0 and 1. |
... |
further arguments passed to or from other methods. |
summary.aldvmm
returns an object of class "summary.aldvmm"
including the following elements.
call |
a character value including the model call captured by
|
summary |
a data frame generated by
|
terms |
a list of objects of class
|
contrasts |
a nested list of character values showing contrasts of factors used in models of component means ("beta") and probabilities of component membership ("delta"). |
coef |
a numeric vector of parameter estimates. |
cov |
a numeric matrix object with covariances of parameters. |
n |
a scalar representing the number of complete observations with no missing values that were used in the estimation. |
df.residual |
an integer value of the residual degrees of freedom. |
df.null |
an integer value of the residual degrees of freedom of a null model including intercepts and standard errors. |
iter |
an integer value of the number of iterations used in optimization. |
ll |
a numeric value of the negative log-likelihood
|
aic |
a numeric value of the Akaike information
criterion |
bic |
a numeric value of the Bayesian information criterion
|
k |
a numeric value of the number of components. |
lcoef |
a character vector of labels for objects including
results on distributions (default |
lcpar |
a
character vector of labels for objects including constant distribution
parameters (default |
lcmp |
a character value of the label for objects including results on different components (default "Comp") |
lvar |
a
list including 2 character vectors of covariate names for model parameters
of distributions ( |
The method terms.aldvmm
for the generic function
terms
returns the
terms object for the combined model of component means and probabilities of
component membership from an object of class "aldvmm".
## S3 method for class 'aldvmm' terms(x, ...)
## S3 method for class 'aldvmm' terms(x, ...)
x |
an object inheriting from class "aldvmm". |
... |
further arguments passed to or from other methods. |
an object of class "terms"
The method update.aldvmm
for the generic function
update
re-estimates an object of class "aldvmm".
## S3 method for class 'aldvmm' update(object, formula., ..., evaluate = TRUE)
## S3 method for class 'aldvmm' update(object, formula., ..., evaluate = TRUE)
object |
an object inheriting from class "aldvmm". |
formula. |
a formula object representing the new model. |
... |
further arguments passed to or from other methods. |
evaluate |
a logical value indicating if the model should be re-estimated (TRUE) or not (FALSE). |
an object of class "aldvmm"
utility
is
a simulated data frame including health state utilities and patients' age
and sex.
utility
utility
A data frame with 200 rows and 3 variables:
utility |
a utility value {[-0.594, 0.883], 1}. |
age |
Age in years. |
female |
Indicator of female sex. |
set.seed(101010101) utility <- data.frame(female = rbinom(size = 1, n = 200, p = 0.6)) utility[, 'age'] <- stats::rnorm(n = 200, mean = 50 + utility$female*10, sd = 15) utility[1:50, 'eq5d'] <- stats::rnorm(n = 50, mean = 0 - 0.1 * utility[1:50, 'female'] + 0.0005 * utility[1:50, 'age'], sd = 0.1) utility[51:200, 'eq5d'] <- stats::rnorm(n = 150, mean = 0.5 + 0.1 * utility[51:200, 'female'] + 0.0001*utility[51:200, 'age'], sd = 0.2) utility[utility$eq5d<(-0.594), 'eq5d'] <- -0.594 utility[utility$eq5d>0.883, 'eq5d'] <- 1 hist(utility$eq5d, breaks = 50)
set.seed(101010101) utility <- data.frame(female = rbinom(size = 1, n = 200, p = 0.6)) utility[, 'age'] <- stats::rnorm(n = 200, mean = 50 + utility$female*10, sd = 15) utility[1:50, 'eq5d'] <- stats::rnorm(n = 50, mean = 0 - 0.1 * utility[1:50, 'female'] + 0.0005 * utility[1:50, 'age'], sd = 0.1) utility[51:200, 'eq5d'] <- stats::rnorm(n = 150, mean = 0.5 + 0.1 * utility[51:200, 'female'] + 0.0001*utility[51:200, 'age'], sd = 0.2) utility[utility$eq5d<(-0.594), 'eq5d'] <- -0.594 utility[utility$eq5d>0.883, 'eq5d'] <- 1 hist(utility$eq5d, breaks = 50)
The method vcov.aldvmm
for the generic function
vcov
returns the
covariance matrix from an object of class "aldvmm".
## S3 method for class 'aldvmm' vcov(object, ...)
## S3 method for class 'aldvmm' vcov(object, ...)
object |
an object inheriting from class "aldvmm". |
... |
further arguments passed to or from other methods. |
a numeric matrix.