xvalid                 package:geoR                 R Documentation

_C_r_o_s_s-_v_a_l_i_d_a_t_i_o_n _u_s_i_n_g _k_r_i_g_i_n_g

_D_e_s_c_r_i_p_t_i_o_n:

     This is a function to perform model validation Options include
     _leaving-one-out_ cross-validation where. each data location is
     removed from the data set and the variable at this location is
     predicted using the remaining locations, for as given model. This
     can be done for all or some of the locations. Alternativelly,
     other validation locations which are not the same as the original
     data locations can be used.

_U_s_a_g_e:

     xvalid(geodata, coords = geodata$coords, data = geodata$data,
            model, reestimate = FALSE, variog.obj = NULL,
            output.reestimate = FALSE, locations.xvalid = "all",
            data.xvalid = NULL, messages, ...)

_A_r_g_u_m_e_n_t_s:

 geodata: a list containing element 'coords' as described next.
          Typically an object of the class '"geodata"' - a 'geoR'
          data-set. If not provided the arguments 'coords' must be
          provided instead.  

  coords: an n x 2 matrix containing coordinates of the n data
          locations in each row. Defaults to 'geodata$coords', if
          provided.

    data: a vector or matrix with data values. If a matrix is provided,
          each column is regarded as one variable or realization.
          Defaults to 'geodata$data', if provided.

   model: an object containing information on a fitted model. Typically
          an output of 'likfit', 'variofit'. If an object of the class
          'eyefit' is passed it takes the first model specified in the
          object.  

reestimate: logical. Indicates whether or not the model parameters
          should be re-estimated for each point removed from the
          data-set. 

variog.obj: on object with the empirical variogram, typically an output
           of the function 'variog'. Only used if 'reestimate = TRUE'
          and the object passed to the argument 'model' is the result
          of a variogram based estimation, i.e. if the model was fitted
          by 'variofit'.  

output.reestimate: logical. Only valid if 'reestimate = TRUE'.
          Specifies whether the re-estimated parameters are returned.  

locations.xvalid: there are three possible specifications for this
          argument: '"all"' indicates the _leaving-on-out_ method is
          used. The second possibility is to use only a sub-set of the
          data for cross-validation. For this case  a vector should be
          provided with numbers indicating at which locations the
          cross-validation should be performed. The third option is to
          perform validation on a different set of data. For this a
          matrix with the coordinates of the validation points should
          be provided and the the argument 'locations.data' should also
          be provided.  

data.xvalid: data values at the validation locations. Only used if the
          validation locations are not the same or a subset of the
          original data coordinates.  

messages: logical. Indicates whether status messages should be printed
          on the screen (or output device) while the function is
          running.  

     ...: further arguments to the minimization functions used by
          'likfit', 'variofit'.  

_D_e_t_a_i_l_s:

     The cross-validation uses the function 'krige.conv' to predict at
     each location.

     For models fitted by 'variofit' the parameters kappa, psiA, psiR
     and lambda are always regarded as fixed.

     See documentation of the function 'likfit' for more details on the
     model and its parameters.

_V_a_l_u_e:

     An object of the 'class' '"xvalid"' which is a list with the
     following components: 

    data: the original data.  

predicted: the values predicted by cross-validation.  

krige.var: the cross-validation prediction variance.  

   error: difference 'data - predicted'.   

std.error: the errors divided by the square root of the prediction
          variances.  

    prob: the cumulative probability at original value under a normal
          distribution with parameters given by the cross-validation
          results.  


     A method for 'summary' returns summary statistics for the errors
     and standard errors.

     If 'reestimate = TRUE' and 'output = TRUE' additional columns are
     added to the data-frame. Each column will contain the values of
     the re-estimated parameters.

_A_u_t_h_o_r(_s):

     Paulo J. Ribeiro Jr. paulojus@ufpr.br, 
      Peter J. Diggle p.diggle@lancaster.ac.uk.

_R_e_f_e_r_e_n_c_e_s:

     Further information on the package 'geoR' can be found at:
      <URL: http://www.leg.ufpr.br/geoR>.

_S_e_e _A_l_s_o:

     'plot.xvalid' for plotting of the results, 'likfit', 'variofit'
     for parameter estimation and 'krige.conv' for the kriging method
     used for predictions.

_E_x_a_m_p_l_e_s:

     #
     # Maximum likelihood estimation
     #
     s100.ml <- likfit(s100, ini = c(.5, .5), fix.nug = TRUE)
     #
     # Weighted least squares estimation
     #
     s100.var <- variog(s100, max.dist = 1)
     s100.wls <- variofit(s100.var, ini = c(.5, .5), fix.nug = TRUE)
     #
     # Now, performing cross-validation without reestimating the model
     #
     s100.xv.ml <- xvalid(s100, model = s100.ml)
     s100.xv.wls <- xvalid(s100, model = s100.wls)
     ##
     ## Plotting results
     ##
     par.ori <- par(no.readonly = TRUE)
     ##
     par(mfcol=c(5,2), mar=c(2.3,2.3,.5,.5), mgp=c(1.3, .6, 0))
     plot(s100.xv.ml)
     par(mfcol=c(5,2))
     plot(s100.xv.wls)
     ##
     par(par.ori)
     #

