Skip to contents

The primary estimation function for conducting the optimization. The function is typically called through the mars function, but can be called here directly.

Usage

estimation(
  formula = NULL,
  scale_formula = NULL,
  effect_name = NULL,
  studyID = NULL,
  effectID = NULL,
  variance = NULL,
  data,
  estimation_method = "REML",
  optim_method = "L-BFGS-B",
  structure = "UN",
  varcov_type,
  weights = NULL,
  intercept = FALSE,
  N = NULL,
  missing = "remove",
  robustID = NULL,
  robust_args = list(),
  unique_n = NULL,
  lasso = FALSE,
  lasso_args = list(lambda_grid = 10^seq(1, -3, length.out = 5), K = 5, all_lasso_metrics
    = FALSE, lambda_tolerance = 0),
  multivariate_covs = NULL,
  tau2 = NULL,
  tol = 1e-10,
  control = list(maxit = 1000L),
  vcov_method = c("gls", "observed"),
  ...
)

Arguments

formula

The formula used for specifying the fixed and random structure. Used for univariate and multilevel structures.

scale_formula

Optional one-sided formula for modeling the log-heterogeneity in location-scale models. Currently supported for structure = "univariate" and structure = "multilevel". For multilevel models, this can be either a single one-sided formula applied to every random-effect component or a list of one-sided formulas aligned to the random-effect components. Multilevel scale predictors must be invariant within the top-level studyID cluster.

effect_name

Character string representing the name of the effect size column in the data.

studyID

Character string representing the study ID

effectID

Character string representing the effect size ID

variance

Character string representing the name of the variance of the effect size in the data.

data

Data used for analysis

estimation_method

Type of estimation used, either "REML" or "MLE", REML is the default

optim_method

Optimization method that is passed to the optim function. Default is 'L-BFGS-B'.

structure

Between studies covariance structure, default is "UN" or unstructured. See details for more specifics.

varcov_type

Type of variance covariance matrix computed. Default is 'cor_weighted' for correlations or 'smd_outcome' for standardized mean differences.

weights

User specified matrix of weights.

intercept

Whether a model intercept should be specified, default is FALSE meaning no intercept. See details for more information.

N

Character string representing the sample size of the studies.

missing

What to do with missing data. Use "remove" to drop incomplete rows, "keep" to keep rows as-is, or "em" to impute missing moderator values via a multivariate-normal EM routine before dropping any remaining incomplete rows. Only continuous missing moderators are supported. Repeated studies require study-level invariant moderators. Single completion does not propagate imputation uncertainty; a warning and metadata flag identify conditional inference.

robustID

A character vector specifying the cluster group to use for computing the robust standard errors.

robust_args

Named list controlling robust covariance and inference. Supported entries include type, inference, joint_test, target, level, fallback, and tol.

unique_n

A numeric vector of unique sample sizes, calculated internally.

lasso

TRUE/FALSE indicator that specifies if lasso results are returned. TRUE means lasso results will be run, if number of predictors is less than number of effect sizes, both lasso and non-lasso results will be returned, if number of predictors is equal to or greater than the number of effect sizes, the lasso results will only be returned.

lasso_args

A list of LASSO specific arguments. lambda_tolerance controls tie-breaking across lambda values by choosing the smaller lambda when CV metrics are within this tolerance.

multivariate_covs

A one-sided formula to specify the covariates used in a multivariate analysis.

tau2

Optional user-supplied between-study variance or covariance. If NULL, heterogeneity is estimated. For univariate models, supply one non-negative value. For multilevel models, supply one non-negative value per random-effect component. For multivariate DIAG2 models, supply one common value; for DIAG1, one value per outcome; and for UN, a positive semidefinite covariance matrix.

tol

Tolerance for estimating, passed to optim

control

Named ordinary-optimizer controls. The default allows 1000 iterations. For example, list(maxit=2000) increases that allowance. An explicit control$factr overrides tol. Nonconvergence emits a warning and is printed in summaries; downstream correlation synthesis rejects it.

vcov_method

Model-based coefficient covariance: "gls" (default) uses conditional GLS/expected information; "observed" uses the coefficient block of the inverse full observed ML information. Observed information requires a converged ML fit and a positive-definite full Hessian, and is withheld at heterogeneity boundaries. With supplied fixed tau2, both methods use the conditional coefficient covariance. This choice is retained for summaries, Wald intervals/tests and downstream correlation/CFA models. Cluster-robust covariance remains a separate inference choice.

...

Additional arguments to pass to optim.

Value

Output is a named list; The output returns the estimated parameters, fit statistics, estimation inputs. For multivariate fits, QE$components contains marginal homogeneity tests for each outcome, fitted separately using its sampling covariance. These tests do not generally sum to the joint Q. QE$joint_contributions allocates the joint Q by outcome as sums of \(r \odot (S^{-1}r)\); these contributions can be negative and have no separate chi-square test. Both are data frames that can be exported with utils::write.csv().

References

Harville, D. A. (1977). Maximum likelihood approaches to variance component estimation and to related problems. Journal of the American Statistical Association, 72(358), 320–338. doi:10.1080/01621459.1977.10480998 .

Patterson, H. D., and Thompson, R. (1971). Recovery of inter-block information when block sizes are unequal. Biometrika, 58(3), 545–554. doi:10.1093/biomet/58.3.545 .

Examples

# \donttest{
fit <- estimation(
  formula = yi ~ 1,
  effect_name = "yi",
  studyID = "study",
  variance = "vi",
  data = teacher_expectancy,
  structure = "univariate",
  varcov_type = "univariate"
)
fit$coefficients
#> NULL
# }