R/RcppExports.R

# This file was generated by Rcpp::compileAttributes
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' Sum all the values in the first dimension of a three dimensional integer
#' vector.
#'
#' \code{i_dim_sum} takes a three dimensional integer vector, fixes the values
#' of the second and third dimensions, and then sums the values of all the
#' entries in the vector with those two values for its second and third
#' dimensions.
#'
#' @param n A three dimensional integer vector.
#' @param j An integer that is a valid index of the second dimension of
#' \code{n}.
#' @param k An integer that is a valid index of the third dimension of
#' \code{n}.
i_dim_sum <- function(n, j, k) {
    .Call('maRkov_i_dim_sum', PACKAGE = 'maRkov', n, j, k)
}

#' Sum all the values in the second dimension of a three dimensional integer
#' vector.
#'
#' \code{j_dim_sum} takes a three dimensional integer vector, fixes the values
#' of the first and third dimensions, and then sums the values of all the
#' entries in the vector with those two values for its first and third
#' dimensions.
#'
#' @param n A three dimensional integer vector.
#' @param i An integer that is a valid index of the first dimension of
#' \code{n}.
#' @param k An integer that is a valid index of the third dimension of
#' \code{n}.
j_dim_sum <- function(n, i, k) {
    .Call('maRkov_j_dim_sum', PACKAGE = 'maRkov', n, i, k)
}

#' Sum all the values in the third dimension of a three dimensional integer
#' vector.
#'
#' \code{k_dim_sum} takes a three dimensional integer vector, fixes the values
#' of the first and second dimensions, and then sums the values of all the
#' entries in the vector with those two values for its first and second
#' dimensions.
#'
#' @param n A three dimensional integer vector.
#' @param i An integer that is a valid index of the first dimension of
#' \code{n}.
#' @param j An integer that is a valid index of the second dimension of
#' \code{n}.
k_dim_sum <- function(n, i, j) {
    .Call('maRkov_k_dim_sum', PACKAGE = 'maRkov', n, i, j)
}

#' Sum all the values in the first and third dimensions of a three dimensional
#' integer vector.
#'
#' \code{ik_dim_sum} takes a three dimensional integer vector, fixes the value
#' of the second dimension, and then sums the values of all the
#' entries in the vector with that value for its second dimension.
#'
#' @param n A three dimensional integer vector.
#' @param j An integer that is a valid index of the second dimension of
#' \code{n}.
ik_dim_sum <- function(n, j) {
    .Call('maRkov_ik_dim_sum', PACKAGE = 'maRkov', n, j)
}

#' Sum all the values in the second and third dimensions of a three dimensional
#' integer vector.
#'
#' \code{jkDimSum} takes a three dimensional integer vector, fixes the value
#' of the first dimension, and then sums the values of all the
#' entries in the vector with that value for its first dimension.
#'
#' @param n A three dimensional integer vector.
#' @param i An integer that is a valid index of the first dimension of
#' \code{n}.
jk_dim_sum <- function(n, i) {
    .Call('maRkov_jk_dim_sum', PACKAGE = 'maRkov', n, i)
}

#' Find the number of entries in a vector greater or equal to the value of the
#' first entry.
#'
#' \code{vec_greater_than} counts the number of entries in a numeric vector
#' \code{testStats} whose values are greater than that of the value of the
#' first element of the vector.
#'
#' @param testStats A one dimensional numeric vector.
#' @export
#' @useDynLib maRkov
vec_greater_than <- function(testStats) {
    .Call('maRkov_vec_greater_than', PACKAGE = 'maRkov', testStats)
}

#' Swap elements of multiple binary chains
#'
#' \code{swap_mult} is used to swap elements of multiple binary chains if doing
#' so maintains the same number of transitions between the two states of those
#' chains.
#'
#' \code{swap_mult} works by taking a two dimensional integer vector
#' \code{bin_chains} and \code{m}, a number of times to attempt swaps. It
#' generates random integers which are valid indices of the two dimensional
#' vector \code{bin_chains} and tries to swap the elements of the vector at
#' the indices that it generates, only doing so if this preserves the total
#' number of transitions between states. After attempting \code{m} swaps,
#' \code{swap_mult} returns the new, freshly swapped two dimensional vector of
#' binary chains.
#'
#' @param bin_chains A two dimensional integer vector with binary values.
#' @param m A positive nonzero integer value for the attempted number of swaps
#' to attempt on \code{bin_chains}.
swap_mult <- function(bin_chains, m) {
    .Call('maRkov_swap_mult', PACKAGE = 'maRkov', bin_chains, m)
}

#' Generate independent data from a set of binary chains.
#'
#' \code{multiple_metropolis} takes a set of binary chains of data in the form of an
#' integer matrix and returns a three dimensional integer vector with
#' with the first entry of the first dimension filled with the original set
#' of binary chains and the rest filled with independent chains generated by
#' \code{multiple_metropolis}.
#'
#' \code{multiple_metropolis} works by taking a supplied set of binary chains
#' \code{bin_chains} and attempting a number \code{m} swaps on entries of those
#' chains, only swapping if doing so maintains the number of transitions
#' between states that existed in the initial set of chains \code{bin_chains}.
#' After it does this, it repeats the process on the newly generated set of
#' binary chains of data \code{b} times, each time saving the new set of chains
#' in a three dimensional vector of data. The first entry of the first
#' dimension of this vector is used to store the original set of binary chains
#' \code{bin_chains}.
#'
#' @param bin_chains An integer matrix whose rows represent separate binary
#' chains of data.
#' @param m An integer value representing the number of swaps to be attempted.
#' @param b An integer value representing the number of new sets of data to be
#' generated.
#' @export
#' @useDynLib maRkov
multiple_metropolis <- function(bin_chains, m, b) {
    .Call('maRkov_multiple_metropolis', PACKAGE = 'maRkov', bin_chains, m, b)
}

#' Second order transition counts for multiple binary chains.
#'
#' \code{n_counts_multiple} counts the number of second order transitions in
#' a integer matrix whose rows represent individual binary chains. It returns
#' a three dimensional vector whose indices represent the type of transition,
#' and whose values represent the number of times that each transition occurs
#' in the set of chains.
#'
#' @param bin_chains A two dimensional integer vector, each of whose rows
#' represents a single binary chain of data.
#' @param n_chain_uniques The number of unique values in the set of chains
#' \code{bin_chains}, represented as an integer value.
n_counts_multiple <- function(bin_chains, n_chain_uniques) {
    .Call('maRkov_n_counts_multiple', PACKAGE = 'maRkov', bin_chains, n_chain_uniques)
}

#' Calculate the likelihood ratio test statistic for a set of binary chains of
#' data.
#'
#' \code{u6_test_stat} takes a two dimensional integer vector \code{bin_chains}
#' in which each row represents a single binary chain of data, and calculates
#' a likelihood ratio test statistic for the entire set.
#'
#' @param bin_chains A two dimensional integer vector where each row is a
#' separate binary chain of data.
#' @param n_chain_uniques An integer value representing the number of unique
#' elements in the set of chains \code{bin_chains}.
u6_test_stat <- function(bin_chains, n_chain_uniques) {
    .Call('maRkov_u6_test_stat', PACKAGE = 'maRkov', bin_chains, n_chain_uniques)
}

#' Calculate the Pearson's chi square test statistic for a set of binary chains
#' of data.
#'
#' \code{multiple_chi_sq_test_stat} takes a two dimensional integer vector
#' \code{bin_chains} in which each row represents a single binary chain of data,
#' and calculates a Pearson's chi square test statistic for the entire set.
#'
#' @param bin_chains A two dimensional integer vector where each row is a
#' separate binary chain of data.
#' @param n_chain_uniques An integer value representing the number of unique
#' elements in the set of chains \code{bin_chains}.
multiple_chi_sq_test_stat <- function(bin_chains, n_chain_uniques) {
    .Call('maRkov_multiple_chi_sq_test_stat', PACKAGE = 'maRkov', bin_chains, n_chain_uniques)
}

#' Indicate whether or not a run of a certain length exists starting at a
#' certain point.
#'
#' \code{multiple_indicate_run} takes a single binary chain \code{binChain}, a
#' valid index of that chain \code{i}, and a length of run \code{p} and tests
#' whether or not a run of that length starts at index \code{i}.
#'
#' @param binChain A one dimensional integer vector representing a binary chain
#' of data.
#' @param p An integer representing the length of run to test for.
#' @param i An integer representing a valid index of \code{binChain}.
multiple_indicate_run <- function(binChain, p, i) {
    .Call('maRkov_multiple_indicate_run', PACKAGE = 'maRkov', binChain, p, i)
}

#' Calculate the run test statistic for a set of binary chains of data and a
#' run of a certain length.
#'
#' \code{multiple_run_test_stat} takes a two dimensional integer vector
#' \code{bin_chains} in which each row represents a single binary chain of data,
#' and calculates a run test statistic for a run of length \code{p} for the
#' entire set.
#'
#' @param bin_chains A two dimensional integer vector where each row is a
#' separate binary chain of data.
#' @param p An integer value representing the length of run to test for.
multiple_run_test_stat <- function(bin_chains, p) {
    .Call('maRkov_multiple_run_test_stat', PACKAGE = 'maRkov', bin_chains, p)
}

#' Calculate likelihood ratio test statistics for many sets of binary chains of
#' data.
#'
#' \code{u6_test_stat_array} takes a three dimensional vector containing multiple
#' sets of binary chains of data, and returns a numeric vector with entries
#' corresponding to the likelihood ratio test statistics of each set of binary
#' chains of data.
#'
#' @param bin_chains A three dimensional vector containing sets of chains of
#' binary data.
#' @param n_chain_uniques An integer value representing the number of unique
#' elements in the set of chains \code{bin_chains}.
#' @export
#' @useDynLib maRkov
u6_test_stat_array <- function(bin_chains, n_chain_uniques) {
    .Call('maRkov_u6_test_stat_array', PACKAGE = 'maRkov', bin_chains, n_chain_uniques)
}

#' Calculate Pearson's chi square test statistics for many sets of binary
#' chains of data.
#'
#' \code{multiple_chi_sq_test_stat_array} takes a three dimensional vector
#' containing multiple sets of binary chains of data, and returns a numeric
#' vector with entries corresponding to the Pearson's chi square test
#' statistics of each set of binary chains of data.
#'
#' @param bin_chains A three dimensional vector containing sets of chains of
#' binary data.
#' @param n_chain_uniques An integer value representing the number of unique
#' elements in the set of chains \code{bin_chains}.
#' @export
#' @useDynLib maRkov
multiple_chi_sq_test_stat_array <- function(bin_chains, n_chain_uniques) {
    .Call('maRkov_multiple_chi_sq_test_stat_array', PACKAGE = 'maRkov', bin_chains, n_chain_uniques)
}

#' Calculate run test statistics for many sets of chains of binary data.
#'
#' \code{multiple_run_test_stat_array} takes a three dimensional integer vector
#' containing multiple sets of binary chains of data, and returns a numeric
#' vector with entries corresponding to the run test statistics for runs of
#' length p for each set of binary chains of data.
#'
#' @param bin_chains A three dimensional integer vector containing sets of
#' chains of binary data.
#' @param p An integer representing the length of run to test for.
#' @export
#' @useDynLib maRkov
multiple_run_test_stat_array <- function(bin_chains, p) {
    .Call('maRkov_multiple_run_test_stat_array', PACKAGE = 'maRkov', bin_chains, p)
}

#' Swap elements of single binary chains
#'
#' \code{swap} is used to swap elements of a single binary chain if doing so
#' maintains the same number of transitions between the two states of that
#' chain.
#'
#' \code{swap} takes a one dimensional vector of integers \code{bin_chain} and
#' an integer \code{m}. It attempts to swap elements of \code{bin_chain}
#' \code{m} times, each time only completing the swap if it does not affect the
#' number of transitions between states in the sequence.
#'
#' @param bin_chain A binary one dimensional integer vector.
#' @param m A integer value representing the number of swaps to attempt.
swap <- function(bin_chain, m) {
    .Call('maRkov_swap', PACKAGE = 'maRkov', bin_chain, m)
}

#' Generate independent data from a single binary chain.
#'
#' \code{metropolis} takes a single binary chain of data in the form of an
#' integer vector and generates \code{b} new independent chains of data,
#' placing all of them in an integer matrix with the original data in the first
#' row.
#'
#' \code{metropolis} works by taking the supplied \code{bin_chain}, and
#' attempting \code{m} swaps on it, only preforming a swap of elements if
#' doing so maintains the number of transitions between states in the resulting
#' chain. \code{metropolis} then takes the resulting chain, and attempts
#' \code{m} swaps on it again, then saving the resulting vector in a new row
#' of an output matrix. \code{metropolis} does this \code{b} times, each time
#' saving the resulting vector. Once all of the new data has been generated,
#' \code{metropolis} returns the newly built integer matrix, of which the first
#' row is the original chain of data \code{bin_chain}.
#'
#' @param bin_chain A single binary chain of data represented by an integer
#' vector.
#' @param m An integer representing the number of swaps to be attempted.
#' @param b An integer representing the number of new chains of data to be
#' generated.
#' @export
#' @useDynLib maRkov
metropolis <- function(bin_chain, m, b) {
    .Call('maRkov_metropolis', PACKAGE = 'maRkov', bin_chain, m, b)
}

#' Second order transition counts for a single binary chain.
#'
#' \code{n_counts} counts the number of second order transitions in a binary
#' chain of data, then returns a three dimensional vector whose indices
#' represent the type of transition, and whose values represent the number of
#' times that each transition occurs in the chain.
#'
#' @param bin_chain An integer vector representing a chain of data.
#' @param n_chain_uniques The number or unique values in the chain
#' \code{bin_chains}, represented as an integer value.
#' @export
#' @useDynLib maRkov
n_counts <- function(bin_chain, n_chain_uniques) {
    .Call('maRkov_n_counts', PACKAGE = 'maRkov', bin_chain, n_chain_uniques)
}

#' Calculates the likelihood ratio test statistic for a single binary chain.
#'
#' \code{u1_test_stat} takes a binary chain of data and calculates the likelihood
#' ratio test statistic associated with it.
#'
#' @param bin_chain A binary chain of data in the form of a one dimensional
#' integer vector.
#' @param n_chain_uniques A integer value representing the number of unique
#' values in \code{bin_chain}.
u1_test_stat <- function(bin_chain, n_chain_uniques) {
    .Call('maRkov_u1_test_stat', PACKAGE = 'maRkov', bin_chain, n_chain_uniques)
}

#' Calculates the Pearson's chi square test statistic for a single binary chain
#' .
#'
#' \code{chi_sq_test_stat} takes a binary chain of data and calculates the
#' Pearson's chi square test statistic associated with it.
#'
#' @param bin_chain A single binary chain of data in the form of an integer
#' vector.
#' @param n_chain_uniques A integer value representing the number of unique
#' values in \code{bin_chain}.
chi_sq_test_stat <- function(bin_chain, n_chain_uniques) {
    .Call('maRkov_chi_sq_test_stat', PACKAGE = 'maRkov', bin_chain, n_chain_uniques)
}

#' Indicate whether or not there is a run at a point in a integer vector.
#'
#' \code{indicate_run} takes an integer vector \code{bin_chain}, and two
#' integers, \code{p} and \code{i}, and tells the user if a run of length
#' \code{p} starting and index \code{i} in the form of a Boolean value.
#'
#' @param bin_chain A binary chain of data in the form of an integer vector.
#' @param p A integer value representing the length of the run to test for.
#' @param i A integer value representing the location in \code{bin_chain} to
#' test for a run starting at.
#' @export
#' @useDynLib maRkov
indicate_run <- function(bin_chain, p, i) {
    .Call('maRkov_indicate_run', PACKAGE = 'maRkov', bin_chain, p, i)
}

#' Calculate the run test statistic for a single binary chain.
#'
#' \code{run_test_stat} takes an integer vector \code{bin_chain} of a chain of
#' binary data, and a integer \code{p} representing the length of run to test
#' for. It returns the run test stat for that chain of data.
#'
#' @param bin_chain A binary chain of data in the form of an integer vector.
#' @param p An integer greater than one representing the length of run to test
#' for.
run_test_stat <- function(bin_chain, p) {
    .Call('maRkov_run_test_stat', PACKAGE = 'maRkov', bin_chain, p)
}

#' Calculate likelihood ratio test statistics for many binary chains.
#'
#' \code{u1_test_stat_array} takes an integer matrix with each row denoting a
#' binary chain of data and returns an integer vector with likelihood ratio test
#' statistics corresponding to each binary chain.
#'
#' @param bin_chains A two dimensional integer matrix with each row denoting a
#' individual binary chain of data.
#' @param n_chain_uniques An integer value representing the number of unique
#' values in the binary chains found in \code{bin_chains}.
u1_test_stat_array <- function(bin_chains, n_chain_uniques) {
    .Call('maRkov_u1_test_stat_array', PACKAGE = 'maRkov', bin_chains, n_chain_uniques)
}

#' Calculate the chi square test statistics for many single binary chains.
#'
#' \code{chi_sq_test_stat_array} takes a two dimensional matrix of many binary
#' chains of data and returns a numeric vector filled with a chi square test
#' statistic for each of them.
#'
#' @param bin_chains A integer matrix of binary chains of data, with each row
#' being a different chain.
#' @param n_chain_uniques A integer value representing the number of unique
#' values in \code{bin_chains}.
chi_sq_test_stat_array <- function(bin_chains, n_chain_uniques) {
    .Call('maRkov_chi_sq_test_stat_array', PACKAGE = 'maRkov', bin_chains, n_chain_uniques)
}

#' Calculate run test statistics for many binary chains.
#'
#' \code{run_test_stat_array} takes an integer matrix with each row denoting a
#' binary chain of data and returns an integer vector with run test statistics
#' for runs of length \code{p} corresponding to each binary chain.
#'
#' @param bin_chains A two dimensional integer matrix with each row denoting a
#' individual binary chain of data.
#' @param p An integer value representing the length of run to test for.
#' @export
#' @useDynLib maRkov
run_test_stat_array <- function(bin_chains, p) {
    .Call('maRkov_run_test_stat_array', PACKAGE = 'maRkov', bin_chains, p)
}
cwcartmell/maRkov documentation built on May 14, 2019, 1:37 p.m.