FindSplineParFNCOR: Find spline parameters (Correlation)

View source: R/FindSplineParsCOR.R

FindSplineParFNCORR Documentation

Find spline parameters (Correlation)

Description

Find spline parameters for deformation based on correlation methods. Either use the Frobenuis norm via type=="F-norm" or the original Smith (1996) method via type=="Smith". Output to be minimised to estimate spline parameters.

Usage

FindSplineParFNCOR(
  par,
  Gcoords,
  m.ind,
  n = 0,
  emp.cor,
  type = c("F-norm", "Smith"),
  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.

n

Number of data points used to estimate emp.cor. Only neccesary for type=="Smith".

emp.cor

A d by d matrix of pairwise empirical correlation values.

type

"F-norm" for Frobenius norm method using theoretical ρ(h^{*}_{ij}) from a stationary Matérn correlation model. "Smith" for original Smith (1996) method; also uses stationary Matérn correlation model.

sphere.dis

Is Spherical distance or Euclidean distance used?

Value

Frobenius norm of difference between theoretical ρ(h^{*}_{ij}) matrix and emp.cor, or negative log-likelihood for a stationary Gaussian process fit using D-plane coordinates.

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])
}
#Transform to Gaussian margins

Z_N<-qnorm(Z_U)

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

    emp.cor[i,j]<-cor(Z_N[,i],Z_N[,j])
  }

}
emp.cor<-emp.cor+t(emp.cor)
diag(emp.cor)<-diag(emp.cor)/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 Frobenius norm method
sdf<-optim(fn=FindSplineParFNCOR,par=c(0.05,0.05,0,1,rep(0,2*m-6)),
           type="F-norm",sphere.dis=TRUE,Gcoords=Gcoords,m.ind=m.ind,
           control=list(maxit=2000), emp.cor=emp.cor,method = "Nelder-Mead")

sdf<-try(optim(fn=FindSplineParFNCOR,par=sdf$par,sphere.dis=TRUE,type="F-norm",
         Gcoords=Gcoords,m.ind=m.ind, control=list(maxit=2000), emp.cor=emp.cor,
    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.