Package: generalCorr 1.2.6

generalCorr: Generalized Correlations, Causal Paths and Portfolio Selection

Function gmcmtx0() computes a more reliable (general) correlation matrix. Since causal paths from data are important for all sciences, the package provides many sophisticated functions. causeSummBlk() and causeSum2Blk() give easy-to-interpret causal paths. Let Z denote control variables and compare two flipped kernel regressions: X=f(Y, Z)+e1 and Y=g(X, Z)+e2. Our criterion Cr1 says that if |e1*Y|>|e2*X| then variation in X is more "exogenous or independent" than in Y, and the causal path is X to Y. Criterion Cr2 requires |e2|<|e1|. These inequalities between many absolute values are quantified by four orders of stochastic dominance. Our third criterion Cr3, for the causal path X to Y, requires new generalized partial correlations to satisfy |r*(x|y,z)|< |r*(y|x,z)|. The function parcorVec() reports generalized partials between the first variable and all others. The package provides several R functions including get0outliers() for outlier detection, bigfp() for numerical integration by the trapezoidal rule, stochdom2() for stochastic dominance, pillar3D() for 3D charts, canonRho() for generalized canonical correlations, depMeas() measures nonlinear dependence, and causeSummary(mtx) reports summary of causal paths among matrix columns. Portfolio selection: decileVote(), momentVote(), dif4mtx(), exactSdMtx() can rank several stocks. Functions whose names begin with 'boot' provide bootstrap statistical inference, including a new bootGcRsq() test for "Granger-causality" allowing nonlinear relations. A new tool for evaluation of out-of-sample portfolio performance is outOFsamp(). Panel data implementation is now included. See eight vignettes of the package for theory, examples, and usage tips. See Vinod (2019) \doi{10.1080/03610918.2015.1122048}.

Authors:Prof. H. D. Vinod, Fordham University, NY.

generalCorr_1.2.6.tar.gz
generalCorr_1.2.6.zip(r-4.5)generalCorr_1.2.6.zip(r-4.4)generalCorr_1.2.6.zip(r-4.3)
generalCorr_1.2.6.tgz(r-4.4-any)generalCorr_1.2.6.tgz(r-4.3-any)
generalCorr_1.2.6.tar.gz(r-4.5-noble)generalCorr_1.2.6.tar.gz(r-4.4-noble)
generalCorr_1.2.6.tgz(r-4.4-emscripten)generalCorr_1.2.6.tgz(r-4.3-emscripten)
generalCorr.pdf |generalCorr.html
generalCorr/json (API)
NEWS

# Install 'generalCorr' in R:
install.packages('generalCorr', repos = c('https://hdvinod.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Datasets:

On CRAN:

This package does not link to any Github/Gitlab/R-forge repository. No issue tracker or development information is available.

4.47 score 2 stars 1 packages 61 scripts 503 downloads 1 mentions 111 exports 83 dependencies

Last updated 1 years agofrom:c9fa07dcd3. Checks:OK: 3 NOTE: 4. Indexed: yes.

TargetResultDate
Doc / VignettesOKNov 04 2024
R-4.5-winNOTENov 04 2024
R-4.5-linuxNOTENov 04 2024
R-4.4-winNOTENov 04 2024
R-4.4-macNOTENov 04 2024
R-4.3-winOKNov 04 2024
R-4.3-macOKNov 04 2024

Exports:abs_resabs_stdapdabs_stdapdCabs_stdresabs_stdresCabs_stdrhserCabs_stdrhserrabsBstdresabsBstdresCabsBstdrhserCallPairsbigfpbootDom12bootGcLCbootGcRsqbootPair2bootPairsbootPairs0bootQuantilebootSignbootSignPcentbootSummarybootSummary2canonRhocauseAllPaircauseSum2BlkcauseSum2PanelcauseSummarycauseSummary0causeSummary2causeSummary2NoPcauseSummBlkcauseSumNoPcofactorcomp_portfo2compPortfodecileVotedepMeasdif4dif4mtxexactSdMtxGcRsqX12GcRsqX12cGcRsqYXGcRsqYXcget0outliersgetSeqgmcmtx0gmcmtxBlkgmcmtxZgmcxy_npheuristkernkern_ctrlkern2kern2ctrlmagmag_ctrlminormomentVotenapairnaTriplenaTripletNLhatoutOFsampoutOFsellPanel2LagPanelLagparcor_ijkparcor_ijkOLDparcor_linearparcor_ridgparcorBijkparcorBManyparcorHijkparcorHijk2parcorManyparcorMtxparcorSilentparcorVecparcorVecHparcorVecH2pcausepillar3Dprelec2probSignrank2returnrank2sellrstarsilentMtxsilentMtx0silentPair2silentPairssilentPairs0siPair2BlksiPairsBlksome0PairssomeCPairssomeCPairs2someMagPairssomePairssomePairs2sort_matrixstdresstdz_xystochdom2sudoCoefParcorsudoCoefParcorHsummaryRanksymmzewtdpapb

Dependencies:abindashbackportsbootbroomcarcarDataclicolorspacecowplotcpp11cubatureDerivdoBydplyrdynlmfansifarverFNNFormulagenericsggplot2glueGPArotationgtablehdrcdeisobandkernlabKernSmoothkslabelinglatticelifecyclelme4lmtestlocfitmagrittrMASSMatrixMatrixModelsmclustmebootmgcvmicrobenchmarkminqamnormtmodelrmulticoolmunsellmvtnormnlmenloptrnnetnpnumDerivpbkrtestpillarpkgconfigpracmapsychpurrrquadprogquantregR6RColorBrewerRcppRcppEigenrlangscalesSparseMstringistringrsurvivaltdigesttibbletidyrtidyselectutf8vctrsviridisLitewithrxtablezoo

generalCorr-vignette

Rendered fromgeneralCorr-vignette.pdf.asisusingR.rsp::asison Nov 04 2024.

Last update: 2017-06-16
Started: 2016-05-21

generalCorr-vignette2

Rendered fromgeneralCorr-vignette2.pdf.asisusingR.rsp::asison Nov 04 2024.

Last update: 2017-06-16
Started: 2017-06-16

generalCorr-vignette3

Rendered fromgeneralCorr-vignette3.pdf.asisusingR.rsp::asison Nov 04 2024.

Last update: 2017-09-02
Started: 2017-09-02

generalCorr-vignette4

Rendered fromgeneralCorr-vignette4.pdf.asisusingR.rsp::asison Nov 04 2024.

Last update: 2019-10-30
Started: 2019-10-30

generalCorr-vignette5

Rendered fromgeneralCorr-vignette5.pdf.asisusingR.rsp::asison Nov 04 2024.

Last update: 2020-11-29
Started: 2020-11-29

generalCorr-vignette6

Rendered fromgeneralCorr-vignette6.pdf.asisusingR.rsp::asison Nov 04 2024.

Last update: 2021-11-10
Started: 2021-11-10

generalCorr-vignette7

Rendered fromgeneralCorr-vignette7.pdf.asisusingR.rsp::asison Nov 04 2024.

Last update: 2023-08-16
Started: 2023-08-16

generalCorr-vignette8

Rendered fromgeneralCorr-vignette8.pdf.asisusingR.rsp::asison Nov 04 2024.

Last update: 2023-10-08
Started: 2023-10-08

Readme and manuals

Help Manual

Help pageTopics
Absolute residuals of kernel regression of x on y.abs_res
Absolute values of gradients (apd's) of kernel regressions of x on y when both x and y are standardized.abs_stdapd
Absolute values of gradients (apd's) of kernel regressions of x on y when both x and y are standardized and control variables are present.abs_stdapdC
Absolute values of residuals of kernel regressions of x on y when both x and y are standardized.abs_stdres
Absolute values of residuals of kernel regressions of x on y when both x and y are standardized and control variables are present (C for control presence).abs_stdresC
Absolute residuals kernel regressions of standardized x on y and control variables, Cr1 has abs(RHS*y) not gradients.abs_stdrhserC
Absolute values of Hausman-Wu null in kernel regressions of x on y when both x and y are standardized.abs_stdrhserr
Block version of abs-stdres Absolute values of residuals of kernel regressions of standardized x on standardized y, no control variables.absBstdres
Block version of Absolute values of residuals of kernel regressions of standardized x on standardized y and control variables.absBstdresC
Block version abs_stdrhser Absolute residuals kernel regressions of standardized x on y and control variables, Cr1 has abs(Resid*RHS).absBstdrhserC
Report causal identification for all pairs of variables in a matrix (deprecated function). It is better to choose a target variable and pair it with all others, instead of considering all possible targets.allPairs
internal badColbadCol
Compute the numerical integration by the trapezoidal rule.bigfp
bootstrap confidence intervals for (x2-x1) exact SD1 to SD4 stochastic dominance .bootDom12
Compute vector of n999 nonlinear Granger causality pathsbootGcLC
Compute vector of n999 nonlinear Granger causality pathsbootGcRsq
Compute matrix of n999 rows and p-1 columns of bootstrap `sum' (scores from Cr1 to Cr3).bootPair2
Compute matrix of n999 rows and p-1 columns of bootstrap `sum' (strength from Cr1 to Cr3).bootPairs
Compute matrix of n999 rows and p-1 columns of bootstrap `sum' index (strength from older criterion Cr1, with newer Cr2 and Cr3).bootPairs0
Compute confidence intervals [quantile(s)] of indexes from bootPairs outputbootQuantile
Probability of unambiguously correct (+ or -) sign from bootPairs outputbootSign
Probability of unambiguously correct (+ or -) sign from bootPairs output transformed to percentages.bootSignPcent
Compute usual summary stats of 'sum' indexes from bootPairs outputbootSummary
Compute usual summary stats of 'sum' index in (-100, 100) from bootPair2bootSummary2
Generalized canonical correlation, estimating alpha, beta, rho.canonRho
All Pair Version Kernel (block) causality summary paths from three criteriacauseAllPair
Block Version 2: Kernel causality summary of causal paths from three criteriacauseSum2Blk
Kernel regressions based causal paths in Panel Data.causeSum2Panel
Kernel causality summary of evidence for causal paths from three criteriacauseSummary
Older Kernel causality summary of evidence for causal paths from three criteriacauseSummary0
Kernel causality summary of evidence for causal paths from three criteria using new exact stochastic dominance. The function develops a unanimity index for deciding which flip (y on xi) or (xi on y) is best. Relevant signs determine the causal direction and unanimity index among three criteria. While allowing the researcher to keep some variables as controls, or outside the scope of causal path determination (e.g., age or latitude) this function produces detailed causal path information in a 5 column matrix identifying the names of variables, causal path directions, path strengths re-scaled to be in the range [-100, 100], (table reports absolute values of the strength) plus Pearson correlation and its p-value. The `2' in the name of the function suggests a second implementation where exact stochastic dominance, decileVote, and momentVote are used and where we avoid Anderson's trapezoidal approximation.causeSummary2
No Print version Kernel causality summary of evidence for causal paths from three criteria using new exact stochastic dominance.causeSummary2NoP
Block Version 2: Kernel causality summary of causal paths from three criteriacauseSummBlk
No print (NoP) version of causeSummBlk summary causal paths from three criteriacauseSumNoP
Compute cofactor of a matrix based on row r and column c.cofactor
Compares two vectors (portfolios) using stochastic dominance of orders 1 to 4.comp_portfo2
Compares two vectors (portfolios) using momentVote, DecileVote and exactSdMtx functions.compPortfo
internal dada
internal da2Lagda2Lag
Function compares nine deciles of stock return distributions.decileVote
depMeas Signed measure of nonlinear nonparametric dependence between two vectors.depMeas
order 4 differencing of a time series vectordif4
order four differencing of a matrix of time seriesdif4mtx
Internal diff.e0diff.e0
Internal digdig
internal e0e0
European Crime DataEuroCrime
Exact stochastic dominance computation from areas above ECDF pillars.exactSdMtx
Generalized Granger-Causality. If dif>0, x2 Granger-causes x1.GcRsqX12
Generalized Granger-Causality. If dif>0, x2 Granger-causes x1.GcRsqX12c
Nonlinear Granger causality between two time series workhorse function.GcRsqYX
Nonlinear Granger causality between two time series workhorse function.(local constant version)GcRsqYXc
generalCorr package description:generalCorr-package generalCorrInfo
Function to compute outliers and their count using Tukey's method using 1.5 times interquartile range (IQR) to define boundaries.get0outliers
Two sequences: starting+ending values from n and blocksize (internal use)getSeq
internal gmc0gmc0
internal gmc1gmc1
Matrix R* of generalized correlation coefficients captures nonlinearities.gmcmtx0
Matrix R* of generalized correlation coefficients captures nonlinearities using blocks.gmcmtxBlk
compute the matrix R* of generalized correlation coefficients.gmcmtxZ
Function to compute generalized correlation coefficients r*(x|y) and r*(y|x) from two vectors (not matrices)gmcxy_np
internal goodColgoodCol
Heuristic t test of the difference between two generalized correlations.heurist
internal ii
internal objectibad
internal iiii
internal jj
Kernel regression with options for residuals and gradients.kern
Kernel regression with control variables and optional residuals and gradients.kern_ctrl
Kernel regression version 2 with optional residuals and gradients with regtype="ll" for local linear, bwmethod="cv.aic" for AIC-based bandwidth selection.kern2
Kernel regression with control variables and optional residuals and gradients. version 2 regtype="ll" for local linear, bwmethod="cv.aic" for AIC-based bandwidth selection. It admits control variables.kern2ctrl
Approximate overall magnitudes of kernel regression partials dx/dy and dy/dx.mag
After removing control variables, magnitude of effect of x on y, and of y on x.mag_ctrl
internal min.e0min.e0
Function to do compute the minor of a matrix defined by row r and column c.minor
Function compares Pearson Stats and Sharpe Ratio for a matrix of stock returnsmomentVote
internal mtxmtx
internal mtx0mtx0
internal mtx2mtx2
internal nn
internal nallnall
internal nam.badColnam.badCol
internal nam.goodColnam.goodCol
internal nam.mtx0nam.mtx0
Function to do pairwise deletion of missing rows.napair
Function to do matched deletion of missing rows from x, y and z variable(s).naTriple
Function to do matched deletion of missing rows from x, y and control variable(s).naTriplet
Compute fitted values from kernel regression of x on y and y on xNLhat
internal out1out1
Compare out-of-sample portfolio choice algorithms by a leave-percent-out method.outOFsamp
Compare out-of-sample (short) selling algorithms by a leave-percent-out method.outOFsell
internal p1p1
Function to compute a vector of 2 lagged values of a variable from panel data.Panel2Lag
Function for computing a vector of one-lagged values of xj, a variable from panel data.PanelLag
Generalized partial correlation coefficients between Xi and Xj, after removing the effect of xk, via nonparametric regression residuals.parcor_ijk
Generalized partial correlation coefficient between Xi and Xj after removing the effect of all others. (older version, deprecated)parcor_ijkOLD
Partial correlation coefficient between Xi and Xj after removing the linear effect of all others.parcor_linear
Compute generalized (ridge-adjusted) partial correlation coefficients from matrix R*. (deprecated)parcor_ridg
Block version of generalized partial correlation coefficients between Xi and Xj, after removing the effect of xk, via nonparametric regression residuals.parcorBijk
Block version reports many generalized partial correlation coefficients allowing control variables.parcorBMany
Generalized partial correlation coefficients between Xi and Xj, after removing the effect of Xk, via OLS regression residuals.parcorHijk
Generalized partial correlation coefficients between Xi and Xj,parcorHijk2
Report many generalized partial correlation coefficients allowing control variables.parcorMany
Matrix of generalized partial correlation coefficients, always leaving out control variables, if any.parcorMtx
Silently compute generalized (ridge-adjusted) partial correlation coefficients from matrix R*.parcorSilent
Vector of generalized partial correlation coefficients (GPCC), always leaving out control variables, if any.parcorVec
Vector of hybrid generalized partial correlation coefficients.parcorVecH
Vector of hybrid generalized partial correlation coefficients.parcorVecH2
Compute the bootstrap probability of correct causal direction.pcause
Create a 3D pillar chart to display (x, y, z) data coordinate surface.pillar3D
Intermediate weighting function giving Non-Expected Utility theory weights.prelec2
Compute probability of positive or negative sign from bootPairs outputprobSign
Compute the portfolio return knowing the rank of a stock in the input `mtx'.rank2return
Compute the portfolio return knowing the rank of a stock in the input `mtx'. This function computes the return earned knowing the rank of a stock computed elsewhere and named myrank associate with the data columns in the input mtx of stock returns. For example, mtx has p=28 Dow Jones stocks over n=169 monthly returns. Portfolio weights are assumed to be linearly declining. If maxChosen=4, the weights are 1/10, 2/10, 3/10 and 4/10, which add up to unity. These portfolio weights are assigned in their order in the sense that first chosen stock (choice rank =p) gets portfolio weight=4/10. The function computes return from the stocks using the `myrank' argument. This helps in assessing out-of-sample performance of (short) the strategy of selling lowest ranking stocks. It is mostly for internal use by 'outOFsell()'. This is a sell version of 'rank2return()'.rank2sell
internal rhs.lag2rhs.lag2
internal rhs1rhs1
internal ridgekridgek
internal rijrij
internal rijMrjirijMrji
internal rjirji
internal rrijrrij
internal rrjirrji
Function to compute generalized correlation coefficients r*(x,y).rstar
internal sales2Lagsales2Lag
internal salesLagsalesLag
internal seedseed
internal sgn.e0sgn.e0
No-print kernel-causality unanimity score matrix with optional control variablessilentMtx
Older kernel-causality unanimity score matrix with optional control variablessilentMtx0
kernel causality (version 2) scores with control variablessilentPair2
No-print kernel causality scores with control variables Hausman-Wu Criterion 1silentPairs
Older version, kernel causality weighted sum allowing control variablessilentPairs0
Block Version of silentPair2 for causality scores with control variablessiPair2Blk
Block Version of silentPairs for causality scores with control variablessiPairsBlk
Function reporting detailed kernel causality results in a 7-column matrix (uses deprecated criterion 1, no longer recommended but may be useful for second and third criterion typ=2,3)some0Pairs
Kernel causality computations admitting control variables.someCPairs
Kernel causality computations admitting control variables reporting a 7-column matrix, version 2.someCPairs2
Summary magnitudes after removing control variables in several pairs where dependent variable is fixed.someMagPairs
Function reporting kernel causality results as a 7-column matrix.(deprecated)somePairs
Function reporting kernel causality results as a 7-column matrix, version 2.somePairs2
Sort all columns of matrix x with respect to the j-th column.sort_matrix
internal sort.abse0sort.abse0
internal sort.e0sort.e0
Residuals of kernel regressions of x on y when both x and y are standardized.stdres
Standardize x and y vectors to achieve zero mean and unit variance.stdz_xy
Compute vectors measuring stochastic dominance of four orders.stochdom2
Pseudo regression coefficients from generalized partial correlation coefficients, (GPCC).sudoCoefParcor
Peudo regression coefficients from hybrid generalized partial correlation coefficients (HGPCC).sudoCoefParcorH
Compute ranks of rows of matrix and summarize them into a choice suggestion.summaryRank
Replace asymmetric matrix by max of abs values of [i,j] or [j,i] elements.symmze
Creates input for the stochastic dominance function stochdom2wtdpapb