jmdem.sim {jmdem} | R Documentation |
Simulate joint mean and dispersion effects models fits
Description
Simulate iterative jmdem
fits on user-defined model settings
Usage
jmdem.sim(mformula = "y ~ 1 + x", dformula = "~ 1 + z", data = NULL,
beta.true, lambda.true, mfamily = gaussian,
dfamily = Gamma, dev.type = c("deviance", "pearson"),
x.str = list(type = "numeric", random.func = "runif", param = list()),
z.str = list(type = "numeric", random.func = "runif", param = list()),
n = NULL, simnum = NULL, trace = FALSE, asymp.test = FALSE,
weights = NULL, moffset = NULL, doffset = NULL,
mustart = NULL, phistart = NULL, betastart = NULL,
lambdastart = NULL, hessian = TRUE, na.action,
grad.func = TRUE, fit.method = "jmdem.fit",
method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN", "Brent"),
df.adj = FALSE, disp.adj = FALSE, full.loglik = FALSE,
mcontrasts = NULL, dcontrasts = NULL, beta.first = TRUE,
prefit = TRUE, control = list(...),
minv.method = c("solve", "chol2inv", "ginv"), ...)
simdata.jmdem.sim(mformula = "y ~ 1 + x", dformula = "~ 1 + z", beta.true, lambda.true,
x.str = list(type = "numeric", random.func = "runif", param = list()),
z.str = list(type = "numeric", random.func = "runif", param = list()),
mfamily = gaussian, dfamily = Gamma, weights = NULL, n, simnum = 1,
moffset = NULL, doffset = NULL)
getdata.jmdem.sim(object)
Arguments
mformula |
the user-defined true mean submodel, expressed in form of an object of class " |
dformula |
the user-defined true dispersion submodel. See |
data |
an optional data frame or list of several data frames. If no data are provided, |
beta.true |
a vector of the true parameter values of the mean submodel. The number of elements in |
lambda.true |
a vector of the true parameter values of the dispersion submodel. The number of elements in |
mfamily |
a description of the error distribution and link function to be used in the mean submodel. This can be a character string naming a family function, a family function or the result of a call to a family function. (See |
dfamily |
a description of the error distribution and link function to be used in the dispersion submodel. (Also see |
dev.type |
a specification of the type of residuals to be used as the response of the dispersion submodel. The ML estimates of the jmdem are the optima of either the quasi-likelihood function for deviance residuals, or the pseudo-likelihood function for Pearson residuals. |
x.str |
a list of user-specified structure for the generation of the mean submodel design matrix, including the |
z.str |
a list of user-specified structure for the generation of the dispersion submodel design matrix, including the |
n |
a numeric value specifying the sample size in each simulation. |
simnum |
a numeric value specifying the number of simulations. |
trace |
a specification whether the estimated coefficients should be printed to screen after each simulation. |
asymp.test |
a specification whether the Rao's score and Wald tests should be conducted for each simulation. |
... |
for |
The following arguments are used for JMDEM fitting. See jmdem
for details.
weights |
an optional vector of 'prior weights' to be used in the fitting process. Should be |
moffset |
an a priori known component to be included in the linear predictor of the mean submodel during fitting. This should be NULL or a numeric vector of length equal to the number of cases. One or more offset terms can be included in the formula instead or as well, and if more than one is specified their sum is used. See |
doffset |
an a priori known component to be included in the linear predictor of the dispersion submodel during fitting. See |
mustart |
a vector of starting values of individual means. |
phistart |
a vector of starting values of individual dispersion. |
betastart |
a vector of starting values for the regression parameters of the mean submodel. |
lambdastart |
a vector of starting values for the regression parameters of the dispersion submodel. |
hessian |
the method used to compute the information matrix. Hessian matrix will be calculated for |
na.action |
a function which indicates what should happen when the data contain |
grad.func |
the gradient function will be included in the optimisation for the " For the " |
fit.method |
the method to be used in fitting the model. The default method " User-supplied fitting functions can be supplied either as a function or a character string naming a function, with a function which takes the same arguments as |
method |
the method to be used for the optimisation. See |
df.adj |
an adjustment factor for the degrees of freedom |
disp.adj |
an adjustment factor for the dispersion weight will be multiplied to the estimated dispersion parameter during the optimisation for |
full.loglik |
the full likelihood function instead of the quasi- or pseudo-likelihood function will be used for the optimisation for |
mcontrasts |
an optional list for the mean effect constrasts. See the |
dcontrasts |
an optional list for the dispersion effect constrasts. See the |
beta.first |
the mean effects will be estimated (assuming constant sample dispersion) at the initial stage for |
prefit |
a specfication whether |
control |
a list of parameters for controlling the fitting process. For |
minv.method |
the method used to invert matrices during the estimation process. " |
object |
one or several objects of class |
Details
jmdem.sim
simulates the fitting of datasets in which the regressors of the mean and dispersion submodels are generated according to the specification given in x.str
and z.str
. The response variable will be then generated according to the distribution specified in mfamily
with linear predictor of the mean given by mformula
and the linear predictor of the dispersion given by dformula
.
The specifications in x.str
and z.str
are rather flexible if more than one independent variables are included in any of the submodels. For instance, if one of the two independent variables of the mean submodel is numeric generated from the normal distribution of mean 0 and standard deviation 1, and the other one is a 4-level factor {0, 1, 2, 3}
generated from the uniform distribution, then they can be specified in a vector using c(...)
, such as: x.str = list(type = c("numeric", "factor"), random.func = c("rnorm", "runif"), param = c(list(mean = 0, sd = 1), list(min = 0, max = 3)))
.
Note that the higher the number of simulations specified in simnum
, the more stabilised are the aggregated simulation results. The larger the sample size in each simulation, the less fluctuated are the estimated results among the simulations.
Users gain simdata.jmdem.sim
higher control on the simulation by generating a number of datasets upon their own settings first, and not running jmdem.sim
at the same time. By taking these steps, users also have the flexiblility to edit the datasets according their own individual requirements, before calling them in jmdem.sim
.
Users can also extract the datasets used in jmdem.sim
by getdata.jmdem.sim
. This function is useful if the datasets are generated in jmdem.sim
where users do not have access prior to the simulations.
getdata.jmdem.sim
and simdata.jmdem.sim
can also be useful if the users would like to conduct various simulations with different jmdem
settings on the same data.
Value
An object of class jmdem.sim
contains of a list of jmdem
fits with full model information. That means, each element of the jmdem.sim
object contains the same attributes as a jmdem
object. See values of jmdem
for details.
Author(s)
Karl Wu Ka Yui (karlwuky@suss.edu.sg)
See Also
Examples
## Run 10 JMDEM simulations with samples of size 50. The response
## variable is Gaussian with mean beta_0 + beta_1 * x and variance
## log(sigma^2) = lambda_0 + lambda_1 * z. The observations of
## the predictor x should be random numbers generated from the normal
## distribution with mean 0 and standard deviation 2. The observations
## of z are factors with three levels between 0 and 2, generated from
## the uniform distribution. The true values of the mean submodel's
## intercept and slope are 1.5 and 4, as well as 2.5, 3 and -0.2 for
## the dispersion submodel's intercept and slope.
sim <- jmdem.sim(mformula = y ~ x, dformula = ~ z, beta.first = TRUE,
mfamily = gaussian, dfamily = Gamma(link = "log"),
x.str = list(type = "numeric", random.func = "rnorm",
param = list(mean = 0, sd = 2)),
z.str = list(type = "factor", random.func = "runif",
param = list(min = 0, max = 2)),
beta.true = c(1.5, 4), lambda.true = c(2.5, 3, -0.2),
grad.func = TRUE, method = "BFGS", n = 50,
simnum = 10)