Estimates a multidimensional semivariogram (and its first derivatives) using local polynomial kernel smoothing of linearly binned semivariances.

```
np.svar(x, ...)
# S3 method for default
np.svar(
x,
y,
h = NULL,
maxlag = NULL,
nlags = NULL,
minlag = maxlag/nlags,
degree = 1,
drv = FALSE,
hat.bin = TRUE,
ncv = 0,
...
)
# S3 method for svar.bin
np.svar(x, h = NULL, degree = 1, drv = FALSE, hat.bin = TRUE, ncv = 0, ...)
np.svariso(
x,
y,
h = NULL,
maxlag = NULL,
nlags = NULL,
minlag = maxlag/nlags,
degree = 1,
drv = FALSE,
hat.bin = TRUE,
ncv = 0,
...
)
np.svariso.hcv(
x,
y,
maxlag = NULL,
nlags = NULL,
minlag = maxlag/nlags,
degree = 1,
drv = FALSE,
hat.bin = TRUE,
loss = c("MRSE", "MRAE", "MSE", "MAE"),
ncv = 1,
warn = FALSE,
...
)
np.svariso.corr(
lp,
x = lp$data$x,
h = NULL,
maxlag = NULL,
nlags = NULL,
minlag = maxlag/nlags,
degree = 1,
drv = FALSE,
hat.bin = TRUE,
tol = 0.05,
max.iter = 10,
plot = FALSE,
verbose = plot,
ylim = c(0, 2 * max(svar$biny, na.rm = TRUE))
)
```

- x
object used to select a method. Usually a matrix with the coordinates of the data locations (columns correspond with dimensions and rows with data).

- ...
further arguments passed to or from other methods.

- y
vector of data (response variable).

- h
(full) bandwidth matrix (controls the degree of smoothing; only the upper triangular part of h is used).

- maxlag
maximum lag. Defaults to 55% of largest lag.

- nlags
number of lags. Defaults to 101.

- minlag
minimun lag.

- degree
degree of the local polynomial used. Defaults to 1 (local linear estimation).

- drv
logical; if

`TRUE`

, the matrix of estimated first derivatives is returned.- hat.bin
logical; if

`TRUE`

, the hat matrix of the binned semivariances is returned.- ncv
integer; determines the number of cells leaved out in each dimension. Defaults to 0 (the full data is used) and it is not normally changed by the user in this setting. See "Details" below.

- loss
character; CV error. See "Details" bellow.

- warn
logical; sets the handling of warning messages (normally due to the lack of data in some neighborhoods). If

`FALSE`

all warnings are ignored.- lp
local polynomial estimate of the trend function (object of class

`locpol.bin`

).- tol
convergence tolerance. The algorithm stops if the average of the relative squared diferences is less than

`tol`

. Defaults to 0.04.- max.iter
maximum number of iterations. Defaults to 10.

- plot
logical; if

`TRUE`

, the estimates obtained at each iteration are plotted.- verbose
logical; if

`TRUE`

, the errors (averages of the relative squared differences) at each iteration are printed.- ylim
y-limits of the plot (if

`plot == TRUE`

).

Returns an S3 object of class `np.svar`

(locpol svar + binned svar + grid par.),
extends `svar.bin`

, with the additional (some optional) 3 components:

- est
vector or array with the local polynomial semivariogram estimates.

- locpol
a list of 6 components:

`degree`

degree of the local polinomial used.`h`

smoothing matrix.`rm`

mean of residual semivariances.`rss`

sum of squared residual semivariances.`ncv`

number of cells ignored in each direction.`hat`

(if requested) hat matrix of the binned semivariances.`nrl0`

(if appropriate) number of cells with`binw > 0`

and`est == NA`

.

- deriv
(if requested) matrix of estimated first semivariogram derivatives.

Currently, only isotropic semivariogram estimation is supported.

If parameter `nlags`

is not specified is set to `101`

.

The computation of the hat matrix of the binned semivariances (`hat.bin = TRUE`

)
allows for the computation of approximated estimation variances (e.g. in `fitsvar.sb.iso`

).

A multiplicative triweight kernel is used to compute the weights.

`np.svariso.hcv`

calls `h.cv`

to obtain an "optimal"
bandwith (additional arguments `...`

are passed to this function).
Argument `ncv`

is only used here at the bandwith selection stage
(estimation is done with all the data).

`np.svariso.corr`

computes a bias-corrected nonparametric semivariogram
estimate using an iterative algorithm similar to that described in
Fernandez-Casal and Francisco-Fernandez (2014). This procedure tries to correct
the bias due to the direct use of residuals (obtained in this case from a
nonparametric estimation of the trend function) in semivariogram estimation.

Fernandez Casal R., Gonzalez Manteiga W. and Febrero Bande M. (2003)
Space-time dependency modeling using general classes of flexible stationary
variogram models, *J. Geophys. Res.*, **108**, 8779,
doi:10.1029/2002JD002909
.

Garcia-Soidan P.H., Gonzalez-Manteiga W. and Febrero-Bande M. (2003)
Local linear regression estimation of the variogram,
*Stat. Prob. Lett.*, **64**, 169-179.

Fernandez-Casal R. and Francisco-Fernandez M. (2014)
Nonparametric bias-corrected variogram estimation under non-constant trend,
*Stoch. Environ. Res. Ris. Assess*, **28**, 1247-1259.