Skip to content

Commit e0de455

Browse files
committed
Rf_error issue and bump version
1 parent 7d6bfcf commit e0de455

File tree

8 files changed

+35
-13
lines changed

8 files changed

+35
-13
lines changed

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ Package: tsmarch
22
Type: Package
33
Title: Multivariate ARCH Models
44
Description: Feasible Multivariate Generalized Autoregressive Conditional Heteroscedasticity (GARCH) models including Dynamic Conditional Correlation (DCC), Copula GARCH and Generalized Orthogonal GARCH with Generalized Hyperbolic distribution. A review of some of these models can be found in Boudt, Galanos, Payseur and Zivot (2019) <doi:10.1016/bs.host.2019.01.001>.
5-
Version: 1.0.2
5+
Version: 1.0.3
66
Authors@R: c(person("Alexios", "Galanos", role = c("aut", "cre","cph"), email = "alexios@4dscape.com", comment = c(ORCID = "0009-0000-9308-0457")))
77
Maintainer: Alexios Galanos <alexios@4dscape.com>
88
Depends: R (>= 4.1.0), methods, tsmethods (>= 1.0.2)
9-
LinkingTo: Rcpp (>= 0.10.6), RcppArmadillo, RcppParallel, RcppBessel
9+
LinkingTo: Rcpp (>= 1.1.1), RcppArmadillo, RcppParallel, RcppBessel
1010
SystemRequirements: GNU make
11-
Imports: Rcpp, RcppParallel, tsgarch (>= 1.0.3), tsdistributions (>= 1.0.2), RcppBessel, Rsolnp, nloptr, flextable, numDeriv, abind, shape, Rdpack, xts, zoo, lubridate, sandwich, future.apply, future, stats, utils, data.table
11+
Imports: Rcpp, RcppParallel, tsgarch (>= 1.0.4), tsdistributions (>= 1.0.3), RcppBessel, Rsolnp (>= 2.0.0), nloptr, flextable, numDeriv, abind, shape, Rdpack, xts, zoo, lubridate, sandwich, future.apply, future, stats, utils, data.table
1212
License: GPL-2
1313
Encoding: UTF-8
1414
LazyData: true

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ importFrom(Rcpp,sourceCpp)
130130
importFrom(RcppBessel,bessel_k)
131131
importFrom(RcppParallel,RcppParallelLibs)
132132
importFrom(Rdpack,reprompt)
133+
importFrom(Rsolnp,csolnp)
133134
importFrom(Rsolnp,solnp)
134135
importFrom(abind,abind)
135136
importFrom(flextable,add_footer_lines)

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* Fix to DCC model simulation when order > 1.
44
* Bump requirement for R > 4.1.0 (required by tsgarch)
5+
* Fix to Rf_error prompted from Rcpp team
56

67
# tsmarch 1.0.1
78

R/dcc.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
{
192192
elapsed <- Sys.time()
193193
estimate <- NULL
194-
solver <- match.arg(solver[1], c("solnp","nloptr"))
194+
solver <- match.arg(solver[1], c("solnp","nloptr","csolnp"))
195195
arglist <- list()
196196
dcc_env <- new.env(hash = TRUE)
197197
arglist$dcc_env <- dcc_env

R/solvers.R

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
{
33
switch(solver,
44
"solnp" = sol$pars,
5+
"csolnp" = sol$pars,
56
"nloptr" = sol$solution,
67
"optim" = sol$par)
7-
88
}
99

1010
.default_options <- function(solver, control = list(trace = 1))
1111
{
1212
control <- switch(solver,
1313
"solnp" = .solnp_defaults(control),
14+
"csolnp" = .csolnp_defaults(control),
1415
"nloptr" = .nloptr_defaults(control),
1516
"optim" = .lbfgsb_defaults(control))
1617
}
@@ -46,11 +47,22 @@
4647
return(control)
4748
}
4849

50+
.csolnp_defaults <- function(control)
51+
{
52+
if (is.null(control$trace)) control$trace <- 0
53+
if (is.null(control$rho)) control$rho <- 1.0
54+
if (is.null(control$max_iter)) control$max_iter <- 400
55+
if (is.null(control$min_iter)) control$min_iter <- 600
56+
if (is.null(control$tol)) control$tol <- 1e-8
57+
return(control)
58+
}
59+
4960

5061
.solver_extract_solution <- function(sol, solver = "solnp")
5162
{
5263
switch(solver,
5364
"solnp" = sol$values[length(sol$values)],
65+
"csolnp" = sol$objective,
5466
"nloptr" = sol$objective,
5567
"optim" = sol$value)
5668
}
@@ -61,6 +73,10 @@
6173
sol <- try(solnp(pars = pars, fun = fun, ineqfun = arglist$inequality_cons,
6274
ineqLB = -1.0, ineqUB = 0.0, LB = lower, UB = upper,
6375
control = control, arglist = arglist), silent = TRUE)
76+
} else if (solver == "csolnp") {
77+
sol <- try(csolnp(pars = pars, fn = fun, ineq_fn = arglist$inequality_cons,
78+
ineq_lower = -1.0, ineq_upper = 0.0, lower = lower, upper = upper,
79+
control = control, arglist = arglist), silent = TRUE)
6480
} else if (solver == "nloptr") {
6581
sol <- try(nloptr(x0 = pars, eval_f = fun, eval_grad_f = arglist$grad,
6682
lb = lower, ub = upper, eval_g_ineq = arglist$inequality_cons,
@@ -75,6 +91,10 @@
7591
sol <- try(solnp(pars = pars, fun = fun, ineqfun = arglist$inequality_cons,
7692
LB = lower, UB = upper,
7793
control = control, arglist = arglist), silent = TRUE)
94+
} else if (solver == "csolnp") {
95+
sol <- try(csolnp(pars = pars, fn = fun, ineq_fn = arglist$inequality_cons,
96+
ineq_lower = -1.0, ineq_upper = 0.0, lower = lower, upper = upper,
97+
control = control, arglist = arglist), silent = TRUE)
7898
} else if (solver == "nloptr") {
7999
sol <- try(nloptr(x0 = pars, eval_f = fun, eval_grad_f = arglist$grad,
80100
lb = lower, ub = upper, opts = control,

R/tsmarch-package.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#' @importFrom sandwich estfun bwNeweyWest vcovHAC vcovOPG bread
1111
#' @importFrom nloptr nloptr
1212
#' @importFrom grDevices hcl.colors heat.colors terrain.colors topo.colors
13-
#' @importFrom Rsolnp solnp
13+
#' @importFrom Rsolnp solnp csolnp
1414
#' @importFrom graphics grid layout lines par axis barplot contour hist image mtext persp points title abline box
1515
#' @importFrom future.apply future_lapply
1616
#' @importFrom future future

src/copula.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ arma::mat pit_transform(arma::mat u, const double shape, Rcpp::String distributi
6464
z.col(i) = vqstd(u.col(i), shape);
6565
}
6666
} else{
67-
Rf_error("pit_transform: unknown distribution");
67+
(Rf_error)("pit_transform: unknown distribution");
6868
}
6969
return z;
7070
}
@@ -556,7 +556,7 @@ Rcpp::List copula_dynamic_simulate(const arma::vec alpha, const arma::vec gamma,
556556
} else if (distribution == "mvn") {
557557
Z.row(i) = rmvnorm(Rt, ztmp);
558558
} else {
559-
Rf_error("cgarchsim: unknown distribution");
559+
(Rf_error)("cgarchsim: unknown distribution");
560560
}
561561
AsyZ.row(i) = matrix_sign(Z.row(i)) % Z.row(i);
562562
}
@@ -566,7 +566,7 @@ Rcpp::List copula_dynamic_simulate(const arma::vec alpha, const arma::vec gamma,
566566
} else if (distribution == "mvt") {
567567
U = mpstd(Z, shape);
568568
} else {
569-
Rf_error("cgarchsim: unknown distribution");
569+
(Rf_error)("cgarchsim: unknown distribution");
570570
}
571571
if (exc > 0) {
572572
R.shed_slices(0, exc - 1);
@@ -592,7 +592,7 @@ Rcpp::List copula_constant_simulate(const double shape, const arma::mat R, const
592592
} else if (distribution == "mvn") {
593593
Z.row(i) = rmvnorm(R, ztmp);
594594
} else {
595-
Rf_error("cgarchsim: unknown distribution");
595+
(Rf_error)("cgarchsim: unknown distribution");
596596
}
597597
}
598598
arma::mat U = arma::zeros(arma::size(Z));
@@ -601,7 +601,7 @@ Rcpp::List copula_constant_simulate(const double shape, const arma::mat R, const
601601
} else if (distribution == "mvt") {
602602
U = mpstd(Z, shape);
603603
} else {
604-
Rf_error("cgarchsim: unknown distribution");
604+
(Rf_error)("cgarchsim: unknown distribution");
605605
}
606606
List L = List::create(Named("R") = R, _("Z") = Z, _("U") = U, _("chisqrv") = chisqrv);
607607
return L;

src/dcc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ Rcpp::List dcc_dynamic_simulate(const arma::vec alpha, const arma::vec gamma,
540540
} else if (distribution == "mvn") {
541541
Z.row(i) = rmvnorm(Rt, ztmp);
542542
} else {
543-
Rf_error("dccsim: unknown distribution");
543+
(Rf_error)("dccsim: unknown distribution");
544544
}
545545
AsyZ.row(i) = matrix_sign(Z.row(i)) % Z.row(i);
546546
}
@@ -567,7 +567,7 @@ Rcpp::List dcc_constant_simulate(const double shape, const arma::mat R, const ar
567567
} else if (distribution == "mvn") {
568568
Z.row(i) = rmvnorm(R, ztmp);
569569
} else {
570-
Rf_error("cgarchsim: unknown distribution");
570+
(Rf_error)("cgarchsim: unknown distribution");
571571
}
572572
}
573573
List L = List::create(Named("R") = R, _("Z") = Z, _("chisqrv") = chisqrv);

0 commit comments

Comments
 (0)