From 423e523176fea1f107cea635c3f4e526eabbbca1 Mon Sep 17 00:00:00 2001 From: Daan de Jong Date: Tue, 28 Nov 2023 11:50:46 +0100 Subject: [PATCH] improved logo --- NAMESPACE | 2 ++ NEWS.md | 2 +- R/optimize.R | 9 ++++++++- R/print.R | 2 +- R/welcome.R | 29 ----------------------------- R/zzz.R | 25 +++++++++++++++++++++++++ 6 files changed, 37 insertions(+), 32 deletions(-) delete mode 100644 R/welcome.R create mode 100644 R/zzz.R diff --git a/NAMESPACE b/NAMESPACE index ba56709..f603b96 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -12,6 +12,7 @@ S3method(residuals,hystar_fit) S3method(summary,hystar_fit) S3method(summary,hystar_sim) export(hystar_fit) +export(hystar_info) export(hystar_sim) export(z_sim) importFrom(Rcpp,sourceCpp) @@ -28,5 +29,6 @@ importFrom(stats,qnorm) importFrom(stats,quantile) importFrom(stats,residuals) importFrom(stats,rnorm) +importFrom(utils,browseURL) importFrom(utils,combn) useDynLib(hystar, .registration = TRUE) diff --git a/NEWS.md b/NEWS.md index 4dbcff9..19fc712 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,5 +18,5 @@ # `hystar` 1.0.0 -* First CRAN release! 🎉 +* First CRAN release! diff --git a/R/optimize.R b/R/optimize.R index ab54c4c..a78751c 100644 --- a/R/optimize.R +++ b/R/optimize.R @@ -35,13 +35,20 @@ get_optims <- function(y, eff, x, z, p0, p1, grid) { prev <- rep(-9L, times = length(eff)) for (i in 1:nrow(grid)) { + message("\rsearching delay, r0, r1 for p0 = ", p0, " and p1 = ", p1, + ". ", round(100 * i / nrow(grid), 0), "%", appendLF = FALSE) + #message("Searching delay, r0, r1: ", + # paste(grid[i, "d"], round(grid[i, "r0"], 2), round(grid[i, "r1"], 2), + # sep = ", "), + # "\r", appendLF = FALSE) H <- ts_hys(z[eff - grid[i, "d"]], grid[i, "r0"], grid[i, "r1"]) R <- ts_reg(H, start = grid[i, "s"]) if (all(R == prev)) { results[i] <- results[i-1] } else { X <- create_X(x, p0, p1, R) - results[i] <- fit(y[eff], X)$rss + results[i] <- Inf + try(results[i] <- fit(y[eff], X)$rss, silent = TRUE) } prev <- R } diff --git a/R/print.R b/R/print.R index 9988305..0a69d73 100644 --- a/R/print.R +++ b/R/print.R @@ -34,7 +34,7 @@ print.hystar_sim <- function(x, ...) { } print_hystar <- function(n, d, r0, r1, coe0, coe1, rv0, rv1, simfit, tar) { - model <- if (tar) "TAR model " else "HysTAR model " + model <- if (tar) "\nTAR model " else "\nHysTAR model " cat(paste0(model, simfit, " ", n, " observations."), "\n\n", "if R[t] = 0:\n", make_formula(coe0, rv0), diff --git a/R/welcome.R b/R/welcome.R deleted file mode 100644 index aecad5b..0000000 --- a/R/welcome.R +++ /dev/null @@ -1,29 +0,0 @@ -print_welcome_message <- function() { -hystar_string <- " - _ _ -| | | | -| |__ _ _ ___ | |_ __ _ _ __ -| '_ \\| | | |/ __|| _| / _` || '__\\ -| | | || |_| |\\__ \\| |_ | (_| || | -|_| |_||___ ||___/ \\__| \\__,_||_| - ___| | - |____/ 1.2.0 \n\n" - -info_string <- " -Estimation and simulation of the HysTAR Model. -For function help, run `?hystar_fit`, `?hystar_sim` or `?z_sim`. -For more information, run `hystar_info()`. -" -cat(hystar_string) -cat(info_string) -} - -#' @export -#' @importFrom utils browseURL -hystar_info <- function() { - browseURL("https://daandejongen.github.io/hystar/index.html") -} - - - - diff --git a/R/zzz.R b/R/zzz.R new file mode 100644 index 0000000..7f5edf0 --- /dev/null +++ b/R/zzz.R @@ -0,0 +1,25 @@ +.onAttach <- function(libname, pkgname) { +hystar_string <- " + __ __ + / /_ __ ______/ /_________ + / _ / // (_ -/ _/ _ / __\\ +/_//_/\\_, /___)\\__/\\_,_/_/ + /___/ 1.2.0 + +Estimation and simulation of the HysTAR Model. +For function help, run `?hystar_fit`, `?hystar_sim` or `?z_sim`. +For more information, run `hystar_info()` (opens a URL in your browser). +" + +packageStartupMessage(hystar_string) +} + +#' @export +#' @importFrom utils browseURL +hystar_info <- function() { + browseURL("https://daandejongen.github.io/hystar/index.html") +} + + + +