Learn R Programming

RandomFields (version 3.0.10)

RFratiotest: Likelihood ratio test

Description

The function performs 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, data,
alpha=0.05, 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
covariance model, see RMmodel or type RFgetModelNames() to get all options.

The set of parameters to estimate for nullmodel

alpha
value in [0,1]. 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

Details

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
{RFoptions(modus_operandi="sloppy")
}

RFoptions(seed=0)

## see also ?soil
data(soil)
str(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))

test <- RFratiotest(submodel, model, data=soil["moisture"], n=20)
str(test)

{RFoptions(modus_operandi="normal")
}

RFoptions(seed=NA)

Run the code above in your browser using DataLab