Variog.fit          package:ProbForecastGOP          R Documentation

_F_i_t_t_i_n_g _a _p_a_r_a_m_e_t_r_i_c _v_a_r_i_o_g_r_a_m _m_o_d_e_l _t_o _a_n _e_m_p_i_r_i_c_a_l _v_a_r_i_o_g_r_a_m

_D_e_s_c_r_i_p_t_i_o_n:

     This function estimates a parametric model fitted to an empirical 
     variogram. The estimates are calculated using the weighted least
     squares  method.

_U_s_a_g_e:

     Variog.fit(emp.variog, variog.model="exponential", max.dist.fit=NULL, 
     init.val=NULL, fix.nugget=FALSE)

_A_r_g_u_m_e_n_t_s:

emp.variog: an object of the class 'emp.variog', output of the function
          'Emp.variog' or of the function  'avg.variog'.

variog.model: character string giving the name of the parametric  model
          to fit to the empirical variogram. Implemented models are 
          'exponential', 'spherical', 'gauss', 'gencauchy', and 
          'matern'.

max.dist.fit: number giving the maximum distance considered when
          fitting the variogram.

init.val: numeric vector giving the initial values for the parameters.
          The number of initial values to be entered depends on the
          variogram model specified. 

          If the variog.model specified is 'exponential', 'spherical'
          or  'gauss', then the parameters required are, in order, the
          nugget  effect, the variance and the range. 

          If the variog.model specified is 'gencauchy', the parameters
          required  are, in order, the nugget effect, the variance, the
          range, the smoothness  parameter 'a', and the long-range
          parameter 'b'.

          If the variog.model specified is 'matern' the parameters
          required are,  in order, the nugget effect, the variance, the
          range, and the smoothness  parameter 'a'.

          For more details on the valid range for the parameters and
          for the  equation  of the variogram models listed above, look
          below at the section "Details".

fix.nugget: logical field indicating whether the nugget should be
          considered fixed or not. If 'TRUE' the nugget effect will be
          assumed to be constant, and a value for the fixed nugget
          effect can be also provided. If the value provided is
          different from the one entered in the 'init.val' field, then
          the value of the nugget effect is taken to be the one entered
          in the 'init.val' field. 

          If 'FALSE' the nugget effect will be estimated along with the
          other parameters in the variogram model.

_D_e_t_a_i_l_s:

     The function estimates the parameters in the variogram model by
     minimizing the weighted least-square loss function


 LOSS(theta) = sum_k n_k [ ( frac{hat{gamma_k} - gamma_k(theta)}{gamma_k(theta)} )^2 ]


     where n_k is the number of pairs contributing to the variogram
     computation in the kth bin, hat{gamma_k} is the value of the
     empirical variogram in the kth bin and gamma_k(theta) is the value
     of the estimated parametric variogram model at the midpoint of the
     kth bin.

     - Parametric variogram models -

     The parametric model implemented for the variogram are:
     exponential ('exponential'), spherical('spherical'), gaussian
     ('gauss'), generalized Cauchy ('gencauchy') and Whittle-Matern
     ('matern').

     - 'exponential':

     The equation of the exponential variogram with parameters the
     nugget  effect, rho, the variance, sigma^{2}, and the range,  r,
     is given by:


         gamma(d) = rho+sigma^{2} cdot (1-exp(- frac{d}{r}))


     where d is the distance between the two locations and gamma(d) is
     the value of the exponential variogram at distance d.

     Notice that: the nugget effect, rho, is a non-negative number, 
     while the variance, sigma^2, and the range, r, are positive 
     numbers.

     - 'spherical'

     The equation of the spherical variogram with parameters the nugget
     effect,  rho, the variance, sigma^{2}, and the range, r, is  given
     by:


 gamma(d) = rho+sigma^{2} cdot (frac{3}{2}  cdotfrac{d}{r}-frac{1}{2} cdot frac{d^3}{r^3})


     where d is the distance between the two locations and gamma(d) is
     the value of the spherical variogram at distance d. 

     Notice that: the nugget effect, rho, is a non-negative number, 
     while the variance, sigma^2, and the range, r, are positive 
     numbers.

     - 'gauss'

     The equation of the gaussian variogram with parameters the nugget
     effect,  rho, the variance, sigma^{2}, and the range, r, is  given
     by:


       gamma(d) = rho+sigma^{2} cdot (1-exp(- frac{d^2}{r^2} ))


     where d is the distance between the two locations and gamma(d) is
     the value of the gaussian variogram at distance d.

     Notice that: the nugget effect, rho, is a non-negative number, 
     while the variance, sigma^2, and the range, r, are positive 
     numbers.

     - 'gencauchy'

     The equation of the generalized Cauchy variogram with parameters
     the  nugget effect, rho, the variance, sigma^{2}, the range,  r,
     the smoothness parameter, a, and the long-range parameter, b, is
     given by:


 gamma(d) = rho+sigma^{2} cdot  (1-(1+frac{d^a}{r^a})^{- frac{b}{a}})


     where d is the distance between the two locations and gamma(d) is
     the value of the generalized Cauchy variogram at distance d.

     Notice that: the nugget effect, rho, is a non-negative number, the
      variance, sigma^2, and the range, r, are positive numbers,  the
     smoothness parameter, a, is a number in (0,2], and the long-range
     parameter, b, is a positive number.

     - 'matern'

     The equation of the Whittle-Matern variogram with parameters the
     nugget  effect, rho, the variance, sigma^{2}, the range, r,  and
     the smoothness parameter, a, is given by:


 gamma(d) = rho+sigma^{2} cdot (1-(frac{2^{1-a}}{Gamma(a)}cdot  frac{d^a}{r^a} cdot K_{a}(frac{d}{r}))


     where d is the distance between the two locations, gamma(d) is the
     value of the Whittle-Matern variogram at distance d, Gamma is the
     gamma function and K_a is the Bessel function of the third kind
     with parameter a.

     Notice that: the nugget effect, rho, is a non-negative number, the
      variance, sigma^2, the range, r, and the smoothness  parameter,
     a, are positive numbers.

     - Defaults -

     The default value for the maximum distance is frac{1}{2 cdot
     sqrt{2}} times the maximum distance considered in the empirical
     variogram. 

     Default for the initial values of the parameters is 'NULL', in
     which case the initial values for the parameters are determined
     internally and depend on the empirical variogram values.

     By default, the nugget effect is not considered constant. Thus,
     the  default value for the 'fix.nugget' field is 'FALSE'.

_V_a_l_u_e:

     The function returns a list with components given by:  

   model: name of the parametric model fitted to the empirical
          variogram.

  nugget: Estimate of the nugget effect.

variance: Estimate of the variance.

   range: Estimate of the range.

additional.par: Numeric vector with the estimates of the  additional
          parameters required by the parametric variogram model. This
          is  returned only if the parametric model fitted are
          'gencauchy' or  'matern'

_A_u_t_h_o_r(_s):

     Gel, Y., Raftery, A. E., Gneiting, T., Berrocal, V. J.
     veronica@stat.washington.edu.

_R_e_f_e_r_e_n_c_e_s:

     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.

     Cressie, N. A. C. (1993) _Statistics for Spatial Data_ (revised
     ed.). Wiley: New York.

     Gneiting, T., Schlather, M. (2004). Stochastic models that
     separate  fractal dimension and the Hurst effect. _SIAM Review_
     *46*,  269-282.

     Stein, M. L. (1999). _Interpolation of Spatial Data - Some Theory
     for Kriging_. Springer-Verlag: New York.

_S_e_e _A_l_s_o:

     'Emp.variog' for computation of the empirical  variogram of
     forecast errors, and 'avg.variog' for computation  of the
     empirical variogram of a random variable.

_E_x_a_m_p_l_e_s:

     ## Loading data
     library(fields)
     library(RandomFields)
     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 the empirical variogram
     variogram <- 
     Emp.variog(day=day,obs=obs,forecast=forecast,id=id,coord1=coord1,coord2=coord2,
     cut.points=NULL,max.dist=NULL,nbins=NULL)
     ## Estimating parameters
     ## Without specifying initial values for the parameters
     param.variog <- 
     Variog.fit(emp.variog=variogram,variog.model="exponential",max.dist.fit=NULL,
     init.val=NULL,fix.nugget=FALSE)
     ## Plotting the empirical variogram with the estimated parametric variogram superimposed
     plot(variogram$bin.midpoints,variogram$empir.variog,xlab="Distance",ylab="Semi-variance")
     lines(variogram$bin.midpoints,linesmodel(distance=variogram$bin.midpoints,
     variog.model="exponential",param=c(param.variog$nugget,
     param.variog$variance,param.variog$range)))

     ## Specifying the initial values for the parameters and keeping the nugget effect fixed
     param.variog <- 
     Variog.fit(emp.variog=variogram,variog.model="exponential",max.dist.fit=NULL,
     init.val=c(0,2,100),fix.nugget=TRUE)
     ## Plotting the empirical variogram with superimposed the estimated parametric variogram
     plot(variogram$bin.midpoints,variogram$empir.variog,xlab="Distance",ylab="Semi-variance")
     lines(variogram$bin.midpoints,linesmodel(distance=variogram$bin.midpoints,
     variog.model="exponential",param=c(param.variog$nugget,
     param.variog$variance,param.variog$range)))

