Initialization
Using the API defined by gstlearn.
nsim = 20
ns = 5000
# target grid in 2d
ndim = 2
dx = c(0.5, 0.5, 0.5)[1:ndim]
nx = c(100, 100, 100)[1:ndim]
grid = DbGrid_create(nx = nx, dx = dx)
2d univariate (CorAniso)
idx = 3
type = c("EXPONENTIAL", "GAUSSIAN", "MATERN")[idx]
nvar = 1
# parameters for the space trace
nu = c(NA, NA, 3/4)[idx]
# space anisotropy
timeRange = 2.0
ranges = c(5,10)[1:ndim]
angles = c(30, 0)[1:ndim]
# covariance model
ctxt = CovContext(nvar = nvar, space = SpaceRN_create(ndim))
mod = CorAniso_create(ctxt = ctxt, type = ECov_fromKey(type),
params = nu,
ranges = ranges, angles = angles,
flagRange = FALSE)
err = draw_model(model = mod, prefix = type)

# simulation using "gstlearn API"
model = ModelGeneric(ctxt = ctxt)
err = model$setCov(mod)
err = simuSpectral(dbin = NULL, dbout = grid, model = model, nbsimu = nsim, ns = ns,
verbose = flag.verbose,
namconv = NamingConvention(type))
# QC
res = QC_section (model = model$getCov(), grid = grid, prefix = type, nsimu = nsim, isec = 1,
flag.histo = TRUE, flag.map = TRUE, flag.vario = TRUE,
verbose = flag.verbose)






knitr::kable(res$tab , digits = 3, caption = sprintf("Statistics for %s", res$prefix))
Statistics for MATERN
| MATERN.S1 |
10000 |
-2.509 |
2.836 |
-0.003 |
0.913 |
| MATERN.S2 |
10000 |
-2.752 |
2.891 |
-0.020 |
0.793 |
| MATERN.S3 |
10000 |
-2.513 |
2.849 |
0.000 |
0.916 |
| MATERN.S4 |
10000 |
-2.752 |
2.891 |
-0.020 |
0.793 |
| MATERN.S5 |
10000 |
-2.496 |
2.821 |
-0.001 |
0.907 |
| MATERN.S6 |
10000 |
-2.752 |
2.891 |
-0.020 |
0.793 |
| MATERN.S7 |
10000 |
-2.765 |
3.366 |
0.473 |
1.058 |
| MATERN.S8 |
10000 |
-2.714 |
2.619 |
0.017 |
0.824 |
| MATERN.S9 |
10000 |
-2.765 |
3.366 |
0.473 |
1.058 |
| MATERN.S10 |
10000 |
-2.715 |
2.605 |
0.023 |
0.823 |
| MATERN.S11 |
10000 |
-2.819 |
3.405 |
0.472 |
1.077 |
| MATERN.S12 |
10000 |
-2.738 |
2.616 |
0.016 |
0.829 |
| MATERN.S13 |
10000 |
-2.729 |
3.250 |
0.466 |
1.051 |
| MATERN.S14 |
10000 |
-2.334 |
2.467 |
0.227 |
0.862 |
| MATERN.S15 |
10000 |
-3.453 |
2.022 |
-0.497 |
0.912 |
| MATERN.S16 |
10000 |
-2.334 |
2.467 |
0.227 |
0.862 |
| MATERN.S17 |
10000 |
-3.463 |
2.032 |
-0.498 |
0.916 |
| MATERN.S18 |
10000 |
-2.334 |
2.467 |
0.227 |
0.862 |
| MATERN.S19 |
10000 |
-3.438 |
2.072 |
-0.493 |
0.910 |
| MATERN.S20 |
10000 |
-2.334 |
2.467 |
0.227 |
0.862 |
Factorized covariance in 2d
type = "Fac2d_exp_gauss"
ctxt1d = CovContext(nvar = 1, space = SpaceRN_create(1))
ctxt2d = CovContext(nvar = 1, space = SpaceRN_create(2))
mod = CorFactorized_create(ctxt = ctxt2d)
# first factor: exponential covariance along Ox
err = mod$addFactor(
CorAniso_create(ctxt = ctxt1d, type = ECov_fromKey("EXPONENTIAL"),
params = NULL, ranges = 5.0, flagRange = FALSE),
proj = matToGst(matrix(c(1,0), 2, 1))
)
# Second factor: gaussian covariance along Oy
err = mod$addFactor(
CorAniso_create(ctxt = ctxt1d, type = ECov_fromKey("GAUSSIAN"),
params = NULL, ranges = 5.0, flagRange = FALSE),
proj = matToGst(matrix(c(0,1), 2, 1))
)
err = draw_model(model = mod, prefix = type)

# simulation using "gstlearn API"
model = ModelGeneric(ctxt = ctxt)
err = model$setCov(mod)
err = simuSpectral(dbin = NULL, dbout = grid, model = model, nbsimu = nsim, ns = ns,
verbose = flag.verbose,
namconv = NamingConvention(type))
# QC
res = QC_section (model = model$getCov(), grid = grid, prefix = type, nsimu = nsim, isec = 1,
flag.histo = TRUE, flag.map = TRUE, flag.vario = TRUE,
verbose = flag.verbose)






knitr::kable(res$tab , digits = 3, caption = sprintf("Statistics for %s", res$prefix))
Statistics for Fac2d_exp_gauss
| Fac2d_exp_gauss.S1 |
10000 |
-2.686 |
3.220 |
0.212 |
0.968 |
| Fac2d_exp_gauss.S2 |
10000 |
-3.240 |
2.992 |
-0.119 |
1.090 |
| Fac2d_exp_gauss.S3 |
10000 |
-2.686 |
3.220 |
0.212 |
0.968 |
| Fac2d_exp_gauss.S4 |
10000 |
-2.722 |
3.012 |
0.120 |
0.923 |
| Fac2d_exp_gauss.S5 |
10000 |
-2.687 |
3.223 |
0.212 |
0.969 |
| Fac2d_exp_gauss.S6 |
10000 |
-2.722 |
3.012 |
0.120 |
0.923 |
| Fac2d_exp_gauss.S7 |
10000 |
-3.413 |
3.277 |
0.152 |
0.939 |
| Fac2d_exp_gauss.S8 |
10000 |
-2.721 |
3.011 |
0.120 |
0.923 |
| Fac2d_exp_gauss.S9 |
10000 |
-3.413 |
3.277 |
0.152 |
0.939 |
| Fac2d_exp_gauss.S10 |
10000 |
-2.934 |
3.450 |
-0.037 |
0.956 |
| Fac2d_exp_gauss.S11 |
10000 |
-3.358 |
3.277 |
0.152 |
0.936 |
| Fac2d_exp_gauss.S12 |
10000 |
-2.917 |
3.493 |
-0.038 |
0.957 |
| Fac2d_exp_gauss.S13 |
10000 |
-2.728 |
4.224 |
0.291 |
0.949 |
| Fac2d_exp_gauss.S14 |
10000 |
-3.115 |
2.410 |
-0.179 |
0.887 |
| Fac2d_exp_gauss.S15 |
10000 |
-2.728 |
4.224 |
0.291 |
0.949 |
| Fac2d_exp_gauss.S16 |
10000 |
-3.115 |
2.410 |
-0.179 |
0.887 |
| Fac2d_exp_gauss.S17 |
10000 |
-3.087 |
3.699 |
-0.036 |
0.951 |
| Fac2d_exp_gauss.S18 |
10000 |
-3.115 |
2.410 |
-0.179 |
0.887 |
| Fac2d_exp_gauss.S19 |
10000 |
-3.088 |
3.698 |
-0.036 |
0.951 |
| Fac2d_exp_gauss.S20 |
10000 |
-3.104 |
2.415 |
-0.179 |
0.886 |
2d trivariate matern
type = "MATERN"
nsim = 13
ctxt = CovContext(nvar = 3, space = SpaceRN_create(2))
mod = CorGaussianMixture_create(ctxt = ctxt, type = ECov_fromKey(type),
params = c(3/4, 1.0, 1/2), kappas = c(1,1, 1/2),
ranges = c(2,4), angles = c(30,0),
flagRange = FALSE)
err = draw_model(model = mod, prefix = type)






# simulation using "gstlearn API"
model = ModelGeneric(ctxt = ctxt)
err = model$setCov(mod)
err = grid$deleteColumns(names = paste(type, "*", sep = "."))
err = simuSpectral(dbin = NULL, dbout = grid, model = model, nbsimu = nsim, ns = ns,
verbose = flag.verbose,
namconv = NamingConvention(type))
res = QC_section (model = model$getCov(), grid = grid, prefix = type, nsimu = nsim, isec = 1,
flag.histo = TRUE, flag.map = TRUE, flag.vario = TRUE,
verbose = flag.verbose)






























knitr::kable(res$tab , digits = 3, caption = sprintf("Statistics for %s", res$prefix))
Statistics for MATERN
| MATERN.V1.S1 |
10000 |
-4.337 |
3.497 |
-0.135 |
1.093 |
| MATERN.V1.S2 |
10000 |
-3.716 |
3.569 |
0.207 |
1.057 |
| MATERN.V1.S3 |
10000 |
-4.266 |
3.518 |
-0.139 |
1.090 |
| MATERN.V1.S4 |
10000 |
-3.744 |
3.559 |
0.208 |
1.056 |
| MATERN.V1.S5 |
10000 |
-4.262 |
3.511 |
-0.139 |
1.090 |
| MATERN.V1.S6 |
10000 |
-3.504 |
3.223 |
-0.085 |
0.935 |
| MATERN.V1.S7 |
10000 |
-4.227 |
3.498 |
-0.139 |
1.088 |
| MATERN.V1.S8 |
10000 |
-3.500 |
3.228 |
-0.085 |
0.935 |
| MATERN.V1.S9 |
10000 |
-4.228 |
3.534 |
-0.139 |
1.088 |
| MATERN.V1.S10 |
10000 |
-3.485 |
3.223 |
-0.087 |
0.935 |
| MATERN.V1.S11 |
10000 |
-4.247 |
3.537 |
-0.139 |
1.090 |
| MATERN.V1.S12 |
10000 |
-3.441 |
3.180 |
-0.090 |
0.934 |
| MATERN.V1.S13 |
10000 |
-3.187 |
3.408 |
-0.142 |
1.084 |
| MATERN.V2.S1 |
10000 |
-4.039 |
3.242 |
-0.140 |
1.125 |
| MATERN.V2.S2 |
10000 |
-3.769 |
3.299 |
0.233 |
1.033 |
| MATERN.V2.S3 |
10000 |
-3.963 |
3.256 |
-0.146 |
1.122 |
| MATERN.V2.S4 |
10000 |
-3.791 |
3.283 |
0.234 |
1.033 |
| MATERN.V2.S5 |
10000 |
-3.958 |
3.249 |
-0.146 |
1.122 |
| MATERN.V2.S6 |
10000 |
-3.379 |
3.197 |
-0.056 |
0.919 |
| MATERN.V2.S7 |
10000 |
-3.921 |
3.237 |
-0.145 |
1.119 |
| MATERN.V2.S8 |
10000 |
-3.375 |
3.202 |
-0.056 |
0.919 |
| MATERN.V2.S9 |
10000 |
-3.918 |
3.272 |
-0.146 |
1.118 |
| MATERN.V2.S10 |
10000 |
-3.361 |
3.197 |
-0.057 |
0.919 |
| MATERN.V2.S11 |
10000 |
-3.940 |
3.278 |
-0.146 |
1.120 |
| MATERN.V2.S12 |
10000 |
-3.304 |
3.125 |
-0.061 |
0.918 |
| MATERN.V2.S13 |
10000 |
-3.071 |
3.191 |
-0.165 |
1.112 |
| MATERN.V3.S1 |
10000 |
-4.112 |
3.972 |
-0.026 |
1.131 |
| MATERN.V3.S2 |
10000 |
-3.513 |
3.575 |
0.267 |
0.954 |
| MATERN.V3.S3 |
10000 |
-4.031 |
3.980 |
-0.033 |
1.125 |
| MATERN.V3.S4 |
10000 |
-3.531 |
3.569 |
0.268 |
0.955 |
| MATERN.V3.S5 |
10000 |
-4.036 |
3.975 |
-0.033 |
1.125 |
| MATERN.V3.S6 |
10000 |
-2.571 |
3.411 |
0.483 |
0.927 |
| MATERN.V3.S7 |
10000 |
-4.046 |
3.967 |
-0.032 |
1.123 |
| MATERN.V3.S8 |
10000 |
-2.568 |
3.415 |
0.483 |
0.927 |
| MATERN.V3.S9 |
10000 |
-4.028 |
3.998 |
-0.032 |
1.123 |
| MATERN.V3.S10 |
10000 |
-2.556 |
3.411 |
0.482 |
0.927 |
| MATERN.V3.S11 |
10000 |
-4.057 |
4.000 |
-0.032 |
1.124 |
| MATERN.V3.S12 |
10000 |
-2.545 |
3.348 |
0.476 |
0.925 |
| MATERN.V3.S13 |
10000 |
-3.162 |
3.577 |
-0.079 |
1.144 |
1d gneiting
nsim = 17
# TEST of separability
type = c("GNEITING_G", "GNEITING_M", "GNEITING_C")[3]
ndim = 1
nvar = 1
sep = 1/2
# parameters for the time trace
alpha = 2.0
beta = 1.0
# parameters for the space trace
nu = c(1/2, 3/4, 1)[1:nvar]
rr = c(1, 2, 1)[1:nvar]
# space-time anisotropy
timeRange = 2.0
ranges = c(5,10)[1:ndim]
angles = c(30, 0)[1:ndim]
ctxt = CovContext(nvar = nvar, space = SpaceRN_create(ndim = ndim))
mod = CorGneiting_create(ctxt = ctxt, type = ECov_fromKey(type),
alpha = alpha, beta = beta, timeRange = timeRange,
params = nu, kappas = rr,
ranges = ranges, angles = angles,
flagRange = FALSE,
separability = sep)
err = draw_model(model = mod, prefix = type, flag.st = TRUE)






# simulation using "gstlearn API"
model = ModelGeneric(ctxt = ctxt)
err = model$setCov(mod)
# creation of a 2D x Time grid: section xOt
nx = c(100, 100)
dx = c(0.5, 0.5)
grid = DbGrid_create(nx = nx, dx = dx)
err = simuSpectral(dbin = NULL, dbout = grid, model = model, nbsimu = nsim, ns = ns,
verbose = flag.verbose,
namconv = NamingConvention(type))
res = QC_section (model = model$getCov(),
grid = grid, prefix = type, nsimu = nsim, isec = 2,
flag.histo = TRUE, flag.map = TRUE, flag.vario = TRUE,
verbose = flag.verbose, flag.st = TRUE)






# printing the statistics
knitr::kable(res$tab , digits = 3, caption = sprintf("Statistics for %s", res$prefix))
Statistics for GNEITING_C
| GNEITING_C.S1 |
10000 |
-3.388 |
2.979 |
0.292 |
0.925 |
| GNEITING_C.S2 |
10000 |
-1.774 |
2.887 |
0.503 |
0.876 |
| GNEITING_C.S3 |
10000 |
-3.395 |
2.973 |
0.288 |
0.924 |
| GNEITING_C.S4 |
10000 |
-2.167 |
3.028 |
0.511 |
0.857 |
| GNEITING_C.S5 |
10000 |
-3.392 |
2.972 |
0.288 |
0.925 |
| GNEITING_C.S6 |
10000 |
-1.673 |
3.019 |
0.499 |
0.880 |
| GNEITING_C.S7 |
10000 |
-3.193 |
2.454 |
-0.531 |
0.888 |
| GNEITING_C.S8 |
10000 |
-1.672 |
3.016 |
0.499 |
0.879 |
| GNEITING_C.S9 |
10000 |
-3.184 |
2.449 |
-0.535 |
0.888 |
| GNEITING_C.S10 |
10000 |
-2.337 |
2.991 |
0.515 |
0.889 |
| GNEITING_C.S11 |
10000 |
-2.986 |
2.178 |
-0.506 |
0.919 |
| GNEITING_C.S12 |
10000 |
-3.065 |
3.772 |
0.437 |
0.968 |
| GNEITING_C.S13 |
10000 |
-3.005 |
2.214 |
-0.505 |
0.930 |
| GNEITING_C.S14 |
10000 |
-3.065 |
3.772 |
0.437 |
0.968 |
| GNEITING_C.S15 |
10000 |
-3.009 |
2.219 |
-0.505 |
0.930 |
| GNEITING_C.S16 |
10000 |
-3.051 |
3.816 |
0.452 |
0.972 |
| GNEITING_C.S17 |
10000 |
-3.011 |
2.221 |
-0.505 |
0.930 |
nsim = 17
# TEST of separability
type = c("GNEITING_G", "GNEITING_M", "GNEITING_C")[2]
ndim = 1
nvar = 2
sep = 0
# parameters for the time trace
alpha = 2.0
beta = 1.0
# parameters for the space trace
nu = c(1/2, 3/4, 1)[1:nvar]
rr = c(1, 2, 1)[1:nvar]
# space-time anisotropy
timeRange = 2.0
ranges = c(5,10)[1:ndim]
angles = c(30, 0)[1:ndim]
ctxt = CovContext(nvar = nvar, space = SpaceRN_create(ndim = ndim))
mod = CorGneiting_create(ctxt = ctxt, type = ECov_fromKey(type),
alpha = alpha, beta = beta, timeRange = timeRange,
params = nu, kappas = rr,
ranges = ranges, angles = angles,
flagRange = FALSE,
separability = sep)
err = draw_model(model = mod, prefix = type, flag.st = TRUE)






# simulation using "gstlearn API"
model = ModelGeneric(ctxt = ctxt)
err = model$setCov(mod)
# creation of a 2D x Time grid: section xOt
nx = c(100, 100)
dx = c(0.5, 0.5)
grid = DbGrid_create(nx = nx, dx = dx)
err = simuSpectral(dbin = NULL, dbout = grid, model = model, nbsimu = nsim, ns = ns,
verbose = flag.verbose,
namconv = NamingConvention(type))
res = QC_section (model = model$getCov(),
grid = grid, prefix = type, nsimu = nsim, isec = 2,
flag.histo = TRUE, flag.map = TRUE, flag.vario = TRUE,
verbose = flag.verbose, flag.st = TRUE)
















# printing the statistics
knitr::kable(res$tab , digits = 3, caption = sprintf("Statistics for %s", res$prefix))
Statistics for GNEITING_M
| GNEITING_M.V1.S1 |
10000 |
-2.853 |
2.972 |
0.104 |
0.916 |
| GNEITING_M.V1.S2 |
10000 |
-2.870 |
2.960 |
0.002 |
0.973 |
| GNEITING_M.V1.S3 |
10000 |
-2.883 |
2.989 |
0.108 |
0.917 |
| GNEITING_M.V1.S4 |
10000 |
-2.891 |
2.944 |
0.005 |
0.972 |
| GNEITING_M.V1.S5 |
10000 |
-2.876 |
2.990 |
0.108 |
0.917 |
| GNEITING_M.V1.S6 |
10000 |
-2.886 |
2.954 |
0.008 |
0.975 |
| GNEITING_M.V1.S7 |
10000 |
-3.282 |
3.199 |
0.201 |
0.933 |
| GNEITING_M.V1.S8 |
10000 |
-2.887 |
2.952 |
0.008 |
0.975 |
| GNEITING_M.V1.S9 |
10000 |
-3.280 |
3.201 |
0.201 |
0.933 |
| GNEITING_M.V1.S10 |
10000 |
-2.889 |
2.939 |
0.009 |
0.976 |
| GNEITING_M.V1.S11 |
10000 |
-3.347 |
3.304 |
0.202 |
0.936 |
| GNEITING_M.V1.S12 |
10000 |
-3.636 |
2.469 |
-0.199 |
0.876 |
| GNEITING_M.V1.S13 |
10000 |
-3.325 |
3.223 |
0.200 |
0.934 |
| GNEITING_M.V1.S14 |
10000 |
-3.627 |
2.477 |
-0.199 |
0.875 |
| GNEITING_M.V1.S15 |
10000 |
-3.326 |
3.219 |
0.201 |
0.934 |
| GNEITING_M.V1.S16 |
10000 |
-3.632 |
2.521 |
-0.195 |
0.879 |
| GNEITING_M.V1.S17 |
10000 |
-3.326 |
3.217 |
0.201 |
0.934 |
| GNEITING_M.V2.S1 |
10000 |
-3.468 |
3.038 |
0.071 |
0.972 |
| GNEITING_M.V2.S2 |
10000 |
-2.993 |
3.057 |
-0.034 |
0.989 |
| GNEITING_M.V2.S3 |
10000 |
-3.447 |
3.041 |
0.076 |
0.972 |
| GNEITING_M.V2.S4 |
10000 |
-2.959 |
3.046 |
-0.032 |
0.987 |
| GNEITING_M.V2.S5 |
10000 |
-3.442 |
3.039 |
0.076 |
0.971 |
| GNEITING_M.V2.S6 |
10000 |
-2.951 |
3.048 |
-0.028 |
0.991 |
| GNEITING_M.V2.S7 |
10000 |
-3.473 |
3.729 |
0.131 |
0.944 |
| GNEITING_M.V2.S8 |
10000 |
-2.956 |
3.051 |
-0.028 |
0.991 |
| GNEITING_M.V2.S9 |
10000 |
-3.458 |
3.729 |
0.131 |
0.943 |
| GNEITING_M.V2.S10 |
10000 |
-2.979 |
3.074 |
-0.028 |
0.992 |
| GNEITING_M.V2.S11 |
10000 |
-3.516 |
3.831 |
0.132 |
0.948 |
| GNEITING_M.V2.S12 |
10000 |
-4.034 |
2.859 |
-0.224 |
0.990 |
| GNEITING_M.V2.S13 |
10000 |
-3.482 |
3.739 |
0.130 |
0.945 |
| GNEITING_M.V2.S14 |
10000 |
-4.025 |
2.866 |
-0.224 |
0.989 |
| GNEITING_M.V2.S15 |
10000 |
-3.481 |
3.734 |
0.130 |
0.944 |
| GNEITING_M.V2.S16 |
10000 |
-4.031 |
2.901 |
-0.221 |
0.994 |
| GNEITING_M.V2.S17 |
10000 |
-3.481 |
3.731 |
0.130 |
0.944 |
2d gneiting
nsim = 13
# TEST of separability
type = c("GNEITING_G", "GNEITING_M", "GNEITING_C")[3]
ndim = 2
nvar = 2
sep = 1/2
# parameters for the time trace
alpha = 2.0
beta = 1.0
# parameters for the space trace
nu = c(1/2, 3/4, 1)[1:nvar]
rr = c(1, 2, 1)[1:nvar]
# space-time anisotropy
timeRange = 2.0
ranges = c(5,10)[1:ndim]
angles = c(30, 0)[1:ndim]
ctxt = CovContext(nvar = nvar, space = SpaceRN_create(ndim = ndim))
mod = CorGneiting_create(ctxt = ctxt, type = ECov_fromKey(type),
alpha = alpha, beta = beta, timeRange = timeRange,
params = nu, kappas = rr,
ranges = ranges, angles = angles,
flagRange = FALSE,
separability = sep)
err = draw_model(model = mod, prefix = type, flag.st = TRUE)









# simulation using "gstlearn API"
model = ModelGeneric(ctxt = ctxt)
err = model$setCov(mod)
# creation of a 2D x Time grid: section xOt
res = list()
for (isec in 1:3) {
print(sprintf(">>>>> simulation of section %d", isec))
nx = c(100, 100, 100)
dx = c(0.5, 0.5, 0.5)
nx[isec] <- 1
grid = DbGrid_create(nx = nx, dx = dx)
err = simuSpectral(dbin = NULL, dbout = grid, model = model, nbsimu = nsim, ns = ns,
verbose = flag.verbose,
namconv = NamingConvention(type))
res[[1+length(res)]] = QC_section (model = model$getCov(),
grid = grid, prefix = type, nsimu = nsim, isec = isec,
flag.histo = TRUE, flag.map = TRUE, flag.vario = TRUE,
verbose = flag.verbose, flag.st = TRUE)
}
## [1] ">>>>> simulation of section 1"
















## [1] ">>>>> simulation of section 2"
















## [1] ">>>>> simulation of section 3"















