nllIMSPexp: Negative composite censored log-likelihood for the stationary...

View source: R/nllIMSPexp.R

nllIMSPexpR Documentation

Negative composite censored log-likelihood for the stationary inverted Brown-Resnick process

Description

Calculate the negative composite censored log-likelihood for the stationary inverted Brown-Resnick process on standard exponential margins.

Usage

nllIMSPexp(par, ZBE, ZXE, ZYE, ZNE, coord, n.a, sphere.dis = F)

Arguments

par

Stationary semivariogram parameters (κ,λ).

ZBE

A list of length d with each element a matrix with 2 columns.

ZXE

A list of length d with each element a matrix with 2 columns.

ZYE

A list of length d with each element a matrix with 2 columns.

ZNE

A list of length d with each element a matrix with 2 columns.

coord

A d by 2 matrix of coordinates.

n.a

A vector with length determined by the number of unique pairs in ZNE.

sphere.dis

Is Spherical distance or Euclidean distance used?

Value

Negative composite censored log-likelihood for inverted Brown-Resnick process.

Examples

# For a N by d matrix of data "Z" and d by 2 matrix of coordinates "Gcoords".
# We use a very small subset of data(Aus_Heat) as an example.
##THIS WILL TAKE A LONG TIME TO RUN WITH THE FULL DATASET##

library(fields)
data(Aus_Heat) 
Z<-Aus_Heat$Temp.[,1:3]
Gcoords<-Aus_Heat$coords[1:3,]

unif<-function(x) rank(x)/(length(x)+1)
Z_U<-Z
for(i in 1:dim(Z_U)[2]) Z_U[,i]<-unif(Z[,i]) # Transform to uniform margins
Z_Exp<-qexp(Z_U) #Transform to exponential margins

q<-0.98
u<-quantile(Z_Exp,prob=q) # Censoring threshold
# Create a list of length 4 of pairwise exceedances and index in coordinate matrix
Zpair<-makepairs(Z_Exp,u=u) 

#Identify number of non-exceedances per pair
#Speeds up likelihood computation
dist<-rdist(Gcoords+runif(dim(Gcoords)[1]*2,0,1))
dist2<-apply(Zpair[[4]][,3:4],1,function(x){dist[x[1],x[2]]})
unique.d<-as.matrix(unique(dist2))
n.a<-rep(0, dim(unique.d)[1])
for(i in 1:length(unique.d)){
  n.a[i]<-sum(dist2==unique.d[i,1])
}

#WARNING- pairwise likelihoods take some time to run
# Inverted Brown-Resnick process fit to G-plane coordinate system
likG.IMSP<-optim(fn=nllIMSPexp,par=c(1,500),ZBE=as.matrix(Zpair[[1]]),
           ZXE=as.matrix(Zpair[[2]]),
           ZYE=as.matrix(Zpair[[3]]),ZNE=as.matrix(Zpair[[4]]),
           n.a=n.a,sphere.dis=TRUE,coord=Gcoords,
           control=list(maxit=2000),
           method = "Nelder-Mead",hessian=TRUE)

Jbrich95/sdfExtreme documentation built on March 24, 2022, 11:15 a.m.