`RFloglikelihood`

returns the log likelihood for Gaussian
random fields. In case NAs are given that refer to linear modeling, the
ML of the linear model is returned.

1 2 3 |

`model` |
object of class |

`x` |
vector or |

`y` |
second vector or matrix for non-stationary covariance functions |

`z` |
z-component of point if xyzT-specification of points is used |

`T` |
T-component of point if xyzT-specification of points is used |

`grid` |
boolean; whether xyzT specify a grid |

`data` |
vector or matrix of values measured at If an |

`distances` |
vector;
the lower triangular part of the distance matrix column-wise;
equivalently the upper triangular part of the distance matrix row-wise;
either |

`dim` |
dimension of the coordinate space in which the model is
applied; only necesary for given |

`likelihood` |
not programmed yet. Character.
choice of kind of likehood ("full", "composite", etc.),
see also |

`estimate_variance` |
logical or |

`...` |
for advanced
further options and control arguments for the simulation
that are passed to and processed by |

The function calculates the likelihood for data of a Gassian process
with given covariance structure.
The covariance structure may not have `NA`

values in the
parameters except for a global variance. In this case the variance
is returned that maximizes the likelihood.
Additional to the covariance structure the model may include a
trend. The latter may contain unknown linear parameters.
In this case again, the unknown parameters are estimated, and returned.

`RFloglikelihood`

returns a list
containing the likelihood, the log likelihood, and
the global variance (if estimated – see details).

Martin Schlather, schlather@math.uni-mannheim.de http://ms.math.uni-mannheim.de/de/publications/software

Bayesian,
`RMmodel`

,
`RFfit`

,
`RFsimulate`

,
`RFlinearpart`

.

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 | ```
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set
## RFoptions(seed=NA) to make them all random again
require("mvtnorm")
pts <- 5
repet <- 3
model <- RMexp()
x <- runif(n=pts, min=-1, max=1)
y <- runif(n=pts, min=-1, max=1)
data <- as.matrix(RFsimulate(model, x=x, y=y, n=repet, spC = FALSE))
print(cbind(x, y, data))
print(system.time(likeli <- RFlikelihood(model, x, y, data=data)))
str(likeli, digits=8)
L <- 0
C <- RFcovmatrix(model, x, y)
for (i in 1:ncol(data)) {
print(system.time(dn <- dmvnorm(data[,i], mean=rep(0, nrow(data)),
sigma=C, log=TRUE)))
L <- L + dn
}
print(L)
stopifnot(all.equal(likeli$log, L))
pts <- 5
repet <- 1
trend <- 2 * sin(R.p(new="isotropic")) + 3
#trend <- RMtrend(mean=0)
model <- 2 * RMexp() + trend
x <- seq(0, pi, len=10)
data <- as.matrix(RFsimulate(model, x=x, n=repet, spC = FALSE))
print(cbind(x, y, data))
print(system.time(likeli <- RFlikelihood(model, x, data=data)))
str(likeli, digits=8)
L <- 0
tr <- RFfctn(trend, x=x, spC = FALSE)
C <- RFcovmatrix(model, x)
for (i in 1:ncol(data)) {
print(system.time(dn <- dmvnorm(data[,i], mean=tr, sigma=C, log=TRUE)))
L <- L + dn
}
print(L)
stopifnot(all.equal(likeli$log, L))
pts <- c(4, 5)
repet <- c(2, 3)
trend <- 2 * sin(R.p(new="isotropic")) + 3
model <- 2 * RMexp() + trend
x <- y <- data <- list()
for (i in 1:length(pts)) {
x[[i]] <- list(x = runif(n=pts[i], min=-1, max=1),
y = runif(n=pts[i], min=-1, max=1))
data[[i]] <- as.matrix(RFsimulate(model, x=x[[i]]$x, y=x[[i]]$y,
n=repet[i], spC = FALSE))
}
print(system.time(likeli <- RFlikelihood(model, x, data=data)))
str(likeli, digits=8)
L <- 0
for (p in 1:length(pts)) {
tr <- RFfctn(trend, x=x[[p]]$x, y=x[[p]]$y,spC = FALSE)
C <- RFcovmatrix(model, x=x[[p]]$x, y=x[[p]]$y)
for (i in 1:ncol(data[[p]])) {
print(system.time(dn <- dmvnorm(data[[p]][,i], mean=tr, sigma=C,
log=TRUE)))
L <- L + dn
}
}
print(L)
stopifnot(all.equal(likeli$log, L))
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.