# qleTest: Monte Carlo testing In mbaaske/qle: Simulation-Based Quasi-Likelihood Estimation

## Description

Monte Carlo hypothesis testing

## Usage

 1 2 3 qleTest(est, local = NULL, sim, ..., nsim = 100, obs = NULL, check.root = FALSE, alpha = 0.05, na.rm = TRUE, cl = NULL, iseed = NULL, verbose = FALSE) 

## Arguments

 est object of class qle, the estimation results from function qle local optional, object of class QSResult, NULL (default), local estimation results sim user supplied simulation function (see qle) ... arguments passed to the simulation function 'sim' nsim number of model replications to generate the simulated statistics obs optional, NULL (default), simulated statistics at the hypothesized parameter check.root logical, FALSE (default), whether to check consistency of estimated parameter (see checkMultRoot) alpha significance level for testing the hypothesis na.rm logical, TRUE (default), whether to remove 'NA' values from the matrix of re-estimated parameters cl cluster object, NULL (default), of class "MPIcluster", "SOCKcluster", "cluster" iseed integer, the seed for initializing the cluster workers for parallel computations verbose logical, TRUE for intermediate output

## Details

The function tests the null hypothesis H_0:\,\hat{θ}=θ_0, that is, whether the statistical model w.r.t. to the estimated parameter is true, against the alternative H_1:\,\hat{θ}\neqθ_0 by testing based on a Monte Carlo approach (see vignette). Due to the approximate nature of the assumed statistical model for the observed data the exact distribution of the test statistics, that is, the Mahalanobis distance or quasi-deviance, is generally unknown and therefore its asymptotic distribution might be an unrealistic assumption for the null hypothesis. For this reason, and in order to retrieve an empirical P-value for testing, we generate (pseudo-)observations from the outcome of the model replications and re-estimate the model parameter for each realization in the same way as done before when estimating the model parameter. This includes all possible types of variance approximations (by kriging or average approximation) and types of prediction variance (kriging or the CV-based variance).

The function expects an estimation result as returned from qle. If any generated observations are readily available at the final parameter estimate, then these can be passed by 'obs'. Otherwise the function first generates those using 'nsim' model replications at the estimated parameter as part of 'est' or 'local'. The criterion function approximations are used as it (specified in the object 'qsd') and will not be further improved by additional samples during the test. The value of the test statistic is either chosen as the current criterion function value in 'OPT' (see argument 'criterion' in getQLmodel) or is taken from the optional argument 'local'. Given the local results 'local' of class QSResult, the user can also select a different criterion function as a test statistic than before when estimating the parameter itself. Apart from the quasi-deviance as a test statistic, in principle, any supported type of a least squares criterion, more generally, the Mahalanobis distance, can be used depending on the prefered type of variance matrix approximation, see covarTx. Practically, the re-estimations might fail to converge, however, then the user can control the convergence conditions of the local solvers (including quasi-scoring) by the corresponding control parameters (see searchMinimizer). Any failed re-estimations are excluded from the test results and stored in the attribute 'info'. In addition, as part of the returned data frame 'param' the empirical standard error, predicted standard error (based on the average inverse quasi-information matrix), the root mean square error, the bias and sample mean value of the re-estimated parameters are also available.

For an example please see the package vignette.

## Value

An object of class qleTest as a list of:

 param data frame of estimated parameters and error measures test the test result Stest name of the test

and attributes:

 msem mean square error matrix of re-estimated parameters aiqm average inverse quasi-information matrix over all re-estimated parameters qi inverse quasi-information matrix at the parameter to be tested 'est\$par' relED relative difference of the empirial and predicted standard error of the parameter to be tested obs list of simulated observed statistics optRes results from re-estimating the model parameters for each simulated observation from 'obs' mean.score average quasi-score, respectively, average gradient of the MD at the re-estimated parameters criterion always equal to "qle" solInfo results of the numerical consistency checks for each re-estimated parameter info list of indices of re-estimation results where the inversion of the quasi-information matrix failed, the re-estimated parameters have NA values, criterion function minimizations have errors or did not converge numerically, the integer seed value 'iseed'