FindSplineParFNEXTR: Find spline parameters (Extremal)

View source: R/FindSplinePars.R

FindSplineParFNEXTRR Documentation

Find spline parameters (Extremal)

Description

Find spline parameters for deformation using extremal dependence methods. Provides Frobenuis norm of difference between pairwise empircal and theoretical χ measures. Output to be minimised to estimate spline parameters.

Usage

FindSplineParFNEXTR(
  par,
  Gcoords,
  m.ind,
  emp.dep,
  type = c("CHI_BR", "CHI_q_IBR"),
  q = 0,
  sphere.dis = FALSE
)

Arguments

par

Parameter values φ=(b_{1},b_{2},ρ,κ,δ^{(1)}_{4}...δ^{(1)}_{m},δ^{(2)}_{4}...δ^{(2)}_{m}). If m < 4, δ parameters are not needed.

Gcoords

A d by 2 matrix of G-plane coordinates.

m.ind

A vector of length m < d giving the indices of the anchor points in Gcoords.

emp.dep

A d by d matrix of pairwise empirical chi values.

type

"CHI_BR" for theoretical χ(h^{*}_{ij}) from a Brown-Resnick model. "CHI_q_IBR" for theoretical χ_q(h^{*}_{ij}) from an inverted Brown-Resnick model.

q

Threhold for χ_q(h^{*}_{ij}). Only needed if type=="CHI_q_IBR".

sphere.dis

Is Spherical distance or Euclidean distance used?

Value

Frobenius norm of difference between theoretical χ(h^{*}_{ij}) or χ_{q}(h^{*}_{ij}) matrix and emp.chi.

Examples

data("Aus_Heat")

Z<-Aus_Heat$Temp.
Gcoords<-Aus_Heat$coords

Z_U<-Z

unif<-function(x){rank(x)/(length(x)+1)}

#Transform to uniform margins
for(i in 1:dim(Z_U)[2]){

  Z_U[,i]<-unif(Z[,i])
}

chi.emp<-function(U,V,z) sum((U>=z)&(V>=z))/sum(U>=z)
q<-0.98

#Calculate pairwise empirical chi
emp.chi<-matrix(rep(0,dim(Z_U)[2]^2),nrow=dim(Z_U)[2],ncol=dim(Z_U)[2])
for(i in 1:dim(Z_U)[2]){
  for(j in 1:i){

    emp.chi[i,j]<-chi.emp(Z_U[,i],Z_U[,j],q)
  }

}
emp.chi<-emp.chi+t(emp.chi)
diag(emp.chi)<-diag(emp.chi)/2

# Set number of anchor points
m<-10
# Sample anchor points
m.ind<-sample(1:dim(Gcoords)[1],m,replace=FALSE)

#Transform to D-plane using Brown-Resnick theoretical chi function
sdf<-optim(fn=FindSplineParFNEXTR,par=c(0.05,0.05,0,1,rep(0,2*m-6)),type="CHI_BR",sphere.dis=TRUE,
           Gcoords=Gcoords,m.ind=m.ind,control=list(maxit=2000), emp.dep=emp.chi,
      method = "Nelder-Mead")

sdf<-optim(fn=FindSplineParFNEXTR,par=sdf$par,sphere.dis=TRUE,type="CHI_BR",
           Gcoords=Gcoords,m.ind=m.ind,
           control=list(maxit=2000), emp.dep=emp.chi,method = "BFGS")
sdf$m.ind<-m.ind

#Plot Dcoords

Dcoords<-returnDcoord(sdf$par,Gcoords,sdf$m.ind,sphere.dis=TRUE)
plot(Dcoords)

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