Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/testConstraints.R

Performs hypothesis tests for arbitrary functions of the model parameters using the Delta method.

1 2 | ```
testConstraints(model, qhat, uhat, constraints, method = c("D1", "D2"),
ariv = c("default", "positive"), df.com = NULL)
``` |

`model` |
A list of fitted statistical models as produced by |

`qhat` |
A matrix or list containing the point estimates of the parameters for each imputed data set (see 'Details'). |

`uhat` |
An array or list containing the variance-covariance matrix of the parameters for each imputed data set (see 'Details'). |

`constraints` |
A character vector specifying constraints or functions of the vector of model parameters to be tested (see 'Details'). |

`method` |
A character string denoting the method by which the test is performed. Can be |

`ariv` |
A character string denoting how the ARIV is calculated. Can be |

`df.com` |
(optional) A single number or a numeric vector denoting the complete-data degrees of freedom for the hypothesis test (see 'Details'). Only used if |

This function performs tests of arbitrary functions (or constraints) of the model parameters using similar methods as `testModels`

.
The function relies on the Delta method (e.g., Casella & Berger, 2002) for testing functions of the parameters and assumes that their sampling distribution is approximately normal.
The parameters can either be extracted automatically from the fitted statistical models (`model`

) or provided manually as matrices, arrays, or lists (`qhat`

and `uhat`

, see 'Examples').

Constraints and other functions of the model parameters are specified in the `constraints`

argument.
The constraints must be supplied as a character vector, where each string denotes a function or a constraint to be tested (see 'Examples').

The Wald-like tests that are carried out by `testConstraints`

are pooled across the imputed data sets with the *D_1* (Li, Raghunathan & Rubin, 1991) or *D_2* (Li, Meng, Raghunathan & Rubin, 1991) method, where *D_1* operates on the constrained point and variance estimates, and *D_2* operates on the Wald-statistics (for additional details, see `testModels`

).
The pooled estimates and standard errors reported in the output are always based on *D_1*.

For *D_1*, the complete-data degrees of freedom can be adjusted for smaller samples by specifying `df.com`

(see `testModels`

).

This function supports general statistical models that define `coef`

and `vcov`

methods (e.g., `lm`

, `glm`

, `lavaan`

and others) as well as multilevel models estimated with `lme4`

or `nlme`

and GEEs estimated with `geepack`

.
The arguments `qhat`

and `uhat`

provide a general method for pooling parameter estimates regardless of model type (see 'Examples').
Support for further models may be added in future releases.

The `ariv`

argument determines how the average relative increase in variance (ARIV) is calculated (see `testModels`

).
If `ariv = "default"`

, the default estimators are used.
If `ariv = "positive"`

, the default estimators are used but constrained to take on strictly positive values.

A list containing the results of the model comparison.
A `print`

method is used for more readable output.

Simon Grund

Casella, G., & Berger, R. L. (2002). *Statistical inference (2nd. Ed.)*. Pacific Grove, CA: Duxbury.

Li, K.-H., Meng, X.-L., Raghunathan, T. E., & Rubin, D. B. (1991). Significance levels from repeated p-values with multiply-imputed data. *Statistica Sinica, 1*, 65-92.

Li, K. H., Raghunathan, T. E., & Rubin, D. B. (1991). Large-sample significance levels from multiply imputed data using moment-based statistics and an F reference distribution. *Journal of the American Statistical Association, 86*, 1065-1073.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | ```
data(studentratings)
fml <- MathDis + ReadDis + SchClimate ~ (1|ID)
imp <- panImpute(studentratings, formula = fml, n.burn = 1000, n.iter = 100, m = 5)
implist <- mitmlComplete(imp)
# fit simple regression model
fit.lm <- with(implist, lm(SchClimate ~ ReadDis + MathDis))
# apply Rubin's rules
testEstimates(fit.lm)
# * Example 1: test 'identity' function of two parameters (automatic)
# test equivalent to model comparison with a restricted model (without 'ReadDis'
# and 'MathDis')
cons <- c("ReadDis", "MathDis")
testConstraints(fit.lm, constraints = cons)
# ... adjusting for finite samples
testConstraints(fit.lm, constraints = cons, df.com = 749)
# ... using D2
testConstraints(fit.lm, constraints = cons, method = "D2")
# * Example 2: test for equality of two parameters
# tests the hypothesis that the coefficients pertaining to 'ReadDis' and 'MathDis'
# are equal (ReadDis = MathDis)
cons <- c("ReadDis-MathDis")
testConstraints(fit.lm, constraints = cons)
# * Example 3: test against a fixed value
# tests the hypothesis that the coefficient of "ReadDis" is equal to one
# (i.e., 'ReadDis' - 1 == 0)
cons <- c("ReadDis-1")
testConstraints(fit.lm, constraints = cons)
# * Example 4: test 'identity' function of two parameters (qhat, uhat)
fit.lm <- with(implist, lm(SchClimate ~ ReadDis + MathDis))
qhat <- sapply(fit.lm, coef)
uhat <- sapply(fit.lm, function(x) vcov(x), simplify = "array")
cons <- c("ReadDis", "MathDis")
testConstraints(qhat = qhat, uhat = uhat, constraints = cons)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.