Schema
This page describes request and response schema. Note that the types indicated are Bond types. These will be translated to whichever language binding you are using. For example, Bond IDL vector
How to understand the schema
In the brief code snippet below, notice that the pn.Lm
instance is created and the expected response is pn.O_lm
.
// C#
// create request ticket
var model = new pn.Lm
{
kind = pn.Kind.OLS,
is_async = false,
X = X,
Y = Y,
add_intercept = true,
x_labels = new List<string>(new string[] { }),
y_labels = new List<string>(new string[] { })
};
// send request
var request = Pack<pn.Lm>.Run(ref model, pc.RequestWork);
pc.Push(ref request);
// wait on response (number of tries).
var (rc, zf) = Receiver.Receive(Receiver.ReceiveFrom.Sync, 200);
var (metadata, response) = Unpacker<pn.O_lm>.TryUnpack(rc, ref zf);
When you send a request type, you unpack a corresponding response type.
While we could’ve avoided this additional bit of complexity, it would’ve come at a performance cost. i.e. we peek at the payload in the engine and route the pipelines.
Matrix
Matrix
{
vector<double> v
uint64 nr
uint64 nc
}
Note that when defining your Matrix translation routines, the outer loop should iterate over columns:
// C++
// your 2d matrix N -> bond matrix M
for (auto c = 0 c < NC c++)
for (auto r = 0 r < NR r++)
M.v.emplace_back(N(r, c))
Lasso Crossvalidation
Request
Cvlasso
{
Kind kind CVLASSO
bool is_async true
Matrix Y
Matrix X
bool standardize
nullable<Matrix> opt_weights
uint32 kfolds
uint32 points_on_path
vector<string> y_labels
vector<string> x_labels
uint32 timeout_minutes
}
Response
O_cvlasso
{
Kind kind CVLASSO
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
vector<double> coeffs
vector<double> yh
double mse
double alpha
double lambda
vector<string> y_labels
vector<string> x_labels
vector<double> lambda_path
Matrix mse_grid
Matrix reg_path
bool cancelled_or_timedout
}
Ridge Crossvalidation
Request
Cvridge
{
Kind kind CVRIDGE
bool is_async true
Matrix Y
Matrix X
uint32 kfolds
uint32 points_on_path
vector<string> y_labels
vector<string> x_labels
uint32 timeout_minutes
}
Response
O_cvridge
{
Kind kind CVRIDGE
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
vector<double> coeffs
vector<double> yh
double mse
double alpha
vector<string> y_labels
vector<string> x_labels
vector<double> alpha_path
Matrix mse_grid
Matrix reg_path
bool cancelled_or_timedout
}
Garch MCMC
Request
struct GarchMcmc
{
Kind kind GARCHMCMC
bool is_async true
vector<double> e
GarchMcmcSpec spec [p1q1, p2q1]
uint32 draws
uint32 burnin
uint32 timeout_minutes
}
Response
struct O_garchmcmc
{
Kind kind GARCHMCMC
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
vector<double> coeff
vector<double> serr
GarchMcmcSpec spec [p2q1, p1q1]
vector<string> coeff_tag
vector<double> vol
bool cancelled_or_timedout
}
Stochastic Volatility
Request
struct Stovol
{
Kind kind STOVOL
bool is_async true
vector<double> e
StovolSpec spec [sv1, sv2]
uint32 draws
uint32 burnin
uint32 timeout_minutes
}
Response
struct O_stovol : ModelOut
{
Kind kind STOVOL
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
vector<double> coeff
vector<double> serr
StovolSpec spec [sv1, sv2]
vector<string> coeff_tag
vector<double> vol
bool cancelled_or_timedout
}
Linear Models
Request
Lm
{
Kind kind [OLS, OLST, LAD, R_ANDREW, R_HUBER, R_RAMSAY, R_TUKEY]
bool is_async false
Matrix Y
Matrix X
bool add_intercept
double alpha
vector<string> y_labels
vector<string> x_labels
}
Response
O_lm
{
Kind kind
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
vector<double> yh
Matrix results_block
vector<string> y_labels
vector<string> x_labels
double rse
uint64 df
double rsq
double rsq_adj
double f_stat
double f_prob
double dw
vector<double> resid
vector<double> resid_student
vector<double> hat
vector<double> dffits
Matrix dfbetas
}
Autoregressive Model
Request
Ar
{
Kind kind AR
bool is_async false
Matrix Y
uint32 lags
}
Response
O_ar
{
Kind kind AR
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
Matrix yh
Matrix coeffs
double mse
}
ACF/PACF
Request
CorFunc
{
Kind kind [ACF, PACF]
bool is_async false
vector<double> v
}
Response
O_autocor
{
Kind kind [ACF, PACF]
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
vector<double> cors
Pair<double, double> bounds
vector<uint32> lags
}
One Hot Encoding
Request
EncodeOneHot
{
Pair<vector<string>, Matrix<string>> categorical_container
Pair<vector<string>, Matrix<double>> numerical_container; // this will not change
bool to_lower = true
string missing_identifier = "NA"
uint32 max_cols = 500
}
Response
O_encodeonehot
{
vector<Pair<string, vector<uint64>>> sparse_container
Pair<vector<string>, Matrix<double>> dense_container
uint64 num_rows
}
Garch
Request
Garch
{
Kind kind GARCH
bool is_async false
vector<double> e
uint32 p
uint32 q
MethodOpt method_opt [SBPLX, NELDERMEAD]
double xtol = 0.0001;
}
Response
O_garch
{
Kind kind GARCH
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
vector<double> coeff
vector<double> serr
vector<double> tstat
vector<double> pval
vector<double> vol
vector<string> coeff_tag
}
Ridge Regression
Request
Ridge
{
Kind kind RIDGE
bool is_async false
Matrix Y
Matrix X
double alpha
vector<string> y_labels
vector<string> x_labels
}
Response
O_ridge
{
Kind kind RIDGE
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
vector<double> coeffs
vector<double> yh
double mse
double alpha
vector<string> y_labels
vector<string> x_labels
}
Lasso Regression
Request
Lasso
{
Kind kind LASSO
bool is_async false
Matrix Y
Matrix X
nullable<Matrix> opt_weights
double lambda
double alpha
bool standardize
vector<string> y_labels
vector<string> x_labels
}
Response
O_lasso
{
Kind kind LASSO
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
vector<double> coeffs
vector<double> yh
double mse
double alpha
double lambda
vector<string> y_labels
vector<string> x_labels
}
Johansen Cointegration
Request
JohansenTest
{
Kind kind JOHANSENCOINT
bool is_async false
Matrix Y
JohansenModel model [H, HS, H1, H1S, H2]
JohansenTestType test_type [Trace]
uint32 lags
double alpha
vector<string> labels
}
Response
O_johansen
{
Kind kind JOHANSENCOINT
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
string specification
vector<uint64> ranks
vector<bool> decisions
vector<double> test_statistics
vector<double> p_values
vector<double> eigenvalues
Matrix X
vector<O_johansen_block> johansen_blocks
vector<string> labels
}
The sub-blocks are returned johansen_blocks
as follows:
O_johansen_block
{
uint64 coint_rank
Matrix A
vector<Pair<string, Matrix>> Bs
Matrix rho0
Matrix gam0
Matrix rho1
Matrix gam1
Matrix residuals
Matrix covariance
Matrix eigenvector
1double eigenvalue
1double restricted_loglik
1double unrestricted_loglik
}
Canonical Correlation Analysis
Request
Cca
{
Kind kind CCA
bool is_async false
Matrix X
Matrix Y
vector<string> x_labels
vector<string> y_labels
}
Response
O_cca
{
Kind kind CCA
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
Matrix A
Matrix B
Matrix U
Matrix V
vector<double> r
vector<int32> df1
vector<int32> df2
vector<double> F
vector<double> pF
vector<double> chisq
1vector<double> pchisq
1vector<double> wilks
1vector<string> x_labels
1vector<string> y_labels
}
Partial Least Squares Regression
Request
Plsr
{
Kind kind PLSR
bool is_async false
Matrix X
Matrix Y
uint32 n
vector<string> x_labels
vector<string> y_labels
}
Response
O_plsr
{
Kind kind PlSR
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
Matrix x_loadings
Matrix y_loadings
Matrix x_scores
Matrix y_scores
Matrix beta
Matrix weights
Matrix t2
Matrix pct_var
Matrix x_residuals
Matrix y_residuals
1vector<string> x_labels
1vector<string> y_labels
}
Singular Value Decomposition
Request
Svd
{
Kind kind SVD
bool is_async false
Matrix X
uint32 n
bool center
SvdMethod method [BDC, Jacobi]
}
Response
O_svd
{
Kind kind SVD
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
Matrix U
vector<double> S
Matrix V
}
Non-negative Matrix Factorization
Request
Nmf
{
Kind kind NMF
bool is_async false
Matrix X
uint16 n
uint32 max_iter
NmfMethod method [ALS, KL, LS]
}
Response
O_nmf
{
Kind kind NMF
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
Matrix W
Matrix H
double rmse
}
Principal Component Analysis
Request
Pca
{
Kind kind PCA
bool is_async false
Matrix X
uint32 n
bool center
}
Response
O_pca
{
Kind kind PCA
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
Matrix score
vector<double> singular_values
Matrix coef
vector<double> hotelling_tsq
vector<double> proportion
}
QR Decomposition
Request
Qr
{
Kind kind QR
bool is_async false
Matrix X
}
Response
O_qr
{
Kind kind QR
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
Matrix Q
Matrix R
}
Factor Analysis
Request
ProcrustesSpec
{
bool has_value
ProcrustesType procrustes_type [oblique, orthogonal]
Matrix target
}
Factan
{
Kind kind FACTAN
bool is_async false
Matrix M
uint32 k
Xtype t [data_matrix]
RotationType rotation [none, orthomax, varimax, quartimax, equamax, parsimax, procrustes, promax]
ProcrustesSpec procrustes_spec
ScoresType scores [wls, regression]
nullable<double> opt_power
}
Response
O_factan
{
Kind kind FACTAN
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
Matrix Lam
Matrix T
Matrix F
vector<double> psi
double loglik
uint32 df
Pair<string, double> statistic
double p
}
Generalized Linear Model
Request
Glm
{
Kind kind GLM
bool is_async false
Matrix Y
Matrix X
bool add_intercept
Family family [binomial, gaussian, gamma, inverse_gaussian, poisson]
Link link [canonical, c_log_log, identity, inv_mu_sq, logit, log, log_log, probit, reciprocal]
vector<string> y_labels
vector<string> x_labels
}
Response
O_glm
{
Kind kind GLM
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
Matrix tbl
nullable<double> resid_dev
nullable<double> resid_null
uint16 fisher_it
nullable<bool> convergence
vector<string> y_labels
vector<string> x_labels
}
One Way ANOVA
Request
Anova1
{
Kind kind HTANOVA1
bool is_async false
Matrix X
nullable<vector<string>> opt_groups
AnovaMethod method [classical, kruskalwallis]
}
Response
O_onewayanova
{
Kind kind HTANOVA1
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
Matrix tbl
Pair<string, vector<double>> means
vector<uint64> n
uint64 df
double mse
double rmse
Pair<string, double> statistic
vector<string> y_labels
vector<string> x_labels
}
Two Way ANOVA
Request
Anova2
{
Kind kind HTANOVA2
bool is_async false
Matrix X
uint64 rep_size
}
Response
O_twowayanova
{
Kind kind HTANOVA2
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
Matrix tbl
double sigmasq
uint64 coln
uint64 rown
double p
uint64 df
vector<string> y_labels
vector<string> x_labels
}
Levene Test
Request
Levene
{
Kind kind HTLEVENE
bool is_async false
vector<double> data
vector<string> groups
double alpha
}
Response
O_levene
{
Kind kind HTLEVENE
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
double p
bool h
Pair<string, double> statistic
Pair<uint64, uint64> df
}
Friedman Test
Request
Friedman
{
Kind kind HTFRDMAN
bool is_async false
Matrix X
uint64 rep_size
}
Response
O_friedman
{
Kind kind HTFRDMAN
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
Matrix tbl
uint64 n
uint64 reps
vector<double> meanranks
double sigma
vector<string> y_labels
vector<string> x_labels
}
Ranksum Test
Request
Ranksum
{
Kind kind HTRANKSUM
bool is_async false
vector<double> X
vector<double> Y
double alpha
TailtypeLR t [both, right, left]
}
Response
O_testloc
{
Kind kind HTRANKSUM
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
double p
bool h
Pair<string, double> statistic
Pair<string, double> statistic2
Pair<double, double> ci
}
Signrank Test
Request
Signrank
{
Kind kind HTSIGNRANK
bool is_async false
vector<double> v
vector<double> mY
double alpha
TailtypeLR t [both, right, left]
}
Response
O_testloc
{
Kind kind HTSIGNRANK
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
double p
bool h
Pair<string, double> statistic
Pair<string, double> statistic2
Pair<double, double> ci
}
Sign Test
Request
Signtest
{
Kind kind HTSIGNTEST
bool is_async false
vector<double> v
vector<double> mY
double alpha
TailtypeLR t [both, right, left]
}
Response
O_testloc
{
Kind kind HTSIGNTEST
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
double p
bool h
Pair<string, double> statistic
Pair<string, double> statistic2
Pair<double, double> ci
}
Z Test
Request
Ztest
{
Kind kind HTZTEST
bool is_async false
vector<double> v
double m
double sig
double alpha
TailtypeLR t [both, right, left]
}
Response
O_testloc
{
Kind kind HTZTEST
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
double p
bool h
Pair<string, double> statistic
Pair<string, double> statistic2
Pair<double, double> ci
}
T Test
Request
Ttest
{
Kind kind HTTTEST
bool is_async false
vector<double> v
vector<double> mY
double alpha
TailtypeLR t [both, right, left]
}
Response
O_testloc
{
Kind kind HTTTEST
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
double p
bool h
Pair<string, double> statistic
Pair<string, double> statistic2
Pair<double, double> ci
}
Variance Test 1
Request
Vartest
{
Kind kind HTVARTEST
bool is_async false
vector<double> vec
double v
double alpha
TailtypeLR t [both, right, left]
}
Response
O_testdisp
{
Kind kind HTVARTEST
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
double p
bool h
Pair<string, double> statistic
Pair<double, double> ci
}
Variance Test 2
Request
Vartest2
{
Kind kind HTVARTEST2
bool is_async false
vector<double> v1
vector<double> v2
double alpha
TailtypeLR t [both, right, left]
}
Response
O_testdisp
{
Kind kind HTVARTEST2
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
double p
bool h
Pair<string, double> statistic
Pair<double, double> ci
}
Bartlett’s Test
Request
Bartest
{
Kind kind HTBARTTEST
bool is_async false
Matrix X
double alpha
}
Response
O_testdisp2
{
Kind kind HTBARTTEST
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
uint64 dim
vector<double> probabilities
Pair<string, vector<double>> statistic
}
Chi-Square Goodness of Fit
Request
Chi2gof
{
Kind kind HTCHI2GOF
bool is_async false
vector<double> X
uint64 nbins
double alpha
uint64 emin
}
Response
O_chi2gof
{
Kind kind HTCHI2GOF
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
double p
bool h
uint64 df
Pair<string, double> statistic
vector<uint64> observed
vector<double> expected
vector<double> edges
}
Kolmogorov Smirnov Test
Request
Kstest
{
Kind kind HTKSTEST
bool is_async false
vector<double> v
double alpha
TailtypeSL t [unequal, smaller, larger]
}
Response
O_testdist
{
Kind kind HTKSTEST
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
double p
bool h
Pair<string, double> statistic
}
Kolmogorov Smirnov Test 2
Request
Kstest2
{
Kind kind HTKSTEST2
bool is_async false
vector<double> v1
vector<double> v2
double alpha
TailtypeSL t [unequal, smaller, larger]
}
Response
O_testdist
{
Kind kind HTKSTEST2
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
double p
bool h
Pair<string, double> statistic
}
Jarque Bera Test
Request
Jbtest
{
Kind kind HTJBTEST
bool is_async false
vector<double> v
double alpha
}
Response
O_testdist
{
Kind kind HTJBTEST
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
double p
bool h
Pair<string, double> statistic
}
Scaling
Request
Scaling
{
Kind kind [SCALING, BOXCOX, MINMAX, STANDARDIZE, YEOJOHNSON]
bool is_async false
Matrix X
vector<string> labels
nullable<double> lb
nullable<double> ub
vector<double> lambdas //(for Box-Cox & Yeo-Johnson if needed)
}
Response
O_scaling
{
Kind kind [SCALING, BOXCOX, MINMAX, STANDARDIZE, YEOJOHNSON]
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
vector<string> labels
vector<double> lambdas
vector<double> logliks
Matrix M
}
Smoothing
Request
Smoothing
{
Kind kind SMOOTH
bool is_async false
Matrix X
MethodSmooth method [HP, MOVAVG, POLY]
vector<string> labels
uint32 movavg_n
uint32 poly_n
uint32 hp_n
}
One of the following depending on type of request.
Response
O_hpfilter
{
Kind kind HPFILTER
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
vector<double> logliks
vector<string> labels
Matrix trend
Matrix diff
}
Response
O_matrix
{
Kind kind SMOOTH
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
Matrix M
Matrix N
vector<string> labels
}
Impute
Request
Impute
{
Kind kind IMPUTE
bool is_async false
Matrix X
MethodImpute meth_impute [fill_value, fill_mean, locf, fill_regress, remove_rows]
nullable<double> fill_value
MethodReg method_reg [NONE, OLS, RIDGE, LASSO]
double lambda
double alpha
vector<string> labels
}
Response
O_matrix
{
Kind kind IMPUTE
uint32 engine_cpu_time
string source
string method
vector<string> warnings
nullable<string> error
Matrix M
Matrix N
vector<string> labels
}