Skip to content

Commit

Permalink
Final touches before submitting to CRAN.
Browse files Browse the repository at this point in the history
  • Loading branch information
dppalomar committed Apr 16, 2022
1 parent e7ea9aa commit ad10b5c
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 18 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
Package: fitHeavyTail
Title: Mean and Covariance Matrix Estimation under Heavy Tails
Version: 0.1.2.9000
Date: 2020-1-7
Version: 0.1.3
Date: 2022-4-14
Description: Robust estimation methods for the mean vector, scatter matrix,
and covariance matrix (if it exists) from data (possibly containing NAs)
under multivariate heavy-tailed distributions such as angular Gaussian
(via Tyler's method), Cauchy, and Student's t distributions. Additionally,
a factor model structure can be specified for the covariance matrix.
a factor model structure can be specified for the covariance matrix. The
latest revision also includes the multivariate skewed t distribution.
The package is based on the papers: Sun, Babu, and Palomar (2014),
Sun, Babu, and Palomar (2015), Liu and Rubin (1995), and
Zhou, Liu, Kumar, and Palomar (2019).
Expand All @@ -24,7 +25,6 @@ URL: https://CRAN.R-project.org/package=fitHeavyTail,
BugReports: https://github.com/dppalomar/fitHeavyTail/issues
License: GPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.1
Depends:
Imports:
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ importFrom(mvtnorm,dmvt)
importFrom(numDeriv,grad)
importFrom(stats,cov)
importFrom(stats,median)
importFrom(stats,na.omit)
importFrom(stats,optimize)
importFrom(stats,uniroot)
importFrom(stats,var)
importFrom(utils,tail)
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Changes in fitHeavyTail version 0.1.2.9000
## Changes in fitHeavyTail version 0.1.3 (2022-4-14)

* New method for skewed t distributions: fit_mvst()

Expand Down
8 changes: 6 additions & 2 deletions R/fit_mvt.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#' \item{\code{psi}: default is
#' \code{diag(initial$cov - initial$B \%*\% t(initial$B)).}}}
#' @param optimize_mu Boolean indicating whether to optimize \code{mu} (default is \code{TRUE}).
#' @param weights Optional weights for each of the observations (the length should be equal to the number of rows of X).
#' @param factors Integer indicating number of factors (default is \code{ncol(X)}, so no factor model assumption).
#' @param max_iter Integer indicating the maximum number of iterations for the iterative estimation
#' method (default is \code{100}).
Expand Down Expand Up @@ -104,6 +105,9 @@
#' Rui Zhou, Junyan Liu, Sandeep Kumar, and Daniel P. Palomar, "Robust factor analysis parameter estimation,"
#' Lecture Notes in Computer Science (LNCS), 2019. <https://arxiv.org/abs/1909.12530>
#'
#' Esa Ollila, Daniel P. Palomar, and Frédéric Pascal, "Shrinking the Eigenvalues of M-estimators of Covariance Matrix,"
#' IEEE Trans. on Signal Processing, vol. 69, pp. 256-269, Jan. 2021.
#'
#' @examples
#' library(mvtnorm) # to generate heavy-tailed data
#' library(fitHeavyTail)
Expand All @@ -115,7 +119,7 @@
#' options(nu_min = 4.01)
#' fit_mvt(X, nu = "iterative")
#'
#' @importFrom stats optimize
#' @importFrom stats optimize na.omit uniroot
#' @export
fit_mvt <- function(X, na_rm = TRUE,
nu = c("kurtosis", "MLE-diag", "MLE-diag-resampled", "iterative"),
Expand Down Expand Up @@ -330,7 +334,7 @@ fit_mvt <- function(X, na_rm = TRUE,
theta <- (1 - N/T) * sum(r2i)/T/N
# correction with sigma
T_ <- 10000
X_ <- mvtnorm::rmvt(n = T_, delta = rep(0, N), sigma = diag(N), df = nu_true) # heavy-tailed data
X_ <- mvtnorm::rmvt(n = T_, delta = rep(0, N), sigma = diag(N), df = nu) # heavy-tailed data
r2 <- rowSums(X_^2)
u <- (N + nu)/(nu + r2)
r2i <- r2/(1 - r2*u/T_)
Expand Down
4 changes: 2 additions & 2 deletions R_buildignore/developer_commands.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ devtools::build()
#devtools::revdep(pkg = "fitHeavyTail") # to check reverse dependencies
#devtools::check_win_release() #to check under windows
#R CMD build . # this is to generate tarball
#R CMD check fitHeavyTail_0.1.2.9000.tar.gz --as-cran --run-donttest # this is before submission to CRAN
#R CMD install fitHeavyTail_0.1.2.9000.tar.gz
#R CMD check fitHeavyTail_0.1.3.tar.gz --as-cran --run-donttest # this is before submission to CRAN
#R CMD install fitHeavyTail_0.1.3.tar.gz
#submit the tarball directly via the webform: https://cran.r-project.org/submit.html
4 changes: 2 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
This is version 0.1.2 (2020-1-7) in CRAN (package also available in GitHub).
This is version 0.1.3 (2022-4-14) in CRAN (package also available in GitHub).

---

## Test environments
* OS X, R 3.6.0
* OS X, R 4.1.2
* Windows at https://win-builder.r-project.org/

## R CMD check results
Expand Down
30 changes: 25 additions & 5 deletions inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ citHeader("To cite 'fitHeavyTail' in publications, please use:")
citEntry(entry = "Manual",
title = "{fitHeavyTail: Mean and Covariance Matrix Estimation under Heavy Tails}",
author = personList(as.person("D. P. Palomar"),
as.person("Rui ZHOU")),
note = "R package version 0.1.2",
year = "2020",
as.person("Rui Zhou"),
as.person("Xiwen Wang")),
note = "R package version 0.1.3",
year = "2022",
url = "https://CRAN.R-project.org/package=fitHeavyTail",
textVersion =
paste("D. P. Palomar and Rui Zhou (2020).",
paste("D. P. Palomar, Rui Zhou, and Xiwen Wang (2022).",
"fitHeavyTail: Mean and Covariance Matrix Estimation under Heavy Tails.",
"R package version 0.1.2.",
"R package version 0.1.3.",
"https://CRAN.R-project.org/package=fitHeavyTail")
)

Expand Down Expand Up @@ -51,3 +52,22 @@ citEntry(entry = "Article",
"vol. 63, no. 12, pp. 3096-3109.",
"https://doi.org/10.1109/TSP.2015.2417513")
)

citEntry(entry = "Article",
title = "Shrinking the Eigenvalues of M-estimators of Covariance Matrix",
author = personList(as.person("E. Ollila"),
as.person("D. P. Palomar"),
as.person("F. Pascal")),
journal = "IEEE Transactions on Signal Processing",
volume = "69",
pages = "256--269",
year = "2021",
url = "https://doi.org/10.1109/TSP.2020.3043952",
textVersion =
paste("E. Ollila, D. P. Palomar, and F. Pascal (2021).",
"Shrinking the Eigenvalues of M-estimators of Covariance Matrix.",
"IEEE Transactions on Signal Processing,",
"vol. 69, pp. 256-269.",
"https://doi.org/10.1109/TSP.2020.3043952")
)

5 changes: 5 additions & 0 deletions man/fit_mvt.Rd

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

4 changes: 3 additions & 1 deletion tests/testthat/test-fit_mvst.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ test_that("default mode works", {
load("fitted_mvst_check.RData")

mvst_model <- fit_mvst(X, ptol = 1e-4)

expect_equal(mvst_model[c("mu", "gamma", "scatter", "nu", "mean", "cov", "converged", "num_iterations")],
mvst_model_check[c("mu", "gamma", "scatter", "nu", "mean", "cov", "converged", "num_iterations")]) #, tolerance = 0.1)
mvst_model_check[c("mu", "gamma", "scatter", "nu", "mean", "cov", "converged", "num_iterations")],
tolerance = 1e-5)

# test for xts
mvst_model <- fit_mvst(X)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-fit_mvt.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test_that("error control works", {
"Cannot deal with T <= N (after removing NAs), too few samples.", fixed = TRUE)
expect_error(fit_mvt(X = X, max_iter = -1), "\"max_iter\" must be greater than 1.")
expect_error(fit_mvt(X = X, factors = -1), "\"factors\" must be no less than 1 and no more than column number of \"X\".")
expect_error(fit_mvt(X = X, nu = "lala"), "'arg' should be one of kurtosis”, “MLE-diag”, “MLE-diag-resampled”, “iterative")
expect_error(fit_mvt(X = X, nu = "lala"), "'arg' should be one of \"kurtosis\", \"MLE-diag\", \"MLE-diag-resampled\", \"iterative\"")
expect_error(fit_mvt(X = X, nu = 1), "Non-valid value for nu.")
})

Expand Down

0 comments on commit ad10b5c

Please sign in to comment.