pairwise: Organizing paired observation

Description Usage Arguments Details Examples

Description

Provide a function that creates a new dataset containing all paired observations, with distance and dependence measures.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
pairwise(x, ...)

## S3 method for class 'formula'
pairwise(xform, x, yform, y, method = "geo", htol = Inf,
  pseudo = TRUE, coord = TRUE, pearson = TRUE, spearman = TRUE,
  kendall = TRUE)

## S3 method for class 'formula'
pobs(form, x)

## S3 method for class 'data.frame'
pdist(y, method = "geo", htol = NULL, ...)

## S3 method for class 'formula'
pdist(form, y, method = "geo", htol = NULL, ...)

Arguments

x, y

Data.frame of the observation and station characteristics.

method

Type of distance to compute. Either 'geo' for geographical distance or 'euclidean' for euclidean distance.

htol

Threshold that limit the paired distances.

pseudo

If TRUE, the pseudo-observations are return.

coord

If TRUE, the coordinates are return.

pearson

If TRUE, the pearson correlation is return.

spearman

If TRUE, the Spearman rho is return.

kendall

If TRUE, the Kendall tau is return.

form, xform, yform

Formula that specify which variables of x or y are used.

Details

With x or the function pobs, the formula is of the form : value ~ id + year, which result in a data.frame with twice the number of columns. In order, they represent the values that composes the paired observation, the station identificator and the time. This function is usually used for transforming a dataset containing hydrological variables from several station at several sampling times.

With y or the function pdist, the formula is of the form : id ~ lon + lat, which returns a data.frame with twice the number of columns, plus the paired distance and other related measures of associations. In order the variable represent the station identificator and the coordinates. If method = 'euclidean' the distance can be calculated between stations characteristics. In the case of 3 variables, the formula could be of the form : id ~ var1 + var2 + var3.

The function pairwise combine the result of pobs and pdist in a list and calculate measure of association between the paired observations.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
xdf <- data.frame(id = factor(c('a','a','b','b','b','c','c'),
                             levels = c('a','b','c','d')),
                 year = 2010 + c(1:2,1:3,1:2),
                 value = rlnorm(7))

pobs(value~id+year, xdf)

coord <- data.frame(id = c('a','b','c','d'),
                 lon = runif(4)-80,
                 lat = runif(4)+43)

pdist(id~lon+lat,coord)
pdist(id~lon+lat,coord, htol = 50)

pairwise(value~id+year, xdf, id~lon+lat,coord)

##################################################################

martindurocher/floodRFA documentation built on June 5, 2019, 8:44 p.m.