Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge #8

Merged
merged 3 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
new updates 16/11
  • Loading branch information
toduckhanh committed Nov 16, 2022
commit 128058e00e001951ec8e2ba3e1a3b5e24f62b019
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ClusROC
Type: Package
Title: ROC Analysis in Three-Class Classification Problems for Clustered Data
Date: 2022-11-15
Date: 2022-11-16
Version: 1.0.2
Author: Duc-Khanh To [aut, cre] (<https://orcid.org/0000-0002-4641-0764>), with contributions from Gianfranco Adimari and Monica Chiogna
Maintainer: Duc-Khanh To <[email protected]>
Expand All @@ -13,13 +13,14 @@ Description: Statistical methods for ROC surface analysis in three-class classif
Methods considered in points (i), (ii) and (iv) are proposed and discussed in To et al. (2022) <doi:10.1177/09622802221089029>. Referring to point (iv), three different selection criteria are implemented: Generalized Youden Index (GYI), Closest to Perfection (CtP) and Maximum Volume (MV). Methods considered in point (iii) are proposed and discussed in Xiong et al. (2018) <doi:10.1177/0962280217742539>. Visualization tools are also provided. We refer readers to the articles cited above for all details.
License: GPL-3
Depends: R (>= 3.5.0), stats, utils, graphics, nlme, Rcpp (>= 0.12.3)
Imports: rgl, car, numDeriv, ggplot2, ggpubr, snow, doSNOW, foreach
Imports: rgl, ellipse, numDeriv, ggplot2, ggpubr, snow, doSNOW, foreach
LinkingTo: Rcpp, RcppArmadillo
Encoding: UTF-8
LazyData: true
LazyLoad: yes
ByteCompile: yes
RoxygenNote: 7.2.2
NeedsCompilation: yes
URL: https://github.com/toduckhanh/ClusROC
BugReports: https://github.com/toduckhanh/ClusROC/issues
Suggests:
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export(clus_opt_thres3)
export(clus_roc_surface)
export(clus_tcfs)
export(clus_vus)
import(car)
import(doSNOW)
import(foreach)
import(ggplot2)
Expand All @@ -27,4 +26,5 @@ import(snow)
import(stats)
import(utils)
importFrom(Rcpp,evalCpp)
importFrom(ellipse,ellipse)
useDynLib(ClusROC, .registration = TRUE)
35 changes: 21 additions & 14 deletions R/clus_opt_thresh_3class.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
####========================================================================####

#' @import grDevices
#' @import car
#' @import graphics
#' @import ggplot2
#' @importFrom ellipse ellipse
#'
clus_opt_thres3_core <- function(method, para, z, n_p, n_coef, boxcox, start,
method_optim, maxit, lower, upper) {
Expand Down Expand Up @@ -351,7 +352,8 @@ clus_opt_thres3 <- function(method = c("GYI", "CtP", "MV"), out_clus_lme,
#'@export
plot.clus_opt_thres3 <- function(x, ci_level = 0.95, colors = NULL, xlims,
ylims, size_point = 0.5, size_path = 0.5,
names_labels, nrow_legend = 1, file_name = NULL, ...) {
names_labels, nrow_legend = 1,
file_name = NULL, ...) {
if (isFALSE(inherits(x, "clus_opt_thres3"))) {
stop("x was not from clus_opt_thres3()!")
}
Expand All @@ -372,55 +374,60 @@ plot.clus_opt_thres3 <- function(x, ci_level = 0.95, colors = NULL, xlims,
theme_bw() +
theme(legend.position = "bottom", strip.text.x = element_text(size = 9))
if (!is.null(x$vcov_thres3)) {
c_alp <- sqrt(qchisq(ci_level, 2))
dt_thres_list <- split(dt_thres, dt_thres$method)
dt_ell_thres <- list()
if ("GYI" %in% x$method) {
dt_ell_thres_gyi <- data.frame()
for (i in 1:n_x){
uu <- ellipse(
center = as.numeric(dt_thres_list$`Generalized Youden Index`[i, 1:2]),
shape = x$vcov_thres3[[i]]$cov_gyi, radius = c_alp, draw = FALSE)
x = cov2cor(x$vcov_thres3[[i]]$cov_gyi)[1, 2],
scale = sqrt(diag(x$vcov_thres3[[i]]$cov_gyi)),
centre = as.numeric(dt_thres_list$`Generalized Youden Index`[i, 1:2]),
level = ci_level)
dt_ell_thres_gyi <- rbind(dt_ell_thres_gyi,
data.frame(uu, pts = as.factor(i)))
}
dt_ell_thres_gyi$method <- factor(rep(c("Generalized Youden Index"),
52 * n_x),
100 * n_x),
levels = c("Generalized Youden Index"))
dt_ell_thres$gyi <- dt_ell_thres_gyi
}
if ("CtP" %in% x$method) {
dt_ell_thres_ctp <- data.frame()
for (i in 1:n_x) {
uu <- ellipse(
center = as.numeric(dt_thres_list$`Closest to Perfection`[i, 1:2]),
shape = x$vcov_thres3[[i]]$cov_ctp, radius = c_alp, draw = FALSE)
x = cov2cor(x$vcov_thres3[[i]]$cov_ctp)[1, 2],
scale = sqrt(diag(x$vcov_thres3[[i]]$cov_ctp)),
centre = as.numeric(dt_thres_list$`Closest to Perfection`[i, 1:2]),
level = ci_level)
dt_ell_thres_ctp <- rbind(dt_ell_thres_ctp,
data.frame(uu, pts = as.factor(i)))
}
dt_ell_thres_ctp$method <- factor(rep(c("Closest to Perfection"),
52 * n_x),
100 * n_x),
levels = c("Closest to Perfection"))
dt_ell_thres$ctp <- dt_ell_thres_ctp
}
if ("MV" %in% x$method) {
dt_ell_thres_mv <- data.frame()
for (i in 1:n_x) {
uu <- ellipse(
center = as.numeric(dt_thres_list$`Max Volume`[i, 1:2]),
shape = x$vcov_thres3[[i]]$cov_mv,
radius = c_alp, draw = FALSE)
x = cov2cor(x$vcov_thres3[[i]]$cov_mv)[1, 2],
scale = sqrt(diag(x$vcov_thres3[[i]]$cov_mv)),
centre = as.numeric(dt_thres_list$`Max Volume`[i, 1:2]),
level = ci_level)
dt_ell_thres_mv <- rbind(dt_ell_thres_mv,
data.frame(uu, pts = as.factor(i)))
}
dt_ell_thres_mv$method <- factor(rep(c("Max Volume"), 52 * n_x),
dt_ell_thres_mv$method <- factor(rep(c("Max Volume"), 100 * n_x),
levels = c("Max Volume"))
dt_ell_thres$mv <- dt_ell_thres_mv
}
dt_ell_thres <- do.call(rbind, dt_ell_thres)
pp <- pp +
geom_path(data = dt_ell_thres,
aes_string(x = "x", y = "y", group = "pts"), size = size_path)
aes_string(x = "x", y = "y", group = "pts"),
linewidth = size_path)
}
if (is.null(colors)) {
colors <- topo.colors(n_x)
Expand Down
3 changes: 1 addition & 2 deletions R/clus_roc_surface.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
####========================================================================####
## This file consists of functions for estimating and ploting the ROC surface ##
## This file consists of functions for plotting the ROC surface ##
####========================================================================####

#' @import rgl
#' @import utils
#' @import graphics

shade_ellips <- function(orgi, sig, lev) {
t1 <- sig[2, 2]
Expand Down
2 changes: 1 addition & 1 deletion R/data_EnergyEthiopia.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @name EnergyEthiopia
#' @docType data
#'
#' @description A subset of energy choice data used in Alem et al. (2016). The authors are used the full dataset to investigate the determinants of household cooking fuel choice and energy transition in urban Ethiopia. A full data is publicly available at \url{https://doi.org/10.1016/j.eneco.2016.06.025}.
#' @description A subset of energy choice data used in Alem et al. (2016). The authors are used the full dataset to investigate the determinants of household cooking fuel choice and energy transition in urban Ethiopia. A full data is publicly available at \doi{10.1016/j.eneco.2016.06.025}.
#'
#' @usage data(EnergyEthiopia)
#'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This package implements the techniques for ROC surface analysis, in cases of clu
- [x] the optimal pairs of thresholds;
- [x] the volume under ROC surface (VUS).

Methods considered for the first three quantities are proposed and discussed in [To et al. (2022)](https://journals.sagepub.com/doi/full/10.1177/09622802221089029) . Referring to the third, three different selection criteria are implemented: Generalized Youden Index (GYI), Closest to Perfection (CtP) and Maximum Volume (MV). Methods considered for the last are proposed and discussed in [Xiong et al. (2018)](https://journals.sagepub.com/doi/full/10.1177/0962280217742539). Visualization tools are also provided. We refer readers to the articles cited above for all details.
Methods considered for the first three quantities are proposed and discussed in [To et al. (2022)](https://doi.org/10.1177/09622802221089029). Referring to the third, three different selection criteria are implemented: Generalized Youden Index (GYI), Closest to Perfection (CtP) and Maximum Volume (MV). Methods considered for the last are proposed and discussed in [Xiong et al. (2018)](https://doi.org/10.1177/0962280217742539). Visualization tools are also provided. We refer readers to the articles cited above for all details.

## INSTALLATION

Expand Down
2 changes: 1 addition & 1 deletion man/EnergyEthiopia.Rd

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

Binary file modified src/ClusROC.dll
Binary file not shown.
41 changes: 0 additions & 41 deletions tests/testthat/test-clus_roc_surface.R

This file was deleted.

Binary file removed tests/testthat/testdata/plot_roc_surface_0_cov.rds
Binary file not shown.
Binary file removed tests/testthat/testdata/plot_roc_surface_1_cov.rds
Binary file not shown.
Binary file removed tests/testthat/testdata/plot_roc_surface_2_cov.rds
Binary file not shown.
Binary file removed tests/testthat/testdata/plot_roc_surface_bcx.rds
Binary file not shown.