Learn R Programming

HiDimMaxStable (version 0.1.1)

dens.grid: Computes the likelihood function on a grid of parameters

Description

The dens.grid.* function family is used to compute the likelihood at several points on a grid. * must be one of the following: "maxstable", "excess" or "simultoccur".

Usage

dens.grid.maxstable(...) dens.grid.excess(...) dens.grid.simultoccur(...)

Arguments

...
see details.

Value

returns a list l including parameters used in the call (l$params, l$seqx, l$seqy), and a matrix for the computed values of the log-likelihood: l$dens.

Details

dens.grid specific arguments are the following:
data
a matrix representing the data.

params
a vector giving the arguments to be passed to the likelihood function; NA indicates that the coordinate has to be replaced by multiple values on a grid (there must be two NA's in the vector).

seqx,seqy
vectors giving the values to be used to compute the likelihood for the two coordinates that are set to NA in the params vector.

ln
logical. If TRUE log-density is computed.

parallel
logical. If TRUE a parallel computation of the log-likelihood function is performed, using the snowfall package (sfInit must be called before).

Other arguments are passed to the likelihood function.

See Also

maxstable.l.clusters, excess.l, simultoccur.l for the likelihood functions; plot3d.densgrid for a 3D visualisation of the computed values of the log-likelihood.

Examples

Run this code

# Log density of the Max-stable distribution of the Schlather process
# with the Whittle Matern correlation function
# Use larger values for n.site and n.obs for better results
n.site<-3
n.obs<-2
xy<-matrix(runif(2*n.site,0,2),ncol=2)
param<-c(0.5,1.5)
library(SpatialExtremes)
data<-t(rmaxstab(n.obs, xy, "whitmat",
    nugget = 0, range = param[1], smooth = param[2]))
cl<-build.clusters.spatial(xy)
d<-dens.grid.maxstable(data,c(NA,NA),seq(0.1,1,length=5),seq(1,2,length=5),
    category="normal",
    spatial=list(sites=xy,family=spatialWhittleMatern),
    parallel=FALSE,
    clusters=cl)
plot3d.densgrid(d)

#  Log density of the Max-stable distribution of the Brown Resnick process
# Use larger values for n.site and n.obs for better results
n.site<-4
n.obs<-3
xy<-matrix(runif(2 * n.site, 0, 2), ncol = 2)
param<-c(0.5,1)
library(SpatialExtremes)
data<-t(rmaxstab(n.obs, xy, cov.mod = "brown", range = param[1], smooth = param[2]))
cl<-build.clusters.spatial(xy)
library(snowfall)
sfInit(parallel=TRUE,cpus=4)
sfLibrary(HiDimMaxStable)
d<-dens.grid.maxstable(data,c(NA,NA),seq(0.1,1,length=5),seq(0.1,1.8,length=5),
    category="lnormal",
    spatial=list(sites=xy,family=spatialPower),
    parallel=TRUE,
    clusters=cl)
sfStop()
plot3d.densgrid(d)

#   Log density of the distribution of the vector of excesses for an
# homogeneous clustered max-stable distribution
# Use larger values for n and dimensions for better results
raw.data<-rCMS(copulas=c(copClayton,copGumbel),
    margins=c(marginLnorm,marginFrechet),
    classes=c(rep(1,4),rep(2,4)),
    params=c(0.5,1,1.5,1.7),n=10)
data<-excess.censor(raw.data)
library(snowfall)
sfInit(parallel=TRUE,cpus=4)
sfLibrary(HiDimMaxStable)
sfLibrary(VGAM)
d<-dens.grid.excess(data,c(NA,1,NA,1.7),
    seq(0.1,1,length=5),seq(1,2,length=5),
    category="copula",
    copulas=c(copClayton,copGumbel),
    margins=c(marginLnorm,marginFrechet),
            parallel=TRUE,
    classes=c(rep(1,4),rep(2,4)))
sfStop()
plot3d.densgrid(d)
    
# Log density of the distribution of the componentwise maxima
# with occurences for an homogeneous clustered max-stable distribution
# Use larger values for n and dimensions for better results
raw.data<-rCMS(copulas=c(copClayton,copGumbel),
    margins=c(marginLnorm,marginFrechet),
    classes=c(rep(1,2),rep(2,2)),
    params=c(0.5,1,1.5,1.7),n=10)
data<-maxblocks(raw.data,n.blocks=2)
library(snowfall)
sfInit(parallel=TRUE,cpus=4)
sfLibrary(HiDimMaxStable)
sfLibrary(VGAM)
d<-dens.grid.simultoccur(data$normalized.max,occur=data$classes.max,
    c(NA,1,NA,1.7),
    seq(0.1,1,length=5),seq(1,2,length=5),
    category="copula",
    copulas=c(copClayton,copGumbel),
    margins=c(marginLnorm,marginFrechet),
    classes=c(rep(1,2),rep(2,2)),
    parallel=TRUE)
sfStop()
plot3d.densgrid(d)

Run the code above in your browser using DataLab