Learn R Programming

fields (version 16.2)

Krig.replicates: Collapse repeated spatial locations into unique locations

Description

In case that several observations are available for a single spatial location find the group means and replicate variability

Usage

Krig.replicates(out = NULL, x, y, Z = NULL, weights = rep(1,
                 length(y)), digits = 8, verbose = FALSE)

Value

A list with components:

yM

Data at unique locations and where more than one observation is available this is the mean of the replicates.

xM

Unique spatial locations.

weightsM

Weights matching the unique lcoations proportional to reciprocal variances This is found as a combination of the original weights at each location.

ZM

Values of the covariates at the unique lcoations.

uniquerows

Index for unique rows of x.

tauHat.rep, tauHat.pure.error

Standard deviation of pure error estimate based on replicate groups (and adjusting for possibly different weights.)

rep.info

Integer tags indicating replicate groups.

Arguments

out

A list with components x, y, weights, and possibily Z.

x

Spatial locations.

y

Spatial observations

Z

Spatial covariates.

weights

Weights proportional to reciprocal varainces of observations.

digits

Number of significant digits to consider in determing a replicate location.

verbose

If TRUE print out details for debugging.

Author

Douglas Nychka

Details

This function figures out which locations are the same and within the function fast.1way use tapply to find replicate group means and standard deviations. NOTE: it is assumed the Z covariates are unique at the locations. Currently these functions can not handle a model with common spatial locations but different values for the Z covariates.

Examples

Run this code

#create  some spatial replicates
 set.seed( 123)
 x0<- matrix( runif(10*2), 10,2)
 x<-  x0[ c(rep(1,3), 2:8, rep( 9,5),10) , ]
 y<-  rnorm( 16)
 
 out<- Krig.replicates( x=x, y=y)
# compare 
# out$yM[1] ;  mean( y[1:3])
# out$yM[9] ; mean( y[11:15])
# mean( y[ out$rep.info==9])
 

Run the code above in your browser using DataLab