| Title: | Archaeological and Historical Analysis |
|---|---|
| Description: | Tools for quantitative analysis related to archaeological and historical problems for irregularly spaced time indexed observations, toward evaluating linear dependence and homogeneity over time. Methods include effect sizes for measuring homogeneity, simulation from a truncated Poisson distribution for random right-censoring of count data, and least-squares spectral analysis by lowest frequency iteration for model fitting. Collins-Elliott (2026) <https://volweb.utk.edu/~scolli46/sce_aqysuppl2026.pdf>. |
| Authors: | Stephen A. Collins-Elliott [aut, cre] (ORCID: <https://orcid.org/0000-0002-5642-6903>) |
| Maintainer: | Stephen A. Collins-Elliott <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.6.12 |
| Built: | 2026-10-21 17:43:59 UTC |
| Source: | https://github.com/scollinselliott/arkhaia |
For a matrix of cross-tabulated counts of observations, computes the Cressie-Read power-divergence statistic according to the selection of a parameter (Cressie and Read 1984; Read and Cressie 1988).
CR(x, lambda = 2/3) ## S3 method for class 'matrix' CR(x, lambda = 2/3) ## S3 method for class 'data.frame' CR(x, lambda = 2/3) ## S3 method for class 'xtabs' CR(x, lambda = 2/3) ## S3 method for class 'table' CR(x, lambda = 2/3)CR(x, lambda = 2/3) ## S3 method for class 'matrix' CR(x, lambda = 2/3) ## S3 method for class 'data.frame' CR(x, lambda = 2/3) ## S3 method for class 'xtabs' CR(x, lambda = 2/3) ## S3 method for class 'table' CR(x, lambda = 2/3)
x |
A matrix of cross-tabulated counts. |
lambda |
The parameter of the Cressie-Read power-divergence statistic. Default is the recommended value of 2/3. To use Pearson's method, set |
The Cressie-Read power-divergence statistic.
Cressie NAC, Read TRC (1984).
“Multinomial Goodness-of-Fit Tests.”
Journal of the Royal Statistical Society. Series B (Methodological), 46, 440–464.
doi:10.1111/j.2517-6161.1984.tb01318.x.
Read TRC, Cressie NAC (1988).
Goodness-of-Fit Statistics for Discrete Multivariate Data.
Springer, New York.
x1 <- c(2, 0, 10, 11, 5) x2 <- c(1, 1, 17, 23, 3) x3 <- c(0, 0, 2, 81, 11) x <- matrix(c(x1, x2, x3), ncol = 3) CR(x) CR(x, lambda = 1)x1 <- c(2, 0, 10, 11, 5) x2 <- c(1, 1, 17, 23, 3) x3 <- c(0, 0, 2, 81, 11) x <- matrix(c(x1, x2, x3), ncol = 3) CR(x) CR(x, lambda = 1)
For multiple time-indexed observations and a number of events, , that occur at a given time index, this function performs a regression of the form , where is an indicator function equaling 1 if . Estimation of , , and is performed numerically on specified ranges of potential values. The intercept term is not used where cases where a zero intercept is expected (e.g., standardized observations).
dtem( x, events, gamma = c(-10, 10), lambda = c(0, 5), intercept = FALSE, incr = 0.01 ) ## S3 method for class 'time_series' dtem( x, events, gamma = c(-10, 10), lambda = c(0, 5), intercept = FALSE, incr = 0.01 )dtem( x, events, gamma = c(-10, 10), lambda = c(0, 5), intercept = FALSE, incr = 0.01 ) ## S3 method for class 'time_series' dtem( x, events, gamma = c(-10, 10), lambda = c(0, 5), intercept = FALSE, incr = 0.01 )
x |
A data frame of two columns, with the first column containing time indices and the second containing values. |
events |
A vector of the time indices of the events, |
gamma |
The range of values of |
lambda |
The range of values of |
intercept |
The range of values of the intercept |
incr |
Increment by which to sample values of |
A list containing
A vector of coefficients and the residual sum of squares.
A matrix of the residual sum of squares for samples within the ranges of gamma and lambda.
There are no references for Rd macro \insertAllCites on this help page.
# generate example of positive trend (gamma = 2) # after event with slow decay (lambda = 0.05) t_ <- runif(100, 0, 100) events <- c(0, 54, 89) gam <- 2 lam <- 0.05 x_ev1 <- (t_ - events[1]) * gam * exp(- lam * (t_ - events[1])) x_ev2 <- (t_ - events[2]) * gam * exp(- lam * (t_ - events[2])) x_ev3 <- (t_ - events[3]) * gam * exp(- lam * (t_ - events[3])) x_ev1[t_ < events[1]] <- 0 x_ev2[t_ < events[2]] <- 0 x_ev3[t_ < events[3]] <- 0 y <- x_ev1 + x_ev2 + x_ev3 + rnorm(length(t_), 0, 0.25) dat <- time_series(t = t_, x = y) # fit model res <- dtem(dat, events, gamma = c(-2.5,2.5), lam = c(0,0.1)) # coefficients res$coefs# generate example of positive trend (gamma = 2) # after event with slow decay (lambda = 0.05) t_ <- runif(100, 0, 100) events <- c(0, 54, 89) gam <- 2 lam <- 0.05 x_ev1 <- (t_ - events[1]) * gam * exp(- lam * (t_ - events[1])) x_ev2 <- (t_ - events[2]) * gam * exp(- lam * (t_ - events[2])) x_ev3 <- (t_ - events[3]) * gam * exp(- lam * (t_ - events[3])) x_ev1[t_ < events[1]] <- 0 x_ev2[t_ < events[2]] <- 0 x_ev3[t_ < events[3]] <- 0 y <- x_ev1 + x_ev2 + x_ev3 + rnorm(length(t_), 0, 0.25) dat <- time_series(t = t_, x = y) # fit model res <- dtem(dat, events, gamma = c(-2.5,2.5), lam = c(0,0.1)) # coefficients res$coefs
Given a contingency table of cross-tabulated counts, with contexts along the columns and types along rows, this function estimates the distribution of effect sizes between pairs of "related" assemblages (determined a priori), as compared against a distribtion of "unrelated" assemblages (if not specified, are supplied as all pairs which are not included in the "related" set). Hence, the practical significance of the level of homogeneity between related deposits is evaluated against that of unrelated deposits.
homogeneity(x, related = NULL, unrelated = NULL, direction = "UW") ## S3 method for class 'effect_sizes' homogeneity(x, related = NULL, unrelated = NULL, direction = "UW")homogeneity(x, related = NULL, unrelated = NULL, direction = "UW") ## S3 method for class 'effect_sizes' homogeneity(x, related = NULL, unrelated = NULL, direction = "UW")
x |
An effect_sizes object as returned by |
related |
The related pairs of contexts as a two-column matrix or data frame (contexts between which one anticipates a meaningful relationship). Names must match |
unrelated |
The unrelated pairs of contexts as a two-column matrix or data frame (contexts between which one does not anticipate a meaningful relationship). Names must match |
direction |
Whether the related or unrelated effect size should come first. Default is |
A list of results:
11
n - A vector of the number of related and unrelated pairs of contexts, respectively and .
U - The effect sizes between unrelated pairs of contexts.
W - The effect sizes between related pairs of contexts.
Q - The quantile indicating the proportion of related contexts more homogenous than unrelated contexts (if direction is "UW"); less homogenous if direction is set to "UW".
D - The distribution of differences, , if direction is set to "UW". The proportion of is equivalent to the mean of Q.
x1 <- c(2, 0, 10, 11, 5) x2 <- c(1, 1, 17, 23, 3) x3 <- c(0, 0, 2, 81, 11) x4 <- c(3, 18, 9, 0, 23) x <- matrix(c(x1, x2, x3, x4), ncol = 4) colnames(x) <- c("surface1", "subsurface1", "surface2", "subsurface2") rownames(x) <- LETTERS[1:5] # related pairs W_contexts <- matrix(c("surface1", "surface2", "subsurface1", "subsurface2"), ncol = 2) # unrelated pairs (will be automatically created if left NULL) U_contexts <- matrix(c("surface1", "surface1", "surface2", "subsurface1", "surface2","subsurface2", "surface1", "subsurface2"), ncol = 2) effect_sizes <- VB_pair(x) homogeneity(effect_sizes, related = W_contexts, unrelated = U_contexts) homogeneity(effect_sizes, related = W_contexts)x1 <- c(2, 0, 10, 11, 5) x2 <- c(1, 1, 17, 23, 3) x3 <- c(0, 0, 2, 81, 11) x4 <- c(3, 18, 9, 0, 23) x <- matrix(c(x1, x2, x3, x4), ncol = 4) colnames(x) <- c("surface1", "subsurface1", "surface2", "subsurface2") rownames(x) <- LETTERS[1:5] # related pairs W_contexts <- matrix(c("surface1", "surface2", "subsurface1", "subsurface2"), ncol = 2) # unrelated pairs (will be automatically created if left NULL) U_contexts <- matrix(c("surface1", "surface1", "surface2", "subsurface1", "surface2","subsurface2", "surface1", "subsurface2"), ncol = 2) effect_sizes <- VB_pair(x) homogeneity(effect_sizes, related = W_contexts, unrelated = U_contexts) homogeneity(effect_sizes, related = W_contexts)
To evaluate the stability of estimates of effect sizes between archaeological contexts in light of the inclusion or exclusion of types and contexts, this routine computes the homogeneity of related assemblages iteratively in two ways, first by leaving out a type on each iteration and second by leaving out a context on each iteration. For details on the arguments, see also homogeneity and VB).
homogeneity_LOO( x, related = NULL, unrelated = NULL, direction = "UW", lambda = 2/3 ) ## S3 method for class 'matrix' homogeneity_LOO( x, related = NULL, unrelated = NULL, direction = "UW", lambda = 2/3 ) ## S3 method for class 'data.frame' homogeneity_LOO( x, related = NULL, unrelated = NULL, direction = "UW", lambda = 2/3 ) ## S3 method for class 'table' homogeneity_LOO( x, related = NULL, unrelated = NULL, direction = "UW", lambda = 2/3 ) ## S3 method for class 'xtabs' homogeneity_LOO( x, related = NULL, unrelated = NULL, direction = "UW", lambda = 2/3 )homogeneity_LOO( x, related = NULL, unrelated = NULL, direction = "UW", lambda = 2/3 ) ## S3 method for class 'matrix' homogeneity_LOO( x, related = NULL, unrelated = NULL, direction = "UW", lambda = 2/3 ) ## S3 method for class 'data.frame' homogeneity_LOO( x, related = NULL, unrelated = NULL, direction = "UW", lambda = 2/3 ) ## S3 method for class 'table' homogeneity_LOO( x, related = NULL, unrelated = NULL, direction = "UW", lambda = 2/3 ) ## S3 method for class 'xtabs' homogeneity_LOO( x, related = NULL, unrelated = NULL, direction = "UW", lambda = 2/3 )
x |
A data frame or matrix representing a contingency table of counts, with contexts along the columns and types along rows. |
related |
The related pairs of contexts as a two-column matrix or data frame (contexts between which one anticipates a meaningful relationship). Names must match |
unrelated |
The unrelated pairs of contexts as a two-column matrix or data frame (contexts between which one does not anticipate a meaningful relationship). Names must match |
direction |
Whether the related or unrelated effect size should come first. Default is |
lambda |
Parameter of the Cressie-Read power-divergence statistic. Default is the recommended value of 2/3. |
A list containing:
EQ - The mean quantile expressing the degree of homogeneity among related contexts.
EQ_T_mean - The mean quantile upon iterating over the omission of each type (of the LOO samples).
EQ_T_var - The variance of the LOO type samples.
EQ_C_mean - The mean quantile upon iterating over the omission of each context.
EQ_C_var - The variance of the LOO context samples.
x1 <- c(2, 0, 10, 11, 5) x2 <- c(1, 1, 17, 23, 3) x3 <- c(0, 0, 2, 81, 11) x4 <- c(3, 18, 9, 0, 23) x <- matrix(c(x1, x2, x3, x4), ncol = 4) colnames(x) <- c("surface1", "subsurface1", "surface2", "subsurface2") rownames(x) <- LETTERS[1:5] # related pairs W_contexts <- matrix(c("surface1", "surface2", "subsurface1", "subsurface2"), ncol = 2) # unrelated pairs (will be automatically created if left NULL) U_contexts <- matrix(c("surface1", "surface1", "surface2", "subsurface1", "surface2","subsurface2", "surface1", "subsurface2"), ncol = 2) homogeneity_LOO(x, related = W_contexts, unrelated = U_contexts)x1 <- c(2, 0, 10, 11, 5) x2 <- c(1, 1, 17, 23, 3) x3 <- c(0, 0, 2, 81, 11) x4 <- c(3, 18, 9, 0, 23) x <- matrix(c(x1, x2, x3, x4), ncol = 4) colnames(x) <- c("surface1", "subsurface1", "surface2", "subsurface2") rownames(x) <- LETTERS[1:5] # related pairs W_contexts <- matrix(c("surface1", "surface2", "subsurface1", "subsurface2"), ncol = 2) # unrelated pairs (will be automatically created if left NULL) U_contexts <- matrix(c("surface1", "surface1", "surface2", "subsurface1", "surface2","subsurface2", "surface1", "subsurface2"), ncol = 2) homogeneity_LOO(x, related = W_contexts, unrelated = U_contexts)
For two one-dimensional temporal point processes and , this function estimates the condition of the two processes becoming "integrated in distribution over time" (i.d.t.) at a moment in time . This is achieved by computing the Kolmogorov-Smirnov distance between their empirical culumative distribution functions (e.c.d.f.), as a function that encompasses observations on the support . For practical significance in the estimation of , Monte Carlo permutation of samples is used to estimate the probability that the observed value of is greater than the distribution of permuted samples (i.e., that observations are interchangable between and ).
idt_ks(x1, x2 = NULL, stat = FALSE, incr = 0.5, perm = FALSE, n_perm = 1e+05) ## S3 method for class 'numeric' idt_ks(x1, x2 = NULL, stat = FALSE, incr = 0.5, perm = FALSE, n_perm = 1e+05) ## S3 method for class 'list' idt_ks(x1, x2 = NULL, stat = FALSE, incr = 0.5, perm = FALSE, n_perm = 1e+06)idt_ks(x1, x2 = NULL, stat = FALSE, incr = 0.5, perm = FALSE, n_perm = 1e+05) ## S3 method for class 'numeric' idt_ks(x1, x2 = NULL, stat = FALSE, incr = 0.5, perm = FALSE, n_perm = 1e+05) ## S3 method for class 'list' idt_ks(x1, x2 = NULL, stat = FALSE, incr = 0.5, perm = FALSE, n_perm = 1e+06)
x1 |
Either a list of vectors or a vector containing observations of sample 1. |
x2 |
If |
stat |
Whether to multiply the distance by |
incr |
The increment at which to sample values of |
perm |
Whether to perform a Monte Carlo permutation across all samples in the input, which will return the probability of an integrating threshold at time |
n_perm |
Number of Monte Carlo permutations to perform. Default is |
The Rcpp-based function ks_arkhaia relied upon for faster estimation of the KS distance than ks.test.
A list containing a data frame two vectors x1 and x2, the probability that Monte Carlo permutation of samples results in a lower distance than the one obtained. For a list of vectors input in x1, a matrix of probabilities pairwise between all vectors.
For two one-dimensional point processes, this function computes their Wasserstein R1 distances as a function , which encompasses observations on the support . Monte Carlo permutation of samples is used to estimate the probability that the obtain distances is of practical signficance.
idt_wass( x1, x2 = NULL, stat = FALSE, scaled = FALSE, scaled_by = 0, quad_by = 0.001, incr = 0.5, perm = FALSE, n_perm = 10^5 ) ## S3 method for class 'numeric' idt_wass( x1, x2 = NULL, stat = FALSE, scaled = FALSE, scaled_by = 0, quad_by = 0.001, incr = 0.5, perm = FALSE, n_perm = 10^5 ) ## S3 method for class 'list' idt_wass( x1, x2 = NULL, stat = FALSE, scaled = FALSE, scaled_by = 0, quad_by = 0.001, incr = 0.5, perm = FALSE, n_perm = 10^5 )idt_wass( x1, x2 = NULL, stat = FALSE, scaled = FALSE, scaled_by = 0, quad_by = 0.001, incr = 0.5, perm = FALSE, n_perm = 10^5 ) ## S3 method for class 'numeric' idt_wass( x1, x2 = NULL, stat = FALSE, scaled = FALSE, scaled_by = 0, quad_by = 0.001, incr = 0.5, perm = FALSE, n_perm = 10^5 ) ## S3 method for class 'list' idt_wass( x1, x2 = NULL, stat = FALSE, scaled = FALSE, scaled_by = 0, quad_by = 0.001, incr = 0.5, perm = FALSE, n_perm = 10^5 )
x1 |
Either a list of vectors or a vector containing observations of sample 1. |
x2 |
If |
stat |
Whether to multiply the distance by |
scaled |
Whether to scale the Wasserstein R1 distance used in the course of estimation. Default is |
scaled_by |
The magnitude by which to scale the Wasserstein R1 distance, if |
quad_by |
The increment of sampling for performing quadrature. Default is |
incr |
The increment at which to sample values of |
perm |
Whether to perform a Monte Carlo permutation across all samples in the input, which will return the probability of an integrating threshold at time |
n_perm |
Number of Monte Carlo permutations to perform. Default is |
For two vectors x1 and x2, the probability that Monte Carlo permutation of samples results in a lower empirical scaled Wassertein R1 distance than the one obtained. For a list of vectors input in x1, a matrix of probabilities pairwise between all vectors.
This function computes the Kolmogorov-Smirnov (KS) distance between two empirical cumulative distribution functions. For more functionality, use ks.test.
ks_arkhaia(x1, x2 = NULL) ## S3 method for class 'numeric' ks_arkhaia(x1, x2 = NULL) ## S3 method for class 'list' ks_arkhaia(x1, x2 = NULL)ks_arkhaia(x1, x2 = NULL) ## S3 method for class 'numeric' ks_arkhaia(x1, x2 = NULL) ## S3 method for class 'list' ks_arkhaia(x1, x2 = NULL)
x1 |
A vector of observations, or a list containing both vectors. |
x2 |
A vector of observations, if |
The Rcpp-based function ks_arkhaia is used for faster estimation of the KS distance than ks.test.
The KS distance between the two vectors.
For a contingency table with columns representing contexts and rows representing types, computes the log odds ratio of a 2 x 2 contingency table of the presence-absences across each pair of columns. The addition of 0.5 to cells of the contingency table is performed (Anscombe 1956; Haldane 1956).
log_OR_pair(x) ## S3 method for class 'matrix' log_OR_pair(x) ## S3 method for class 'data.frame' log_OR_pair(x) ## S3 method for class 'xtabs' log_OR_pair(x) ## S3 method for class 'table' log_OR_pair(x)log_OR_pair(x) ## S3 method for class 'matrix' log_OR_pair(x) ## S3 method for class 'data.frame' log_OR_pair(x) ## S3 method for class 'xtabs' log_OR_pair(x) ## S3 method for class 'table' log_OR_pair(x)
x |
A matrix or data frame with contexts along columns and types along rows. |
A matrix giving the log odds ratio between all columns of the input.
x1 <- c(2, 0, 0, 11, 5, 0, 2, 0, 4) x2 <- c(1, 1, 0, 23, 3, 3, 0, 0, 0) x3 <- c(1, 0, 0, 0, 10, 0, 4, 0, 1) x <- data.frame(S1 = x1, S2 = x2, S3 = x3) rownames(x) <- LETTERS[1:nrow(x)] log_OR_pair(x)x1 <- c(2, 0, 0, 11, 5, 0, 2, 0, 4) x2 <- c(1, 1, 0, 23, 3, 3, 0, 0, 0) x3 <- c(1, 0, 0, 0, 10, 0, 4, 0, 1) x <- data.frame(S1 = x1, S2 = x2, S3 = x3) rownames(x) <- LETTERS[1:nrow(x)] log_OR_pair(x)
Performs a simple least squares fitting to time indexed data of the form , using a range of potential frequencies (Vaníček 1969, 1971). Intercept may be ommitted.
LSSA( x, freqs = seq(0.001, 0.5, by = 5e-04), intercept = TRUE, type = "frequency" ) ## S3 method for class 'time_series' LSSA( x, freqs = seq(0.001, 0.5, by = 5e-04), intercept = TRUE, type = "frequency" )LSSA( x, freqs = seq(0.001, 0.5, by = 5e-04), intercept = TRUE, type = "frequency" ) ## S3 method for class 'time_series' LSSA( x, freqs = seq(0.001, 0.5, by = 5e-04), intercept = TRUE, type = "frequency" )
x |
A time_series object (see |
freqs |
A vector of frequencies to evaluate. By default a grid from 0.001 to 0.5 is tested at an interval of 0.005. |
intercept |
Whether to include the intercept. Default is |
type |
Type of output. Can be either |
A data frame containing the power and residual sum of squares for each frequency, as well as coefficients.
Vaníček P (1969).
“Approximate Spectral Analysis by Least-Squares Fit.”
Astrophysics and Space Science, 4, 387–391.
doi:10.1007/BF00651344.
Vaníček P (1971).
“Further development and properties of the spectral analysis by least-squares fit.”
Astrophysics and Space Science, 12, 10–33.
doi:10.1007/BF00656134.
t_ <- runif(100, 0, 100) y <- 5 * sin(0.1 * t_) - 2.3 * cos(0.3 * t_ + 1) dat <- time_series(t = t_, x = y) LSSA(dat)t_ <- runif(100, 0, 100) y <- 5 * sin(0.1 * t_) - 2.3 * cos(0.3 * t_ + 1) dat <- time_series(t = t_, x = y) LSSA(dat)
Performs a simple least squares fitting to time indexed data of the form , using an input of frequencies; the lowest frequency peak (not the highest power frequency) is chosen for regression, up to a chosen number of iterations. Intercept may be ommitted. The lowest frequency is equivalent to the longest period.
LSSA_LFI(x, n_iter = 1, intercept = TRUE, AIC = FALSE) ## S3 method for class 'time_series' LSSA_LFI(x, n_iter = 1, intercept = TRUE, AIC = FALSE)LSSA_LFI(x, n_iter = 1, intercept = TRUE, AIC = FALSE) ## S3 method for class 'time_series' LSSA_LFI(x, n_iter = 1, intercept = TRUE, AIC = FALSE)
x |
A time_series object (see |
n_iter |
The number of iterations to run. Default is 1. |
intercept |
Whether to include the intercept. Default is |
AIC |
If |
A list containing:
A list of the coefficients for each iteration (the intercept is included in the first iteration).
A vector of the frequencies.
The residual sum of squares (RSS) after each iteration (decreasing).
The AIC upon each iteration. (If the parameter AIC is TRUE, this will stop at the lowest AIC value produced by the frequencies tested).
Akaike H (1973). “Information Theory and an Extension of the Maximum Likelihood Principle.” In Petrov BN, Caski F (eds.), Proceeding of the Second International Symposium on Information Theory, 267–281. Akademiai Kiado, Budapest.
For a set of time series (namely partitions of set of series) contained in a list, will compute the Akaike Information Criterion (AIC) for each candidate set (Akaike 1973).
LSSA_LFI_candidates(x, sets = NULL, n_iter = 1, intercept = TRUE) ## S3 method for class 'time_series' LSSA_LFI_candidates(x, sets = NULL, n_iter = 1, intercept = TRUE)LSSA_LFI_candidates(x, sets = NULL, n_iter = 1, intercept = TRUE) ## S3 method for class 'time_series' LSSA_LFI_candidates(x, sets = NULL, n_iter = 1, intercept = TRUE)
x |
A time_series object (see |
sets |
Candidate sets of variates to evaluate; must be a |
n_iter |
The number of iterations to run for the least squares spectral analysis via lowest frequency iteration (LSSA-LFI). Default is 1. |
intercept |
Whether to include the intercept in the least squares spectral analysis via lowest frequency iteration (LSSA-LFI). Default is |
The index of the set yielding the lowest AIC. If sets is NULL, the output of [1] indicates linear dependence; if the output is [2], linear independence.
Akaike H (1973). “Information Theory and an Extension of the Maximum Likelihood Principle.” In Petrov BN, Caski F (eds.), Proceeding of the Second International Symposium on Information Theory, 267–281. Akademiai Kiado, Budapest.
For multiple time series contained in a list, this function will compute the Akaike Information Criterion (AIC) for the best-fitting models particular to each series, including the case of an intercept-only model. This function can be performed after LSSA_LFI_candidates and repartition to determine the appropriate number of terms. For the situation where all time series must have the same number of terms, LSSA_LFI_multi should be used, but this function should chosose a better fitting model, since it adjusts the number of parameters for each dataset.
LSSA_LFI_comp(x, intercept = TRUE) ## S3 method for class 'time_series' LSSA_LFI_comp(x, intercept = TRUE)LSSA_LFI_comp(x, intercept = TRUE) ## S3 method for class 'time_series' LSSA_LFI_comp(x, intercept = TRUE)
x |
A time_series object (see |
intercept |
Whether to include the intercept in the least squares spectral analysis via lowest frequency iteration (LSSA-LFI). Default is |
A list giving the number of parameters (k) and residual sum of squares (rss) for each dataset in x, along with the AIC for the paritioned model.
Evaluate pairwise linear dependence between two time series using a LSSA-LFI valdiated model selection (see LSSA_LFI_validated)), with variable length time period.
LSSA_LFI_epoch( x, pair = NULL, n_iter = 1, intercept = TRUE, t_range = NULL, h_range = NULL, t_grid = 1, h_grid = 1 ) ## S3 method for class 'list' LSSA_LFI_epoch( x, pair = NULL, n_iter = 1, intercept = TRUE, t_range = NULL, h_range = NULL, t_grid = 1, h_grid = 1 )LSSA_LFI_epoch( x, pair = NULL, n_iter = 1, intercept = TRUE, t_range = NULL, h_range = NULL, t_grid = 1, h_grid = 1 ) ## S3 method for class 'list' LSSA_LFI_epoch( x, pair = NULL, n_iter = 1, intercept = TRUE, t_range = NULL, h_range = NULL, t_grid = 1, h_grid = 1 )
x |
A list of data frames. |
pair |
The pair of commodities to evaluate in the list |
n_iter |
The number of iterations to run. Default is 1. |
intercept |
Whether to include the intercept in the least squares spectral analysis via lowest frequency iteration (LSSA-LFI). Default is |
t_range |
The range of the time period. Default are the minimum and maximum dates spanned by the data in |
h_range |
The range of the potential windows of |
t_grid |
The length of interval along which to sample |
h_grid |
The length of interval along which to sample |
A matrix giving the probability of linear dependence, predicated upon time and window length .
Generates a data frame of values of the model generated by LSSA-LFI (see LSSA_LFI).
LSSA_LFI_model(x, t_ = NULL, n_iter = 1, intercept = TRUE, label = "model") ## S3 method for class 'time_series' LSSA_LFI_model(x, t_ = NULL, n_iter = 1, intercept = TRUE, label = "model")LSSA_LFI_model(x, t_ = NULL, n_iter = 1, intercept = TRUE, label = "model") ## S3 method for class 'time_series' LSSA_LFI_model(x, t_ = NULL, n_iter = 1, intercept = TRUE, label = "model")
x |
A time_series object (see |
t_ |
A vector giving samples range of |
n_iter |
The number of iterations to run. Default is 1. |
intercept |
Whether to include the intercept in the least squares spectral analysis via lowest frequency iteration (LSSA-LFI). Default is |
label |
Default is |
A data frame containing .
For multiple time series contained in a time_series object, this function will compute the Akaike Information Criterion (AIC) as the number of terms (n_iter) is increased. This function can be performed after LSSA_LFI_candidates and repartition to determine the appropriate number of terms.
LSSA_LFI_multi(x, n_iter = 1, intercept = TRUE, AIC = FALSE) ## S3 method for class 'time_series' LSSA_LFI_multi(x, n_iter = 1, intercept = TRUE, AIC = FALSE)LSSA_LFI_multi(x, n_iter = 1, intercept = TRUE, AIC = FALSE) ## S3 method for class 'time_series' LSSA_LFI_multi(x, n_iter = 1, intercept = TRUE, AIC = FALSE)
x |
A time_series object (see |
n_iter |
The number of iterations to run for the least squares spectral analysis via lowest frequency iteration (LSSA-LFI). Default is 1. |
intercept |
Whether to include the intercept in the least squares spectral analysis via lowest frequency iteration (LSSA-LFI). Default is |
AIC |
If |
A data frame giving the number of iterations and the AIC for each.
Akaike H (1973). “Information Theory and an Extension of the Maximum Likelihood Principle.” In Petrov BN, Caski F (eds.), Proceeding of the Second International Symposium on Information Theory, 267–281. Akademiai Kiado, Budapest.
Evaluate pairwise linear dependence between observations using a LSSA-LFI validated model selection (see LSSA_LFI_validated).
LSSA_LFI_pairwise(x, n_iter = 1, intercept = TRUE) ## S3 method for class 'time_series' LSSA_LFI_pairwise(x, n_iter = 1, intercept = TRUE)LSSA_LFI_pairwise(x, n_iter = 1, intercept = TRUE) ## S3 method for class 'time_series' LSSA_LFI_pairwise(x, n_iter = 1, intercept = TRUE)
x |
A time_series object (see |
n_iter |
The number of iterations to run. Default is 1. |
intercept |
Whether to include the intercept in the least squares spectral analysis via lowest frequency iteration (LSSA-LFI). Default is |
An upper-triangular matrix, containing the probability of linear dependence between series.
Probability of linear dependence between two groups of time series observations using a LSSA-LFI model selection (see LSSA_LFI_candidates), on the basis of the inclusion of a third "attendant" variate. The third attendant variate is selected from the remaining time series in the list, hence the input list must include at least three times series.
LSSA_LFI_validated(x, pair = NULL, n_iter = 1, intercept = TRUE) ## S3 method for class 'time_series' LSSA_LFI_validated(x, pair = NULL, n_iter = 1, intercept = TRUE)LSSA_LFI_validated(x, pair = NULL, n_iter = 1, intercept = TRUE) ## S3 method for class 'time_series' LSSA_LFI_validated(x, pair = NULL, n_iter = 1, intercept = TRUE)
x |
A time_series object (see |
pair |
The pair of series to evaluate in the |
n_iter |
The number of iterations to run. Default is 1. |
intercept |
Whether to include the intercept in the least squares spectral analysis via lowest frequency iteration (LSSA-LFI). Default is |
The probability of linear dependence between two time series, in which 1 indicates linear dependence almost surely and 0 indicates independence.
Create a 2 x 2 contingency table of the presence/absence of a given type
pa_matrix(x) ## S3 method for class 'matrix' pa_matrix(x) ## S3 method for class 'data.frame' pa_matrix(x) ## S3 method for class 'table' pa_matrix(x) ## S3 method for class 'xtabs' pa_matrix(x)pa_matrix(x) ## S3 method for class 'matrix' pa_matrix(x) ## S3 method for class 'data.frame' pa_matrix(x) ## S3 method for class 'table' pa_matrix(x) ## S3 method for class 'xtabs' pa_matrix(x)
x |
A matrix or data frame where the two columns indicate contexts and the rows indicate types, with each cell containing counts of types in a context. |
A 2 x 2 contingency table of the counts of types present in both, either, or neither context.
x1 <- c(2, 0, 10, 11, 5) x2 <- c(1, 1, 17, 23, 3) x <- data.frame(S1 = x1, S2 = x2) rownames(x) <- LETTERS[1:5] pa_matrix(x)x1 <- c(2, 0, 10, 11, 5) x2 <- c(1, 1, 17, 23, 3) x <- data.frame(S1 = x1, S2 = x2) rownames(x) <- LETTERS[1:5] pa_matrix(x)
For a matrix of cross-tabulated counts of observations which constitute a minimum threshold, this function esimates the rate parameter column-wise, either retaining or omitting zeros, by a least-squares approach.
pois_rcens(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE) ## S3 method for class 'matrix' pois_rcens(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE) ## S3 method for class 'data.frame' pois_rcens(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE) ## S3 method for class 'xtabs' pois_rcens(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE) ## S3 method for class 'table' pois_rcens(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE)pois_rcens(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE) ## S3 method for class 'matrix' pois_rcens(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE) ## S3 method for class 'data.frame' pois_rcens(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE) ## S3 method for class 'xtabs' pois_rcens(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE) ## S3 method for class 'table' pois_rcens(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE)
x |
A matrix of cross-tabulated counts. |
lambda_grid |
The resolutation at which to sample for the rate parameter. Default is |
omit_zero |
Whether to omit zeros. Default is |
A vector of the rate parameters for each column.
x1 <- c(1,2,2,5,7,0,0) x2 <- c(9,2,5,15,7,90,0) x <- matrix(c(x1,x2), ncol = 2) pois_rcens(x) pois_rcens(x, omit_zero = FALSE)x1 <- c(1,2,2,5,7,0,0) x2 <- c(9,2,5,15,7,90,0) x <- matrix(c(x1,x2), ncol = 2) pois_rcens(x) pois_rcens(x, omit_zero = FALSE)
Given multiple time series in a time_series object (x), group the variates into a new set of variates, expressed as a list of the variate names (set). Returns a time_series object using the new partitioning of variates.
repartition(x, set = NULL) ## S3 method for class 'time_series' repartition(x, set = NULL)repartition(x, set = NULL) ## S3 method for class 'time_series' repartition(x, set = NULL)
x |
A |
set |
A |
A list containing the data according to the partition structure described by set.
idx <- runif(40, 0, 100) x1 <- runif(10, 0, 1) + 3 x2 <- runif(10, 0, 1) + 2 x3 <- runif(10, 0, 1) + 1 x4 <- runif(10, 0, 1) x <- time_series(t = idx, x = c(x1,x2,x3,x4), variate = c(rep("x1", 10), rep("x2", 10), rep("x3", 10), rep("x4", 10))) repartition(x, set = list(c("x1", "x4"), "x2", "x3"))idx <- runif(40, 0, 100) x1 <- runif(10, 0, 1) + 3 x2 <- runif(10, 0, 1) + 2 x3 <- runif(10, 0, 1) + 1 x4 <- runif(10, 0, 1) x <- time_series(t = idx, x = c(x1,x2,x3,x4), variate = c(rep("x1", 10), rep("x2", 10), rep("x3", 10), rep("x4", 10))) repartition(x, set = list(c("x1", "x4"), "x2", "x3"))
For two one-dimensional temporal point processes and , this function estimates the condition of the two processes becoming "integrated in distribution over time" (i.d.t.) at a moment in time . This is achieved by computing the Kolmogorov-Smirnov distance between their empirical culumative distribution functions (e.c.d.f.), before and after for some duration , and taking the difference between the distances - . For practical significance in the estimation of , Monte Carlo permutation of samples is used to estimate the probability that the observed value of is greater than the distribution of permuted samples (i.e., that observations are interchangable between and ).
th_idt_ks( x1, x2 = NULL, stat = FALSE, incr = 0.5, perm = FALSE, n_perm = 1e+05 ) ## S3 method for class 'numeric' th_idt_ks( x1, x2 = NULL, stat = FALSE, incr = 0.5, perm = FALSE, n_perm = 1e+05 ) ## S3 method for class 'list' th_idt_ks( x1, x2 = NULL, stat = FALSE, incr = 0.5, perm = FALSE, n_perm = 1e+06 )th_idt_ks( x1, x2 = NULL, stat = FALSE, incr = 0.5, perm = FALSE, n_perm = 1e+05 ) ## S3 method for class 'numeric' th_idt_ks( x1, x2 = NULL, stat = FALSE, incr = 0.5, perm = FALSE, n_perm = 1e+05 ) ## S3 method for class 'list' th_idt_ks( x1, x2 = NULL, stat = FALSE, incr = 0.5, perm = FALSE, n_perm = 1e+06 )
x1 |
Either a list of vectors or a vector containing observations of sample 1. |
x2 |
If |
stat |
Whether to multiply the distance by |
incr |
The increment at which to sample values of |
perm |
Whether to perform a Monte Carlo permutation across all samples in the input, which will return the probability of an integrating threshold at time |
n_perm |
Number of Monte Carlo permutations to perform. Default is |
A list containing a data frame two vectors x1 and x2, the probability that Monte Carlo permutation of samples results in a lower distance than the one obtained. For a list of vectors input in x1, a matrix of probabilities pairwise between all vectors.
For two one-dimensional point processes, this function estimates the condition of the two processes becoming i.d.t. at a moment of time considering a window of time around that moment, . This is achieved by computing the difference of the empirical scaled Wasserstein R1 distances between the two processes before and after . Monte Carlo permutation of samples is used to estimate the probability that the obtain distances is of practical signficance.
th_idt_wass( x1, x2 = NULL, stat = FALSE, scaled = FALSE, scaled_by = 0, quad_by = 0.001, incr = 0.5, perm = FALSE, n_perm = 10^5 ) ## S3 method for class 'numeric' th_idt_wass( x1, x2 = NULL, stat = FALSE, scaled = FALSE, scaled_by = 0, quad_by = 0.001, incr = 0.5, perm = FALSE, n_perm = 10^5 ) ## S3 method for class 'list' th_idt_wass( x1, x2 = NULL, stat = FALSE, scaled = FALSE, scaled_by = 0, quad_by = 0.001, incr = 0.5, perm = FALSE, n_perm = 10^5 )th_idt_wass( x1, x2 = NULL, stat = FALSE, scaled = FALSE, scaled_by = 0, quad_by = 0.001, incr = 0.5, perm = FALSE, n_perm = 10^5 ) ## S3 method for class 'numeric' th_idt_wass( x1, x2 = NULL, stat = FALSE, scaled = FALSE, scaled_by = 0, quad_by = 0.001, incr = 0.5, perm = FALSE, n_perm = 10^5 ) ## S3 method for class 'list' th_idt_wass( x1, x2 = NULL, stat = FALSE, scaled = FALSE, scaled_by = 0, quad_by = 0.001, incr = 0.5, perm = FALSE, n_perm = 10^5 )
x1 |
Either a list of vectors or a vector containing observations of sample 1. |
x2 |
If |
stat |
Whether to multiply the distance by |
scaled |
Whether to scale the Wasserstein R1 distance used in the course of estimation. Default is |
scaled_by |
The magnitude by which to scale the Wasserstein R1 distance, if |
quad_by |
The increment of sampling for performing quadrature. Default is |
incr |
The increment at which to sample values of |
perm |
Whether to perform a Monte Carlo permutation across all samples in the input, which will return the probability of an integrating threshold at time |
n_perm |
Number of Monte Carlo permutations to perform. Default is |
For two vectors x1 and x2, the probability that Monte Carlo permutation of samples results in a lower empirical scaled Wassertein R1 distance than the one obtained. For a list of vectors input in x1, a matrix of probabilities pairwise between all vectors.
Creates an object of class time_series from a matrix or data frame, or by giving a filename for a csv file in the working directory. The first column contains time indices (t), the second the value of observations (x), both of which must be numeric, and the third contains a label as a factor column (variate). Multiple time series are contained in the same time_series object, distinguished by different labels.
time_series( input, t = NULL, x = NULL, variate = NULL, log = FALSE, inverse = FALSE, standard = FALSE, ... ) ## S3 method for class 'matrix' time_series( input, t = NULL, x = NULL, variate = NULL, log = FALSE, inverse = FALSE, standard = FALSE, ... ) ## S3 method for class 'data.frame' time_series( input, t = NULL, x = NULL, variate = NULL, log = FALSE, inverse = FALSE, standard = FALSE, ... ) ## S3 method for class 'character' time_series( input, t = NULL, x = NULL, variate = NULL, log = FALSE, inverse = FALSE, standard = FALSE, ... ) ## S3 method for class 'numeric' time_series( input = NULL, t = NULL, x = NULL, variate = NULL, log = FALSE, inverse = FALSE, standard = FALSE, ... )time_series( input, t = NULL, x = NULL, variate = NULL, log = FALSE, inverse = FALSE, standard = FALSE, ... ) ## S3 method for class 'matrix' time_series( input, t = NULL, x = NULL, variate = NULL, log = FALSE, inverse = FALSE, standard = FALSE, ... ) ## S3 method for class 'data.frame' time_series( input, t = NULL, x = NULL, variate = NULL, log = FALSE, inverse = FALSE, standard = FALSE, ... ) ## S3 method for class 'character' time_series( input, t = NULL, x = NULL, variate = NULL, log = FALSE, inverse = FALSE, standard = FALSE, ... ) ## S3 method for class 'numeric' time_series( input = NULL, t = NULL, x = NULL, variate = NULL, log = FALSE, inverse = FALSE, standard = FALSE, ... )
input |
A matrix, data frame, or a filename given as character. |
t |
If used, ignores ime indices of the observations; requires also input |
x |
The values of the |
variate |
The label of the variate if |
log |
Whether to take the logarithm of observations for |
inverse |
Whether to use the inverse of observations (default is |
standard |
Whether to standardize the observations, using |
... |
Additional arguments for importing from csv.
|
A time_series object.
idx <- runif(100,0,100) x <- cumsum(rnorm(100,0,1)) label <- rep("x", 100) mat <- matrix(c(idx, x, label), ncol = 3) time_series(mat) dat <- data.frame(idx, x, label) time_series(dat) time_series(t = idx, x = x, variate = label)idx <- runif(100,0,100) x <- cumsum(rnorm(100,0,1)) label <- rep("x", 100) mat <- matrix(c(idx, x, label), ncol = 3) time_series(mat) dat <- data.frame(idx, x, label) time_series(dat) time_series(t = idx, x = x, variate = label)
For a contingency table with columns representing contexts and rows representing types, computes the trace of a 2 x 2 contingency table of the presence-absences across each pair of columns.
trace_pair(x) ## S3 method for class 'matrix' trace_pair(x) ## S3 method for class 'data.frame' trace_pair(x) ## S3 method for class 'xtabs' trace_pair(x) ## S3 method for class 'table' trace_pair(x)trace_pair(x) ## S3 method for class 'matrix' trace_pair(x) ## S3 method for class 'data.frame' trace_pair(x) ## S3 method for class 'xtabs' trace_pair(x) ## S3 method for class 'table' trace_pair(x)
x |
A matrix or data frame with contexts along columns and types along rows. |
A matrix giving the trace between all columns of the input.
x1 <- c(2, 0, 0, 11, 5, 0, 2, 0, 4) x2 <- c(1, 1, 0, 23, 3, 3, 1, 1, 1) x3 <- c(1, 0, 0, 0, 10, 0, 4, 0, 0) x <- data.frame(S1 = x1, S2 = x2, S3 = x3) rownames(x) <- LETTERS[1:nrow(x)] trace_pair(x)x1 <- c(2, 0, 0, 11, 5, 0, 2, 0, 4) x2 <- c(1, 1, 0, 23, 3, 3, 1, 1, 1) x3 <- c(1, 0, 0, 0, 10, 0, 4, 0, 0) x <- data.frame(S1 = x1, S2 = x2, S3 = x3) rownames(x) <- LETTERS[1:nrow(x)] trace_pair(x)
For a data frame in which the first column contains a time index and the second colum observations, trim the data frame to include observations only with a given epoch (time period).
trim_epoch(x, epoch = NULL) ## S3 method for class 'time_series' trim_epoch(x, epoch = NULL)trim_epoch(x, epoch = NULL) ## S3 method for class 'time_series' trim_epoch(x, epoch = NULL)
x |
A time_series object (see |
epoch |
A numeric vector given the start and end time indices of the epoch. |
A data frame containing only those observations with time indices within the epoch.
For a matrix of cross-tabulated counts of observations which constitute a minimum threshold, returns a contingency table whose counts are sampled according to a truncated Poisson distribution, whose rate parameter is determined column-wise (see pois_rcens).
trunc_pois(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE) ## S3 method for class 'matrix' trunc_pois(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE) ## S3 method for class 'data.frame' trunc_pois(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE) ## S3 method for class 'xtabs' trunc_pois(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE) ## S3 method for class 'table' trunc_pois(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE)trunc_pois(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE) ## S3 method for class 'matrix' trunc_pois(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE) ## S3 method for class 'data.frame' trunc_pois(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE) ## S3 method for class 'xtabs' trunc_pois(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE) ## S3 method for class 'table' trunc_pois(x, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE)
x |
A matrix of cross-tabulated counts. |
lambda_grid |
The resolutation at which to sample for the rate parameter. Default is |
omit_zero |
Whether to omit zeros. Default is |
A contingency table of the same size as , with drawn according to a truncated Poisson distribution that ensures .
x1 <- c(1,2,2,5,7,0,0) x2 <- c(9,2,5,15,7,90,0) x <- matrix(c(x1,x2), ncol = 2) pois_rcens(x) pois_rcens(x, omit_zero = FALSE)x1 <- c(1,2,2,5,7,0,0) x2 <- c(9,2,5,15,7,90,0) x <- matrix(c(x1,x2), ncol = 2) pois_rcens(x) pois_rcens(x, omit_zero = FALSE)
For a matrix of cross-tabulated counts of observations, estimates Cramer's V using Bergsma's bias correction (Bergsma 2013), using the Cressie-Read power divergence statistic (see CR).
VB(x, lambda = 2/3) ## S3 method for class 'matrix' VB(x, lambda = 2/3) ## S3 method for class 'data.frame' VB(x, lambda = 2/3) ## S3 method for class 'xtabs' VB(x, lambda = 2/3) ## S3 method for class 'table' VB(x, lambda = 2/3)VB(x, lambda = 2/3) ## S3 method for class 'matrix' VB(x, lambda = 2/3) ## S3 method for class 'data.frame' VB(x, lambda = 2/3) ## S3 method for class 'xtabs' VB(x, lambda = 2/3) ## S3 method for class 'table' VB(x, lambda = 2/3)
x |
A matrix or data frame of cross-tabulated counts. |
lambda |
Parameter of the Cressie-Read power-divergence statistic. Default is the recommended value of 2/3. |
Bergsma's bias-corrected etimate of Cramer's .
Bergsma W (2013). “A Bias-Correction for Cramér’s $V$ and Tschuprow’s $T$.” Journal of the Korean Statistical Society, 42, 323–328. doi:10.1016/j.jkss.2012.10.002.
x1 <- c(2, 0, 10, 11, 5) x2 <- c(1, 1, 17, 23, 3) x3 <- c(0, 0, 2, 81, 11) x <- matrix(c(x1, x2, x3), ncol = 3) VB_pair(x) VB(x, lambda = 1)x1 <- c(2, 0, 10, 11, 5) x2 <- c(1, 1, 17, 23, 3) x3 <- c(0, 0, 2, 81, 11) x <- matrix(c(x1, x2, x3), ncol = 3) VB_pair(x) VB(x, lambda = 1)
To evaluate the stability of estimates of effect sizes between archaeological contexts in light of the inclusion or exclusion of a given type, this routine computes bias-corrected Cramer's V VB) omitting a type on each iteration.
VB_LOO_type(x, lambda = 2/3) ## S3 method for class 'matrix' VB_LOO_type(x, lambda = 2/3) ## S3 method for class 'data.frame' VB_LOO_type(x, lambda = 2/3) ## S3 method for class 'xtabs' VB_LOO_type(x, lambda = 2/3) ## S3 method for class 'table' VB_LOO_type(x, lambda = 2/3)VB_LOO_type(x, lambda = 2/3) ## S3 method for class 'matrix' VB_LOO_type(x, lambda = 2/3) ## S3 method for class 'data.frame' VB_LOO_type(x, lambda = 2/3) ## S3 method for class 'xtabs' VB_LOO_type(x, lambda = 2/3) ## S3 method for class 'table' VB_LOO_type(x, lambda = 2/3)
x |
A contingency table as a matrix or data frame expressing counts, with contexts along columns and types along rows. |
lambda |
Parameter of the Cressie-Read power-divergence statistic. Default is the recommended value of 2/3. |
A three-dimensional array of the pairwise context-by-context effect sizes given the ommission of a type, for all types given in the input data frame.
x1 <- c(2, 0, 10, 11, 5) x2 <- c(1, 1, 17, 23, 3) x3 <- c(0, 0, 2, 81, 11) x <- matrix(c(x1, x2, x3), ncol = 3) rownames(x) <- LETTERS[1:nrow(x)] colnames(x) <- c("S1", "S2", "S3") VB_LOO_type(x)x1 <- c(2, 0, 10, 11, 5) x2 <- c(1, 1, 17, 23, 3) x3 <- c(0, 0, 2, 81, 11) x <- matrix(c(x1, x2, x3), ncol = 3) rownames(x) <- LETTERS[1:nrow(x)] colnames(x) <- c("S1", "S2", "S3") VB_LOO_type(x)
For a matrix or data frame of cross-tabulated counts of observations, estimates Cramer's V using Bergsma's bias correction (Bergsma 2013) by subsetting the table by pairs of columns (see VB). In subsetting, zero row/columns are automatically removed from the subset matrix.
VB_pair(x, lambda = 2/3) ## S3 method for class 'matrix' VB_pair(x, lambda = 2/3) ## S3 method for class 'data.frame' VB_pair(x, lambda = 2/3) ## S3 method for class 'xtabs' VB_pair(x, lambda = 2/3) ## S3 method for class 'table' VB_pair(x, lambda = 2/3)VB_pair(x, lambda = 2/3) ## S3 method for class 'matrix' VB_pair(x, lambda = 2/3) ## S3 method for class 'data.frame' VB_pair(x, lambda = 2/3) ## S3 method for class 'xtabs' VB_pair(x, lambda = 2/3) ## S3 method for class 'table' VB_pair(x, lambda = 2/3)
x |
A matrix or data frame of cross-tabulated counts. |
lambda |
Parameter of the Cressie-Read power-divergence statistic. Default is the recommended value of 2/3. |
A matrix of Bergsma's bias-corrected etimate of Cramer's , pairwise between columns of the input matrix, of class effect_sizes.
Bergsma W (2013). “A Bias-Correction for Cramér’s $V$ and Tschuprow’s $T$.” Journal of the Korean Statistical Society, 42, 323–328. doi:10.1016/j.jkss.2012.10.002.
x1 <- c(2, 0, 10, 11, 5) x2 <- c(1, 1, 17, 23, 3) x3 <- c(0, 0, 2, 81, 11) x <- matrix(c(x1, x2, x3), ncol = 3) VB_pair(x) VB_pair(x, lambda = 1)x1 <- c(2, 0, 10, 11, 5) x2 <- c(1, 1, 17, 23, 3) x3 <- c(0, 0, 2, 81, 11) x <- matrix(c(x1, x2, x3), ncol = 3) VB_pair(x) VB_pair(x, lambda = 1)
Given a matrix of cross-tabulated counts of observations which constitute a minimum threshold, returns the distribution of bias-corrected Cramer's by resampling from a truncated Poisson distribution, with rates determined column-wise (see VB, trunc_pois).
VB_trunc_pois( x, lambda = 2/3, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE, n_iter = 10^5 ) ## S3 method for class 'matrix' VB_trunc_pois( x, lambda = 2/3, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE, n_iter = 10^5 ) ## S3 method for class 'data.frame' VB_trunc_pois( x, lambda = 2/3, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE, n_iter = 10^5 ) ## S3 method for class 'xtabs' VB_trunc_pois( x, lambda = 2/3, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE, n_iter = 10^5 ) ## S3 method for class 'table' VB_trunc_pois( x, lambda = 2/3, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE, n_iter = 10^5 )VB_trunc_pois( x, lambda = 2/3, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE, n_iter = 10^5 ) ## S3 method for class 'matrix' VB_trunc_pois( x, lambda = 2/3, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE, n_iter = 10^5 ) ## S3 method for class 'data.frame' VB_trunc_pois( x, lambda = 2/3, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE, n_iter = 10^5 ) ## S3 method for class 'xtabs' VB_trunc_pois( x, lambda = 2/3, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE, n_iter = 10^5 ) ## S3 method for class 'table' VB_trunc_pois( x, lambda = 2/3, lambda_grid = seq(0.01, 100, by = 0.01), omit_zero = TRUE, n_iter = 10^5 )
x |
A matrix of cross-tabulated counts. |
lambda |
The value of lambda (default is 2/3) for the Cressie-Read power divergence statistic used to estimate the bias-corrected Cramer's |
lambda_grid |
The resolutation at which to sample for the rate parameter. Default is |
omit_zero |
Whether to omit zeros. Default is |
n_iter |
Number of samples of |
A contingency table of the same size as , with drawn according to a truncated Poisson distribution, .
x1 <- c(1,2,2,5,7,0,0) x2 <- c(9,2,5,15,7,90,0) x <- matrix(c(x1,x2), ncol = 2) VB_trunc_pois(x, n_iter = 10^2) VB_trunc_pois(x, omit_zero = FALSE, n_iter = 10^2)x1 <- c(1,2,2,5,7,0,0) x2 <- c(9,2,5,15,7,90,0) x <- matrix(c(x1,x2), ncol = 2) VB_trunc_pois(x, n_iter = 10^2) VB_trunc_pois(x, omit_zero = FALSE, n_iter = 10^2)
For two or more one-dimensional point processes, computes their Wasserstein distance via their empirical cumuluative density functions (e.c.d.f.), adjusting for sample size and the scale of their durations (Vasershtein 1969; Anderson 1962; Ramdas et al. 2017), using numerical quadrature:
where is a scaling coefficient, namely either the range of the point process or its support. More than two processes result in pairwise estimation of processes.
wass_R1( x1, x2 = NULL, scaled = FALSE, scaled_by = 0, quad_by = 0.001, perm = FALSE, n_perm = 10^5 ) ## S3 method for class 'numeric' wass_R1( x1, x2 = NULL, scaled = FALSE, scaled_by = 0, quad_by = 0.001, perm = FALSE, n_perm = 10^5 ) ## S3 method for class 'list' wass_R1( x1, x2 = NULL, scaled = FALSE, scaled_by = 0, quad_by = 0.001, perm = FALSE, n_perm = 10^5 )wass_R1( x1, x2 = NULL, scaled = FALSE, scaled_by = 0, quad_by = 0.001, perm = FALSE, n_perm = 10^5 ) ## S3 method for class 'numeric' wass_R1( x1, x2 = NULL, scaled = FALSE, scaled_by = 0, quad_by = 0.001, perm = FALSE, n_perm = 10^5 ) ## S3 method for class 'list' wass_R1( x1, x2 = NULL, scaled = FALSE, scaled_by = 0, quad_by = 0.001, perm = FALSE, n_perm = 10^5 )
x1 |
Either a list of vectors or a vector containing observations of sample 1. |
x2 |
If |
scaled |
Whether to scale the resulting Wasserstein R1 distance. Default is |
scaled_by |
The magnitude by which to scale the Wasserstein R1 distance, if |
quad_by |
The increment of sampling for performing quadrature. Default is |
perm |
Whether to perform a Monte Carlo permutation across all samples in the input. Default is |
n_perm |
Number of Monte Carlo permutations to perform. Default is |
For two vectors x1 and x2, the empirical scaled Wassertein R1 distance between the two e.c.d.f. of their samples. For a list of vectors input in x1, a matrix of the empirical scaled Wasserstein R1 distances pairwise between all vectors.
Anderson TW (1962).
“On the Distribution of the Two-Sample Cramer–von Mises Criterion.”
Annals of Mathematical Statistics, 33, 1148–1159.
doi:10.1214/aoms/1177704477.
Ramdas A, García Trillos N, Cuturi M (2017).
“On Wasserstein Two-Sample Testing and Related Families of Nonparametric Tests.”
Entropy, 19.47, 1–15.
doi:10.3390/e19020047.
Vasershtein LN (1969).
“Markov processes over denumerable products of spaces, describing large systems of automata.”
Problemy Peredači Informacii, 5, 64–72.