Title: | Spatial Multivariate Data Modeling |
---|---|
Description: | Aim is to provide fractional Brownian vector field generation algorithm, Hurst parameter estimation method and fractional kriging model for multivariate data modeling. |
Authors: | Neringa Urbonaite [aut, cre], Leonidas Sakalauskas [aut] |
Maintainer: | Neringa Urbonaite <[email protected]> |
License: | GPL-2 |
Version: | 1.0.0 |
Built: | 2024-11-09 03:06:56 UTC |
Source: | https://github.com/nidagreen/frackriging |
Generates fractional Brownian vector field data
FracField(K, m, H, X)
FracField(K, m, H, X)
K |
number of observations |
m |
number of criteria |
H |
Hurst parameter (a real in interval [0,1)) |
X |
Coordinates |
# Load FracKrigingR library library(FracKrigingR) # generate Coordinates p=2; K=10; X<-matrix(0,ncol=p, nrow=K) for(j in 1:p){ for(i in 1:K){ X[i,j] = rnorm(1, 0, 1) } } # generate fractional Brownian vector field H = 0.5; m = 3 FracField(K,m,H,X)
# Load FracKrigingR library library(FracKrigingR) # generate Coordinates p=2; K=10; X<-matrix(0,ncol=p, nrow=K) for(j in 1:p){ for(i in 1:K){ X[i,j] = rnorm(1, 0, 1) } } # generate fractional Brownian vector field H = 0.5; m = 3 FracField(K,m,H,X)
Performs extrapolation for spatial multivariate data
FracKrig(X, Z, Xnew, H)
FracKrig(X, Z, Xnew, H)
X |
Coordinates |
Z |
observations |
Xnew |
Coordinates of points where the prognosis should be made |
H |
Hurst parameter (a real in interval [0,1)) |
library(sp) library(gstat) data(meuse) xy<-cbind(meuse$x,meuse$y) X<-xy[1:50,] min_max_norm <- function(x) { (x - min(x)) / (max(x) - min(x)) } normalize <- function(x) { return ((x - min(x)) / (max(x) - min(x))) } dat<-cbind(meuse[3],meuse[4],meuse[5]) data<-dat[51:100,] zz1 <- as.data.frame(lapply(dat, normalize)) data1=as.data.frame(lapply(as.data.frame(data), normalize)) Z<-as.matrix(zz1[1:50,]) library(FracKrigingR) K<-50 #Hurst parameter estimation H<-0.2 Xnew<-xy[51:100,] results<- FracKrig(X,Z,Xnew,H) denormalize <- function(x, bottom, top){ (top - bottom) * x + bottom } z1 = denormalize( results[,1], top = max(data[,1]), bottom = min(data[,1]) ) z2 = denormalize( results[,2], top = max(data[,2]), bottom = min(data[,2]) ) z3 = denormalize( results[,3], top = max(data[,3]), bottom = min(data[,3]) ) RMSE<-function(z,prognosis){ rmse<-sqrt(((1/(length(z))))*sum((z-prognosis)^2)) rmse } Cd<-RMSE(data[,1],z1) Cu<-RMSE(data[,2],z2) Pb<-RMSE(data[,3],z3) Cd Cu Pb
library(sp) library(gstat) data(meuse) xy<-cbind(meuse$x,meuse$y) X<-xy[1:50,] min_max_norm <- function(x) { (x - min(x)) / (max(x) - min(x)) } normalize <- function(x) { return ((x - min(x)) / (max(x) - min(x))) } dat<-cbind(meuse[3],meuse[4],meuse[5]) data<-dat[51:100,] zz1 <- as.data.frame(lapply(dat, normalize)) data1=as.data.frame(lapply(as.data.frame(data), normalize)) Z<-as.matrix(zz1[1:50,]) library(FracKrigingR) K<-50 #Hurst parameter estimation H<-0.2 Xnew<-xy[51:100,] results<- FracKrig(X,Z,Xnew,H) denormalize <- function(x, bottom, top){ (top - bottom) * x + bottom } z1 = denormalize( results[,1], top = max(data[,1]), bottom = min(data[,1]) ) z2 = denormalize( results[,2], top = max(data[,2]), bottom = min(data[,2]) ) z3 = denormalize( results[,3], top = max(data[,3]), bottom = min(data[,3]) ) RMSE<-function(z,prognosis){ rmse<-sqrt(((1/(length(z))))*sum((z-prognosis)^2)) rmse } Cd<-RMSE(data[,1],z1) Cu<-RMSE(data[,2],z2) Pb<-RMSE(data[,3],z3) Cd Cu Pb
Fractional distance matrix
FracMatrix(H, K, X)
FracMatrix(H, K, X)
H |
Hurst parameter (a real in interval [0,1)) |
K |
number of observations |
X |
Coordinates |
# Load FracKrigingR library library(FracKrigingR) #Fractional Brownian vector field K = 10; H = 0.5; p = 2 #Generate coordinates X<-matrix(0,ncol=p, nrow=K) for(j in 1:p){ for(i in 1:K){ X[i,j] = rnorm(1, 0, 1) } } FracMatrix(H, K, X)
# Load FracKrigingR library library(FracKrigingR) #Fractional Brownian vector field K = 10; H = 0.5; p = 2 #Generate coordinates X<-matrix(0,ncol=p, nrow=K) for(j in 1:p){ for(i in 1:K){ X[i,j] = rnorm(1, 0, 1) } } FracMatrix(H, K, X)
Maximum likelihood method for Hurst parameter estimation of multivariate data
MaxLikelihood(X, Z)
MaxLikelihood(X, Z)
X |
Coordinates |
Z |
Observations |
# Load FracKrigingR library library(FracKrigingR) # generate Coordinates p<-2; K<-20; X<-matrix(0,ncol=p, nrow=K) for(j in 1:p){ for(i in 1:K){ X[i,j] = rnorm(1, 0, 1) } } # generate fractional Brownian vector field H <- 0.8; m <- 3 Z<-FracField(K,m,H,X) # Hurst parameter estimation MaxLikelihood(X,Z)
# Load FracKrigingR library library(FracKrigingR) # generate Coordinates p<-2; K<-20; X<-matrix(0,ncol=p, nrow=K) for(j in 1:p){ for(i in 1:K){ X[i,j] = rnorm(1, 0, 1) } } # generate fractional Brownian vector field H <- 0.8; m <- 3 Z<-FracField(K,m,H,X) # Hurst parameter estimation MaxLikelihood(X,Z)