Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/EmpDir.variog.R

Calculates directional empirical variogram of forecast errors, averaged over time.

1 | ```
EmpDir.variog(day, obs, forecast, id, coord1, coord2, tol.angle1=45, tol.angle2=135, cut.points=NULL, max.dist=NULL, nbins=300, type)
``` |

`day` |
numeric vector containing the day of observation. |

`obs` |
numeric vector containing the observed weather quantity. |

`forecast` |
numeric vector containing the forecasted weather quantity. |

`id` |
vector with the id of the metereological stations. |

`coord1` |
vector containing the longitudes of the metereological stations. |

`coord2` |
vector containing the latitudes of the metereological stations. |

`tol.angle1` |
number giving a lower bound for the tolerance angle (measured in degrees). |

`tol.angle2` |
number giving an upper bound for the tolerance angle (measured in degrees). |

`cut.points` |
numeric vector containing the cutpoints used for variogram binning. |

`max.dist` |
a numerical value giving the upper bound for the distance considered in the variogram computation |

.

`nbins` |
a numerical value giving the number of bins to use for variogram binning. If both |

`type` |
character string indicating the direction to use for variogram computations. Possible values are either 'E' (for East-West) or 'N' (for North-South). |

The function includes bias-correction; it regresses the forecasts on the observed weather quantity and computes the residuals. The directional empirical variogram of the residuals is then calculated by determining, for each day, the "directional" distance among all pairs of stations that have been observed in the same day and by calculating for each day the sum of all the squared differences in the residuals within each bin. These sums are then averaged over time, with weights for each bin given by the sum over time of the number of pairs of stations within the bin.

The formula used is:

* γ(h) = ∑_d \frac{1}{2N_{(h,d)}} (∑_i (Y(x_{i}+h,d)-Y(x_{i},d))^2)*

where *γ(h)* is the empirical variogram at distance *h*, *N_{(h,d)}* is the number of pairs of stations that have been recorded at day *d* and whose
distance is equal to *h*, and *Y(x_{i}+h,d)* and *Y(x_{i},d)* are, respectively, the values of the residuals on day *d* at stations *x_{i}+h* and
*x_{i}*. Variogram binning is ignored in this formula.

The "directional" distance between two locations is defined to be equal to the distance between the two locations if the angle between the two locations is within the allowed range, while it is set equal to infinity if the angle between the two locations is outside the allowed range.

**- Defaults -**

By default, `tol.angle1`

and `tol.angle2`

are set to 45 and 135 degrees, respectively. If the vector with the cutpoints is not specified, the cutpoints are
determined so that there are `nbins`

number of bins with approximately the same number of pairs per bin.

If both the vector with the cutpoints and the number of bins, `nbins`

, are not provided, the function by default determines the cutpoints so that there are a total of 300 bins with approximately the same number of pairs per bin. If both the vector with the cutpoints and the number of bins are provided, the entry for the number of bins is ignored and the vector with the cutpoints is used for variogram binning.

The default value for the maximum distance considered in the variogram computation is the *90*-th percentile of the distances between the stations.

The function returns a list with components given by:

`bin.midpoints` |
Numeric vector with midpoints of the bins used in the directional empirical variogram computation. |

`number.pairs` |
Numeric vector with the number of pairs per bin. |

`dir.variog` |
Numeric vector with the directional empirical variogram values. |

The function might require some time to return an output.

Berrocal, V. J. (veroberrocal@gmail.com), Raftery, A. E., Gneiting, T., Gel, Y.

Gel, Y., Raftery, A. E., Gneiting, T. (2004). Calibrated
probabilistic mesoscale weather field forecasting: The Geostatistical
Output Perturbation (GOP) method (with discussion). *Journal of the
American Statistical Association*, **Vol. 99 (467)**, 575–583.

Gel, Y., Raftery, A. E., Gneiting, T., Berrocal, V. J. (2004).
Rejoinder. *Journal of the American Statistical Association*,
**Vol. 99 (467)**, 588–590.

Cressie, N. A. C. (1993). *Statistics for Spatial Data* (revised ed.). Wiley: New York.

`Emp.variog`

for empirical variogram averaged over time, `avg.variog`

and `avg.variog.dir`

for, respectively, empirical and
directional empirical variogram of a random variable averaged over time, and `Variog.fit`

for estimation of parameters in a parametric variogram model.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ```
## Loading data
data(slp)
day <- slp$date.obs
id <- slp$id.stat
coord1 <- slp$lon.stat
coord2 <- slp$lat.stat
obs <- slp$obs
forecast <- slp$forecast
## Computing directional variogram
## No specified cutpoints, no specified maximum distance
## No specified tolerance angles and default number of bins
dir.variog <- EmpDir.variog(day,obs,forecast,id,coord1,coord2,
tol.angle1=NULL,tol.angle2=NULL,cut.points=NULL,max.dist=NULL,
nbins=NULL,type='E')
## Plotting directional variogram
plot(dir.variog$bin.midpoints,dir.variog$dir.variog,xlab="Distance",
ylab="Semi-variance",main="Empirical Directional variogram")
## Computing directional variogram
## Specified cutpoints, specified maximum distance
## Specified tolerance angles and unspecified number of bins
dir.variog <-
EmpDir.variog(day,obs,forecast,id,coord1,coord2,tol.angle1=30,
tol.angle2=150,cut.points=seq(0,1000,by=5),max.dist=800,nbins=NULL,
type='N')
## Plotting directional variogram
plot(dir.variog$bin.midpoints,dir.variog$dir.variog,xlab="Distance",ylab="Semi-variance",main="Empirical Directional variogram")
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.