GithubHelp home page GithubHelp logo

kisungyou / covtools Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 6.0 24.14 MB

Statistical Tools for Covariance Analysis

Home Page: https://cran.r-project.org/web/packages/CovTools/index.html

R 78.91% TeX 14.26% C++ 6.83%
r covariance covariance-estimation

covtools's Introduction

CovTools

CRAN_Status_Badge

Covariance is of universal prevalence across various disciplines within statistics. This package aims at providing a rich collection of geometric and statistical tools for a variety of inferences on covariance structures as well as its inverse called precision matrix. See the package help file by help("package-CovTools") in R console for the list of available functions.

Installation

You can install the released version of CovTools from CRAN with:

install.packages("CovTools")

or the development version from github:

## install.packages("devtools")
## library(devtools)
devtools::install_github("kisungyou/CovTools")

List of Available Methods

We offer various methods for covariance and symmetric positive-definite matrices. Below is the list of functions implemented in our package.

(0) Elementary Operations

function name description
CovDist computes pairwise distance for symmetric positive-definite matrices
CovMean estimate mean/average covariance matrix

(1) Estimation : Covariance

function name authors description
CovEst.adaptive Cai and Liu (2011) adaptive thresholding
CovEst.hard Bickel and Levina (2008) hard thresholding
CovEst.hardPD Fan et al. (2013) hard thresholding under positive-definiteness constraint
CovEst.nearPD Qi and Sun (2006) nearest positive-definite matrix projection
CovEst.soft Antoniadis and Fan (2001) soft thresholding
CovEst.2003LW Ledoit and Wolf (2003) linear shrinkage estimation
CovEst.2010OAS Chen et al. (2010) oracle approximation shrinkage
CovEst.2010RBLW Chen et al. (2010) Rao-Blackwell Ledoit-Wolf estimation

(2) Estimation : Precision

function name authors description
PreEst.2014An An et al. (2014) banded precision estimation via bandwidth test
PreEst.2014Banerjee Banerjee and Ghosal (2014) Bayesian estimation of a banded precision matrix
PreEst.2017Lee Lee and Lee (2017) Bayesian estimation of a banded precision matrix
PreEst.glasso Friedman et al. (2008) graphical lasso

(3) Hypothesis Test : 1-sample

function name authors description
BCovTeset1.mxPBF Lee et al. (2018) Bayesian test using Maximum Pairwise Bayes Factor
CovTest1.2013Cai Cai and Ma (2013) Test by Cai and Ma
CovTest1.2014Srivastava Srivastava et al. (2014) Test by Srivastava, Yanagihara, and Kubokawa

(4) Hypothesis Test : 2-sample

function name authors description
CovTest2.2013Cai Cai and Ma (2013) Test by Cai and Ma

(5) Hypothesis Test : 1-sample Diagonal

function name authors description
BDiagTest1.mxPBF Lee et al. (2018) Bayesian Test using Maximum Pairwise Bayes Factor
DiagTest1.2011Cai Cai and Jiang (2011) Test by Cai and Jiang
DiagTest1.2015Lan Lan et al. (2015) Test by Lan, Luo, Tsai, Wang, and Yang

covtools's People

Contributors

kisungyou avatar matthieustigler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

covtools's Issues

CovEst.hardPD does not give positive definite matrix?

CovEst.hardPD() does not give a matrix that is positive definite? See code below

I believe this comes from the second search, which searches within the "first non pd" (Cvec1[iter]) to the last "pd" (Cvec1[iter-1]). It starts from the lowest, and then see if it is non pd. So this will stop at the first value (first non pd), and hence returns a non-pd value!?

Solution is probably either to inverse the line: Cvec2 = seq(from=Cvec1[iter], to=Cvec1[iter-1], length.out=20), or to change the sign in the second if ((min(eigen(tmpS, only.values=TRUE)$values)) < sqrt(.Machine$double.eps)){ to stop at the first pd?

Thanks!

library(CovTools)

pdim <- 20
data <- matrix(rnorm(10*pdim), ncol=pdim)

out4 <- CovEst.hardPD(data) 
min(eigen(out4$S, only.values = TRUE)$values)
#> [1] -0.2785753

## verify with matrixcalc
matrixcalc::is.positive.definite(out4$S)
#> [1] FALSE

Created on 2021-05-05 by the reprex package (v2.0.0)

thr1.multiple: feeding X instead of S to func_

Hi Kisung

I was looking at the code, trying to implement Cai and Zhang (2016) shrinkage method allowing NA values.

Looking at thr1.multiple(), I notice that it takes a new function func_*_givenS, which seems to involve rewriting code many times? What was the reason for this exactly? The additional problem is that the function I am writing requires X at each iteration, meaning a _givenS function cannot be written.

It looks like thr1.multiple_X() could actually store the training X instead of computing the training S (S1), still compute the test S (S2) as before, and then thr1.singlesum() would work using the direct functions?

Am I missing something there? Happy to send a pull request for that!

Thanks alot!

Suggested changes:
new: X_train <-array(0,c(n1,p,nCV))
Change S1[,,i] = X[idx1,] into X_train[,,i] = X[idx1,,drop=FALSE]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.