rolling_test_dist {tectonicr}R Documentation

Apply Rolling Functions using Circular Statistics

Description

A generic function for applying a function to rolling margins of an array along an additional value.

Usage

distroll_circstats(
  x,
  distance,
  FUN,
  width = NULL,
  min_n = 2,
  align = c("right", "center", "left"),
  w = NULL,
  sort = TRUE,
  ...
)

distroll_confidence(
  x,
  distance,
  w = NULL,
  width = NULL,
  min_n = 2,
  align = c("right", "center", "left"),
  sort = TRUE,
  ...
)

distroll_dispersion(
  x,
  y,
  w = NULL,
  w.y = NULL,
  distance,
  width = NULL,
  min_n = 2,
  align = c("right", "center", "left"),
  sort = TRUE,
  ...
)

distroll_dispersion_sde(
  x,
  y,
  w = NULL,
  w.y = NULL,
  distance,
  width = NULL,
  min_n = 2,
  align = c("right", "center", "left"),
  sort = TRUE,
  ...
)

Arguments

x, y

vectors of numeric values in degrees. length(y) is either 1 or length(x)

distance

numeric. the independent variable along the values in x are sorted, e.g. the plate boundary distances

FUN

the function to be applied

width

numeric. the range across distance on which FUN should be applied on x. If NULL, then width is a number that separates the distances in 10 equal groups.

min_n

integer. The minimum values that should be considered in FUN (2 by default), otherwise NA.

align

specifies whether the index of the result should be left- or right-aligned or centered (default) compared to the rolling window of observations. This argument is only used if width represents widths.

w

numeric. the weighting for x

sort

logical. Should the values be sorted after distance prior to applying the function (TRUE by default).

...

optional arguments to FUN

w.y

numeric. the weighting for y

Value

two-column vectors of (sorted) x and the rolled statistics along distance.

Examples

data("plates")
plate_boundary <- subset(plates, plates$pair == "na-pa")
data("san_andreas")
PoR <- subset(nuvel1, nuvel1$plate.rot == "na")
san_andreas$distance <- distance_from_pb(
  x = san_andreas,
  PoR = PoR,
  pb = plate_boundary,
  tangential = TRUE
)
dat <- san_andreas |> cbind(PoR_shmax(san_andreas, PoR, "right"))

distroll_circstats(dat$azi.PoR, distance = dat$distance, w = 1 / dat$unc, FUN = circular_mean)
distroll_confidence(dat$azi.PoR, distance = dat$distance, w = 1 / dat$unc)
distroll_dispersion(dat$azi.PoR, y = 135, distance = dat$distance, w = 1 / dat$unc)
distroll_dispersion_sde(dat$azi.PoR, y = 135, distance = dat$distance, w = 1 / dat$unc, R = 100)

[Package tectonicr version 0.3.2 Index]