Learn R Programming

RandomFields (version 3.0.5)

RFratiotest: Likelihood ratio test

Description

The function performs an approximate $$chi^2$ test or a Monte Carlo likelihood ratio test based on fitgauss. Currently it only works for Gaussian random fields.

Usage

RFratiotest(nullmodel, alternative, x, y = NULL, z = NULL, T = NULL,
grid=NULL, data,
alpha, n = 5 / alpha, seed = 0, 
lower = NULL, upper = NULL, bc_lambda, methods,
sub.methods, optim.control = NULL, users.guess = NULL,
distances = NULL, dim, transform = NULL, ...)

Arguments

nullmodel, alternative
See Details. The set of parameters to be estimated for nullmodel should be a subset of the parameters to be estimated for alternative if alternative is given.
alpha
value in [0,1] or missing. Significance level.
n
integer. The test is based on n-1 simulations.
seed
integer. If not NULL and not NA, the .Random.seed is set to seed. Otherwise, set.seed is set to the value
x, y, z, T, grid, data, lower, upper, bc_lambda, methods, sub.methods, optim.control, users.guess, distances, dim, transform, ...
see RFfit

Value

  • The test returns a message whether the null hypothesis, i.e. the smaller model is accepted. Invisibly, a list that also contains
    • p, the$p$-value
    • n
    • data.ratiothe log ratio for the data
    • simu.ratiothe log ratio for the simulations
    • data.fitthe models fitted to the data
    • msgthe message that is also directly returned
    It has S3 class "RFratiotest".

Details

nullmodel (and the alternative) can be
  • a covariance model, seeRMmodelor typeRFgetModelNames(type="negative")to get all options.

    Depending weather theRFoptionsratiotest_approxis TRUE the the chisq approximation is performed. Otherwise a Monte Carlo ratio test is performed.

  • RFfitorRMmodelFitHere, a chisq approximative test is always performed on the already fitted models.
RFratiotest tries to detect whether nullmodel is a submodel of alternative. If it fails,
  • a message is printed that says that anautomaticdetection has not been possible;
  • it is not guaranteed anymore that thealternativemodel returns a (log) likelihood that is at least as large as that of thenullmodel, even ifnullmodelis a submodel ofalternative. This is due to numerical optimisation which is never perfect.
Otherwise it is guaranteed that the alternative model has a (log) likelihood that is at least as large as that of the nullmodel.

See Also

RFfit RMmodel, RandomFields, weather.

Examples

Run this code
\dontrun{
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set
##                   RFoptions(seed=NA) to make them all random again

data(soil)  ## see also ?soil
soil <- RFspatialPointsDataFrame(
 coords = soil[, c("x.coord", "y.coord")],
 data = soil[, c("moisture", "NO3.N", "Total.N",
 "NH4.N", "DOC", "N20N")],
 RFparams=list(vdim=6, n=1)
 )

model <- ~1 + RMplus(RMwhittle(scale=NA, var=NA, nu=NA), RMnugget(var=NA))
submodel <- ~1 + RMplus(RMwhittle(scale=NA, var=NA, nu=NA), RMnugget(var=0))

RFratiotest(submodel, model, data=soil["moisture"],
            modus_operandi="sloppy")
}

FinalizeExample()

Run the code above in your browser using DataLab