---
title: "Different Models in RGeostats"
author: "D. Renard"
date: "7 juillet 2017"
output:
  rmarkdown::html_vignette:
    fig_width: 5
    fig_height: 4
vignette: >
  %\VignetteIndexEntry{Different Models in RGeostats}             
  %\VignetteEngine{knitr::rmarkdown}
  \usepackage[utf8]{inputenc}
---

# Introduction

This file allows descovering the various models implemented in RGeostats.

```{r Loading_library,include=FALSE}
library(RGeostats)
```

In the next paragraph, we define the main global parameters. 

Note that not all models are available in all cases: there are usage limitation due to space dimension or degree of the Intrinsic Random Function.

```{r Main parameters}
ndim <- 2
```

```{r}
list <- melem.name(degree=0)
rank = 20
```

The next paragraph consists of a loop on the different models representing each one of them separately in a normalized manner. For those which accept a third parameter, its value is arbitrarily fixed to 1.2.

```{r Internal Function}
plot.model <- function(vartype,param=1.2,sill=1,ndim=2, verbose=FALSE)
{
  if (verbose)
  {
    res = melem.characteristics(vartype,ndim=ndim)
    res = argout(res)
    cat("Structure: ",vartype,"\n")
    if (res$flag.range) cat("Range parameter is available\n")
    if (res$flag.param) cat("Third parameter is available\n")
    cat("Structure may be used for degree of IRF >=",res$min.order,"\n")
    cat("Structure may be used for space dimension <=",res$max.ndim,"\n")
    if (res$flag.int.1d)   cat("Integral range is defined in 1-D\n")
    if (res$flag.int.2d)   cat("Integral range is defined in 2-D\n")
    if (res$flag.aniso)    cat("Anisotropy can be defined\n")
    if (res$flag.rotation) cat("Anisotropy rotation can be defined\n")
    if (res$flag.param)
    {
      if (! miss(res$parmax))
      {
        if (param > res$parmax) param = res$parmax
        cat("Third parameter must be < ",res$parmax,"\n")
      }
    }
  }
  
  model    <- model.create(vartype, param=param, sill=sill) 
  plot(model,title=vartype)
  invisible()
}
```


```{r Graphics}
list <- melem.name(degree=0)
nstruct <- length(list)

# Loop on the authorized structures #
for (rank in 1:nstruct) {
  vartype  <- list[rank]
  cat("Covariance",vartype,"\n")
  plot.model(vartype, ndim=ndim)
}
```

