PPCKO: Principal Predictive Components for Estimating an Autoregressive Operator
 
Loading...
Searching...
No Matches
parameters_wrapper.hpp File Reference

Contains methods to check and wrap R-inputs into PPCKO-coherent ones. More...

#include <vector>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <utility>
#include <string>
#include <stdexcept>
#include "traits_ko.hpp"
#include "mesh.hpp"

Go to the source code of this file.

Enumerations

enum  REM_NAN { NR = 0 , MR = 1 , ZR = 2 }
 The available strategy for removing non-dummy NaNs. More...
 

Functions

std::string wrap_string_CV_to_be_printed (const std::string &id_cv)
 Creating a string to print on the screen which PPCKO version is being used.
 
void check_threshold_ppc (const double &threshold_ppc)
 Check if 'threshold_ppc' input is between 0 and 1. Eventually, raises and error.
 
void check_alpha (const double &alpha)
 Check if 'alpha' input is greater than 0. Eventually, raises and error.
 
void check_k (const int &k, const int &max_k)
 Check if 'k' input is an integer between 0 and the number of available evaluations of the functional object. Eventually, raises and error.
 
void check_solver (bool solver_ex, const std::string &id_cv, int k)
 Check if, if using 'gep_solver', the number of PPCs is not retrieved through explanatory power criterion. Eventually, raises and error.
 
std::vector< double > wrap_alpha_vec (Rcpp::Nullable< Rcpp::NumericVector > alpha_vec)
 Wrapping the R-vector representing the regularization parameter input space into a coherent C++ object, checking parameters consistency, eventually throwing an error, eventually sorting them in increasing order.
 
std::vector< int > wrap_k_vec (Rcpp::Nullable< Rcpp::IntegerVector > k_vec, int k_max)
 Wrapping the R-vector representing the number of PPCs input space into a coherent C++ object, checking parameters consistency, eventually throwing an error, eventually sorting them in increasing order.
 
std::vector< double > wrap_disc_ev (Rcpp::Nullable< Rcpp::NumericVector > disc_ev, double a, double b, int dim)
 Wrapping the points over which the discrete evaluations of the functional object are available. Check consistency of domain extremes and passed points, eventualy throwing an error.
 
std::pair< int, int > wrap_sizes_set_CV (Rcpp::Nullable< int > min_size_ts, Rcpp::Nullable< int > max_size_ts, int number_time_instants)
 Wrapping the minimum and maximum dimension of the training set, checking their consitency, eventually raising an error.
 
int wrap_num_thread (Rcpp::Nullable< int > num_threads)
 Wrapping the number of threads for OMP.
 
REM_NAN wrap_id_rem_nans (Rcpp::Nullable< std::string > id_rem_nan)
 Wrapping the strategy for handling non-dummy NaNs.
 

Detailed Description

Contains methods to check and wrap R-inputs into PPCKO-coherent ones.

Author
Andrea Enrico Franzoni

Enumeration Type Documentation

◆ REM_NAN

enum REM_NAN

The available strategy for removing non-dummy NaNs.

Enumerator
NR 

Not replacing NaN: not to be used by the user, necessary for handling dummy NaNs.

MR 

Replacing nans with mean (could change the mean of the distribution)

ZR 

Replacing nans with 0s (could change the sd of the distribution)

Function Documentation

◆ check_alpha()

void check_alpha ( const double & alpha)
inline

Check if 'alpha' input is greater than 0. Eventually, raises and error.

Parameters
alpharegularization parameter

◆ check_k()

void check_k ( const int & k,
const int & max_k )
inline

Check if 'k' input is an integer between 0 and the number of available evaluations of the functional object. Eventually, raises and error.

Parameters
knumber of PPCs passed as parameter
max_kthe maximum value for 'k' (number of available evaluations of the functional object)

◆ check_solver()

void check_solver ( bool solver_ex,
const std::string & id_cv,
int k )
inline

Check if, if using 'gep_solver', the number of PPCs is not retrieved through explanatory power criterion. Eventually, raises and error.

Parameters
solver_ex'true' if using ex_solver
id_cvwhich PPCKO version is used
kthe input parameter k

◆ check_threshold_ppc()

void check_threshold_ppc ( const double & threshold_ppc)
inline

Check if 'threshold_ppc' input is between 0 and 1. Eventually, raises and error.

Parameters
threshold_ppcrequested explanatory power for the predictor

◆ wrap_alpha_vec()

std::vector< double > wrap_alpha_vec ( Rcpp::Nullable< Rcpp::NumericVector > alpha_vec)
inline

Wrapping the R-vector representing the regularization parameter input space into a coherent C++ object, checking parameters consistency, eventually throwing an error, eventually sorting them in increasing order.

Parameters
alpha_vecRcpp::Nullable<Rcpp::NumericVector>
Returns
the R-vector is shifted to a std::vector<double>
Note
If the input is 'NULL': a vector in logarithmic scale, from 10 to the power of -10 up to the power of 11 is generated

◆ wrap_disc_ev()

std::vector< double > wrap_disc_ev ( Rcpp::Nullable< Rcpp::NumericVector > disc_ev,
double a,
double b,
int dim )
inline

Wrapping the points over which the discrete evaluations of the functional object are available. Check consistency of domain extremes and passed points, eventualy throwing an error.

Parameters
disc_evRcpp::Nullable<Rcpp::NumericVector> containing the domain points
aleft domain extreme
bright domain extreme
dimthe number of discrete evaluations
Returns
an std::vector<double>
Note
If the 'disc_ev' is 'NULL': an equally spaced grid from 'a' to 'b' is generated. For surfaces, the two dimensions are wrapped separately

◆ wrap_id_rem_nans()

REM_NAN wrap_id_rem_nans ( Rcpp::Nullable< std::string > id_rem_nan)
inline

Wrapping the strategy for handling non-dummy NaNs.

Parameters
id_rem_nanstring indicating the straegy for removing non-dummy NaNs
Returns
the correpsonding value of 'REM_NAN' (default: 'MR')

◆ wrap_k_vec()

std::vector< int > wrap_k_vec ( Rcpp::Nullable< Rcpp::IntegerVector > k_vec,
int k_max )
inline

Wrapping the R-vector representing the number of PPCs input space into a coherent C++ object, checking parameters consistency, eventually throwing an error, eventually sorting them in increasing order.

Parameters
k_vecRcpp::Nullable<Rcpp::IntegerVector>
k_maxthe maximum number possible of retained PPCs
Returns
the R-vector is shifted to a std::vector<int>
Note
If the input is 'NULL': a vector from 1 to 'k_max' is generated

◆ wrap_num_thread()

int wrap_num_thread ( Rcpp::Nullable< int > num_threads)
inline

Wrapping the number of threads for OMP.

Parameters
num_threadsindicates how many threads to be used by multi-threading directives.
Returns
the number of threads

if omp is not included: will return 1. If not, a number going from 1 up to the maximum cores available by the machine used (default, or if the input is smaller than 1 or bigger than the maximum number of available cores)

Note
omp requested

◆ wrap_sizes_set_CV()

std::pair< int, int > wrap_sizes_set_CV ( Rcpp::Nullable< int > min_size_ts,
Rcpp::Nullable< int > max_size_ts,
int number_time_instants )
inline

Wrapping the minimum and maximum dimension of the training set, checking their consitency, eventually raising an error.

Parameters
min_size_tsminimum dimension of the training set
max_size_tsmaximum dimension of the training set
number_time_instantsnumber of total time instants available
Returns
a pair containig minimum and maximum dimension training set
Note
  • 'min_dim_ts' has to be at least 2, but less than 'max_size_ts'. Default value: ceil of 'number_time_instants'/2
  • 'max_size_ts' has to be greater than 'min_dim_ts' but less than number_time_instants. Default value: 'number_time_instants' (to be consistent with Eigen, look at the reference to better understand this choice)
See also
train_validation_set_strategy()

◆ wrap_string_CV_to_be_printed()

std::string wrap_string_CV_to_be_printed ( const std::string & id_cv)
inline

Creating a string to print on the screen which PPCKO version is being used.

Parameters
id_cvstring indicating the version used
Returns
a string to be printed