File: RFratiotest.Rd

package info (click to toggle)
r-cran-randomfields 3.3.14-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,916 kB
  • sloc: cpp: 52,159; ansic: 3,015; makefile: 2; sh: 1
file content (153 lines) | stat: -rw-r--r-- 4,997 bytes parent folder | download | duplicates (2)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
\name{RFratiotest}
\alias{RFratiotest}
\alias{print.RFratiotest}
\title{Likelihood ratio test}
\description{
  The function performs an approximate chi2 test or
  a Monte Carlo likelihood ratio test
  based on \command{\link{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, methods,
            sub.methods, optim.control = NULL, users.guess = NULL,
            distances = NULL, dim, transform = NULL, ...)
}
\arguments{  
  \item{nullmodel, alternative}{See Details.
     
    The set of parameters 
    to be estimated for \code{nullmodel}
    should be a subset of the parameters to be estimated for
    \code{alternative} if \code{alternative} is given.
  }
  \item{alpha}{value in [0,1] or missing. Significance level.
  }
  \item{n}{integer. The test is based on \code{n-1} simulations.}
 \item{seed}{integer. If not \code{NULL} and not \code{NA}, the
   \link[base]{.Random.seed} is set to \code{seed}. Otherwise,
   \command{\link[base]{set.seed}} is set to the value of 
   \code{RFoptions{}$basic$seed}
   if the latter is not \code{NA}.
 }
 \item{x}{\argX}
 \item{y,z}{\argYz}
 \item{T}{\argT}
 \item{grid}{\argGrid}
 \item{data}{\argData}
 \item{lower}{\argLower}
 \item{upper}{\argUpper}
 \item{methods}{\argFitmethods} 
 \item{sub.methods}{\argFitsubmethods See \link{RFfit} for details.}
 \item{users.guess}{\argUsersguess}
 \item{distances,dim}{\argDistances}
 \item{optim.control}{\argOptimcontrol}
 \item{transform}{\argTransform}
 \item{...}{\argDots}
}

\note{
  An important \command{\link{RFoptions}} is \code{ratiotest_approx}.
}

\details{
  \code{nullmodel} (and the \code{alternative}) can be
  \itemize{
    \item
    a covariance model, see \command{\link{RMmodel}} or
    type \code{\link{RFgetModelNames}(type="variogram")} to get all options.

    If \command{\link{RFoptions}}
    \code{ratiotest_approx} is \code{TRUE} the chisq approximation is performed. Otherwise 
    a Monte Carlo ratio test is performed.
    \item
    \code{\link[=RFfit-class]{RFfit}} or
    \code{\link[=RMmodelFit-class]{RMmodelFit}}

    Here, a chisq approximative test is always performed on the
    already fitted models.
  }
  
  \command{RFratiotest} tries to detect whether
  \code{nullmodel} is a submodel of \code{alternative}.
  If it fails,
  \itemize{
    \item a message is printed that says that an
    \emph{automatic} detection has not been possible;
    \item it is not guaranteed anymore that the \code{alternative} model
    returns a (log) likelihood that is at least as large as
    that of the \code{nullmodel},
    even if \code{nullmodel} is a submodel of \code{alternative}.
    This is due to numerical optimisation which is never perfect.       
  }
  Otherwise it is guaranteed that the \code{alternative} model has
  a (log) likelihood that is at least as large as that of the \code{nullmodel}.
}

\note{
  Note that the likelihood ratio test may take a huge amount of time.
}

\section{Methods}{
 \describe{
   \item{print}{prints the summary}
   \item{summary}{gives a summary}
 }
}


\value{
  The test returns a message whether the null hypothesis, i.e. the
  smaller model is accepted.
  Invisibly, a list that also contains
  \itemize{
    \item \code{p}, the \eqn{p}-value
    \item \code{n}
    \item \code{data.ratio} the log ratio for the data
    \item \code{simu.ratio} the log ratio for the simulations
    \item \code{data.fit} the models fitted to the data
    \item \code{msg} the message that is also directly returned
  }
  It has S3 class \code{"RFratiotest"}.
}

\me

\note{This function does not depend on the value of
 \command{\link{RFoptions}}\code{()$PracticalRange}. The function \command{RFratiotest} always uses the standard specification
 of the covariance model as given in \command{\link{RMmodel}}.
}
\seealso{
  \command{\link{RFfit}},
 \command{\link{RMmodel}},
 \code{\link[=RandomFields-package]{RandomFields}},
 \command{\link{weather}}.
}

\examples{\dontshow{StartExample()}
\dontshow{\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")
}}

\dontshow{FinalizeExample()}}

\keyword{spatial}
\keyword{htest}