Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ RcppFNN <- function(target, rt, eps, lib, pred, E, tau = 1L, style = 0L, dist_me
.Call(`_pc_RcppFNN`, target, rt, eps, lib, pred, E, tau, style, dist_metric, k, threads, parallel_level, nb, nrows, na_comp)
}

RcppPC <- function(target, source, lib, pred, E, tau, style = 0L, num_neighbors = 4L, zero_tolerance = 0L, dist_metric = "euclidean", relative = TRUE, weighted = TRUE, threads = 1L, h = 0L, nb = NULL, nrows = NULL, na_comp = TRUE) {
.Call(`_pc_RcppPC`, target, source, lib, pred, E, tau, style, num_neighbors, zero_tolerance, dist_metric, relative, weighted, threads, h, nb, nrows, na_comp)
RcppPC <- function(source, target, lib, pred, E, tau, style = 0L, num_neighbors = 4L, zero_tolerance = 0L, dist_metric = "euclidean", relative = TRUE, weighted = TRUE, threads = 1L, h = 0L, nb = NULL, nrows = NULL, na_comp = TRUE) {
.Call(`_pc_RcppPC`, source, target, lib, pred, E, tau, style, num_neighbors, zero_tolerance, dist_metric, relative, weighted, threads, h, nb, nrows, na_comp)
}

RcppPCboot <- function(target, source, libsizes, lib, pred, E, tau, style = 0L, num_neighbors = 4L, zero_tolerance = 0L, dist_metric = "euclidean", boot = 99L, replace_sampling = TRUE, seed = 42L, relative = TRUE, weighted = TRUE, threads = 1L, parallel_level = 0L, verbose = FALSE, h = 0L, nb = NULL, nrows = NULL, na_comp = TRUE) {
.Call(`_pc_RcppPCboot`, target, source, libsizes, lib, pred, E, tau, style, num_neighbors, zero_tolerance, dist_metric, boot, replace_sampling, seed, relative, weighted, threads, parallel_level, verbose, h, nb, nrows, na_comp)
RcppPCboot <- function(source, target, libsizes, lib, pred, E, tau, style = 0L, num_neighbors = 4L, zero_tolerance = 0L, dist_metric = "euclidean", boot = 99L, replace_sampling = TRUE, seed = 42L, relative = TRUE, weighted = TRUE, threads = 1L, parallel_level = 0L, verbose = FALSE, h = 0L, nb = NULL, nrows = NULL, na_comp = TRUE) {
.Call(`_pc_RcppPCboot`, source, target, libsizes, lib, pred, E, tau, style, num_neighbors, zero_tolerance, dist_metric, boot, replace_sampling, seed, relative, weighted, threads, parallel_level, verbose, h, nb, nrows, na_comp)
}

RcppPCops <- function(target, source, lib, pred, E, tau, k, maximize = "positive", style = 0L, zero_tolerance = 0L, dist_metric = "euclidean", relative = TRUE, weighted = TRUE, threads = 1L, parallel_level = 0L, h = 0L, nb = NULL, nrows = NULL, na_comp = TRUE) {
.Call(`_pc_RcppPCops`, target, source, lib, pred, E, tau, k, maximize, style, zero_tolerance, dist_metric, relative, weighted, threads, parallel_level, h, nb, nrows, na_comp)
RcppPCops <- function(source, target, lib, pred, E, tau, k, maximize = "positive", style = 0L, zero_tolerance = 0L, dist_metric = "euclidean", relative = TRUE, weighted = TRUE, threads = 1L, parallel_level = 0L, h = 0L, nb = NULL, nrows = NULL, na_comp = TRUE) {
.Call(`_pc_RcppPCops`, source, target, lib, pred, E, tau, k, maximize, style, zero_tolerance, dist_metric, relative, weighted, threads, parallel_level, h, nb, nrows, na_comp)
}

12 changes: 6 additions & 6 deletions R/ops.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.ops_ts = \(data, target, source, E = 3:5, k = E, tau = 1, style = 1, lib = NULL, pred = NULL,
.ops_ts = \(data, source, target, E = 3:5, k = E, tau = 1, style = 1, lib = NULL, pred = NULL,
maximize = c("dark", "positive", "negative"), dist.metric = c("euclidean", "manhattan", "maximum"),
zero.tolerance = max(k), relative = TRUE, weighted = TRUE, threads = length(E), higher.parallel = TRUE, h = 0, ...) {
maximize = match.arg(maximize)
Expand All @@ -8,11 +8,11 @@
if (is.null(lib)) lib = which(!(is.na(tv) | is.na(sv)))
if (is.null(pred)) pred = lib

return(RcppPCops(tv, sv, lib, pred, E, tau, k, maximize, style, zero.tolerance,
return(RcppPCops(sv, tv, lib, pred, E, tau, k, maximize, style, zero.tolerance,
dist.metric, relative, weighted, threads, higher.parallel, h, NULL, NULL))
}

.ops_lattice = \(data, target, source, E = 3:5, k = E+1, tau = 1, style = 1, lib = NULL, pred = NULL,
.ops_lattice = \(data, source, target, E = 3:5, k = E+1, tau = 1, style = 1, lib = NULL, pred = NULL,
maximize = c("dark", "positive", "negative"), dist.metric = c("euclidean", "manhattan", "maximum"),
zero.tolerance = max(k), relative = TRUE, weighted = TRUE, threads = length(E), higher.parallel = TRUE, detrend = FALSE, nb = NULL, ...) {
if (is.null(nb)) nb = sdsfun::spdep_nb(data)
Expand All @@ -23,11 +23,11 @@
if (is.null(lib)) lib = which(!(is.na(tv) | is.na(sv)))
if (is.null(pred)) pred = lib

return(RcppPCops(tv, sv, lib, pred, E, tau, k, maximize, style, zero.tolerance,
return(RcppPCops(sv, tv, lib, pred, E, tau, k, maximize, style, zero.tolerance,
dist.metric, relative, weighted, threads, higher.parallel, 0, nb, NULL))
}

.ops_grid = \(data, target, source, E = 3:5, k = E+1, tau = 1, style = 1, lib = NULL, pred = NULL,
.ops_grid = \(data, source, target, E = 3:5, k = E+1, tau = 1, style = 1, lib = NULL, pred = NULL,
maximize = c("positive", "negative", "dark"), dist.metric = c("euclidean", "manhattan", "maximum"),
zero.tolerance = max(k), relative = TRUE, weighted = TRUE, threads = length(E), higher.parallel = TRUE, detrend = FALSE, ...) {
maximize = match.arg(maximize)
Expand All @@ -37,7 +37,7 @@
if (is.null(lib)) lib = which(!(is.na(tv) | is.na(sv)))
if (is.null(pred)) pred = lib

return(RcppPCops(tv, sv, lib, pred, E, tau, k, maximize, style, zero.tolerance, dist.metric,
return(RcppPCops(sv, tv, lib, pred, E, tau, k, maximize, style, zero.tolerance, dist.metric,
relative, weighted, threads, higher.parallel, 0, NULL, terra::nrow(data)))
}

Expand Down
18 changes: 9 additions & 9 deletions R/pc.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.pc_ts = \(data, target, source, libsizes = NULL, E = 3, k = E, tau = 1, style = 1, lib = NULL, pred = NULL, boot = 99,
.pc_ts = \(data, source, target, libsizes = NULL, E = 3, k = E, tau = 1, style = 1, lib = NULL, pred = NULL, boot = 99,
replace = FALSE, seed = 42L, dist.metric = c("euclidean", "manhattan", "maximum"), zero.tolerance = max(k),
relative = TRUE, weighted = TRUE, threads = length(libsizes), higher.parallel = TRUE, verbose = TRUE, h = 0, ...) {
dist.metric = match.arg(dist.metric)
Expand All @@ -8,15 +8,15 @@
if (is.null(pred)) pred = lib

if (is.null(libsizes)) {
return(RcppPC(tv, sv, lib, pred, E, tau, style, k, zero.tolerance,
return(RcppPC(sv, tv, lib, pred, E, tau, style, k, zero.tolerance,
dist.metric, relative, weighted, threads, h, NULL, NULL))
} else {
return(RcppPCboot(tv, sv, libsizes, lib, pred, E, tau, style, k, zero.tolerance, dist.metric, boot,
return(RcppPCboot(sv, tv, libsizes, lib, pred, E, tau, style, k, zero.tolerance, dist.metric, boot,
replace, seed, relative, weighted, threads, higher.parallel, verbose, h, NULL, NULL))
}
}

.pc_lattice = \(data, target, source, libsizes = NULL, E = 3, k = E+1, tau = 1, style = 1, lib = NULL, pred = NULL, boot = 99,
.pc_lattice = \(data, source, target, libsizes = NULL, E = 3, k = E+1, tau = 1, style = 1, lib = NULL, pred = NULL, boot = 99,
replace = FALSE, seed = 42L, dist.metric = c("euclidean", "manhattan", "maximum"), zero.tolerance = max(k),
relative = TRUE, weighted = TRUE, threads = length(libsizes), higher.parallel = TRUE, verbose = TRUE, detrend = FALSE, nb = NULL, ...) {
if (is.null(nb)) nb = sdsfun::spdep_nb(data)
Expand All @@ -27,15 +27,15 @@
if (is.null(pred)) pred = lib

if (is.null(libsizes)) {
return(RcppPC(tv, sv, lib, pred, E, tau, style, k, zero.tolerance,
return(RcppPC(sv, tv, lib, pred, E, tau, style, k, zero.tolerance,
dist.metric, relative, weighted, threads, 0, nb, NULL))
} else {
return(RcppPCboot(tv, sv, libsizes, lib, pred, E, tau, style, k, zero.tolerance, dist.metric, boot,
return(RcppPCboot(sv, tv, libsizes, lib, pred, E, tau, style, k, zero.tolerance, dist.metric, boot,
replace, seed, relative, weighted, threads, higher.parallel, verbose, 0, nb, NULL))
}
}

.pc_grid = \(data, target, source, libsizes = NULL, E = 3, k = E+1, tau = 1, style = 1, lib = NULL, pred = NULL, boot = 99,
.pc_grid = \(data, source, target, libsizes = NULL, E = 3, k = E+1, tau = 1, style = 1, lib = NULL, pred = NULL, boot = 99,
replace = FALSE, seed = 42L, dist.metric = c("euclidean", "manhattan", "maximum"), zero.tolerance = max(k),
relative = TRUE, weighted = TRUE, threads = length(libsizes), higher.parallel = TRUE, verbose = TRUE, detrend = FALSE, ...) {
dist.metric = match.arg(dist.metric)
Expand All @@ -45,10 +45,10 @@
if (is.null(pred)) pred = lib

if (is.null(libsizes)) {
return(RcppPC(tv, sv, lib, pred, E, tau, style, k, zero.tolerance, dist.metric,
return(RcppPC(sv, tv, lib, pred, E, tau, style, k, zero.tolerance, dist.metric,
relative, weighted, threads, 0, NULL, terra::nrow(data)))
} else {
return(RcppPCboot(tv, sv, libsizes, lib, pred, E, tau, style, k, zero.tolerance, dist.metric, boot, replace,
return(RcppPCboot(sv, tv, libsizes, lib, pred, E, tau, style, k, zero.tolerance, dist.metric, boot, replace,
seed, relative, weighted, threads, higher.parallel, verbose, 0, NULL, terra::nrow(data)))
}
}
Expand Down
10 changes: 5 additions & 5 deletions man/ops.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/pc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions src/PC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// Wrapper function to perform pattern causality analysis
// [[Rcpp::export(rng = false)]]
Rcpp::List RcppPC(
const Rcpp::NumericVector& target,
const Rcpp::NumericVector& source,
const Rcpp::NumericVector& target,
const Rcpp::IntegerVector& lib,
const Rcpp::IntegerVector& pred,
const Rcpp::IntegerVector& E,
Expand All @@ -31,9 +31,9 @@ Rcpp::List RcppPC(
bool na_comp = true)
{
// --- Input Conversion and Validation ---
std::vector<double> tg = Rcpp::as<std::vector<double>>(target);
std::vector<double> sg = Rcpp::as<std::vector<double>>(source);
const size_t n_obs = tg.size();
std::vector<double> tg = Rcpp::as<std::vector<double>>(target);
const size_t n_obs = sg.size();

// Convert library indices (R 1-based → C++ 0-based)
std::vector<size_t> lib_std = Rcpp::as<std::vector<size_t>>(lib);
Expand Down Expand Up @@ -431,8 +431,8 @@ Rcpp::List RcppPC(
// Wrapper function to perform bootstrapped pattern causality analysis
// [[Rcpp::export(rng = false)]]
Rcpp::List RcppPCboot(
const Rcpp::NumericVector& target,
const Rcpp::NumericVector& source,
const Rcpp::NumericVector& target,
const Rcpp::IntegerVector& libsizes,
const Rcpp::IntegerVector& lib,
const Rcpp::IntegerVector& pred,
Expand All @@ -456,9 +456,9 @@ Rcpp::List RcppPCboot(
bool na_comp = true)
{
// --- Input Conversion and Validation --------------------------------------
std::vector<double> tg = Rcpp::as<std::vector<double>>(target);
std::vector<double> sg = Rcpp::as<std::vector<double>>(source);
const size_t n_obs = tg.size();
std::vector<double> tg = Rcpp::as<std::vector<double>>(target);
const size_t n_obs = sg.size();

// Convert library indices (R 1-based → C++ 0-based)
std::vector<size_t> lib_std = Rcpp::as<std::vector<size_t>>(lib);
Expand Down Expand Up @@ -1065,8 +1065,8 @@ Rcpp::IntegerVector OptPCparm(const Rcpp::NumericMatrix& Emat,
// Wrapper function to perform optimal parameters search for pattern causality analysis
// [[Rcpp::export(rng = false)]]
Rcpp::List RcppPCops(
const Rcpp::NumericVector& target,
const Rcpp::NumericVector& source,
const Rcpp::NumericVector& target,
const Rcpp::IntegerVector& lib,
const Rcpp::IntegerVector& pred,
const Rcpp::IntegerVector& E,
Expand All @@ -1086,9 +1086,9 @@ Rcpp::List RcppPCops(
bool na_comp = true)
{
// Input Conversion and Validation --------------------------------------
std::vector<double> tg = Rcpp::as<std::vector<double>>(target);
std::vector<double> sg = Rcpp::as<std::vector<double>>(source);
const size_t n_obs = tg.size();
std::vector<double> tg = Rcpp::as<std::vector<double>>(target);
const size_t n_obs = sg.size();

// Convert library indices (R 1-based → C++ 0-based)
std::vector<size_t> lib_std = Rcpp::as<std::vector<size_t>>(lib);
Expand Down
Loading
Loading