@@ -157,8 +157,7 @@ jvn_nowcast <- function(
157157
158158 if (! include_news && ! include_noise ) {
159159 rlang :: abort(
160- " At least one of `include_news` or `include_noise` must be TRUE." ,
161- call = rlang :: caller_env()
160+ " At least one of `include_news` or `include_noise` must be TRUE."
162161 )
163162 }
164163
@@ -320,7 +319,7 @@ jvn_nowcast <- function(
320319 abort_flag(standardize , " standardize" )
321320
322321 if (! is.list(solver_options )) {
323- rlang :: abort(" `solver_options` must be a list." , call = rlang :: caller_env() )
322+ rlang :: abort(" `solver_options` must be a list." )
324323 }
325324
326325 # Solver options (defaults + validation + legacy aliases) ----
@@ -362,8 +361,7 @@ jvn_nowcast <- function(
362361 " Valid options are: " ,
363362 paste(names(default_solver_options ), collapse = " , " ),
364363 " ."
365- ),
366- call = rlang :: caller_env()
364+ )
367365 )
368366 }
369367
@@ -466,8 +464,7 @@ jvn_nowcast <- function(
466464 " IDs were provided: " ,
467465 paste(names(check ), collapse = " , " ),
468466 " ."
469- ),
470- call = rlang :: caller_env()
467+ )
471468 )
472469 }
473470 df <- df [[1 ]]
@@ -480,18 +477,15 @@ jvn_nowcast <- function(
480477 paste0(
481478 " `df` contains " , length(unique(df $ id )), " different IDs. " ,
482479 " Filter to a single ID first."
483- ),
484- call = rlang :: caller_env()
480+ )
485481 )
486482 }
487483 df <- suppressWarnings(vintages_wide(df , names_from = " release" ))
488484 if (is.list(df ) && ! is.data.frame(df )) df <- df [[1 ]]
489485 }
490486
491487 if (! (" time" %in% names(df ))) {
492- rlang :: abort(" After preprocessing, `df` must contain a `time` column." ,
493- call = rlang :: caller_env()
494- )
488+ rlang :: abort(" After preprocessing, `df` must contain a `time` column." )
495489 }
496490
497491 # Keep time first (predictable subsetting)
@@ -503,8 +497,7 @@ jvn_nowcast <- function(
503497 paste0(
504498 " Not enough vintage columns in `df`.\n " ,
505499 " Requested `e = " , e , " ` but found " , n_vint_total , " vintage columns."
506- ),
507- call = rlang :: caller_env()
500+ )
508501 )
509502 }
510503
@@ -515,9 +508,7 @@ jvn_nowcast <- function(
515508 is.numeric(time_in ) ||
516509 is.integer(time_in )) &&
517510 any(diff(as.numeric(time_in )) < = 0 , na.rm = TRUE )) {
518- rlang :: abort(" `time` must be strictly increasing." ,
519- call = rlang :: caller_env()
520- )
511+ rlang :: abort(" `time` must be strictly increasing." )
521512 }
522513
523514 # Internal working subset: time + first e vintages
@@ -550,8 +541,7 @@ jvn_nowcast <- function(
550541 if (! is.null(default_solver_options $ startvals )) {
551542 if (length(default_solver_options $ startvals ) != model_struct $ n_params ) {
552543 rlang :: abort(
553- paste0(" `startvals` must have length " , model_struct $ n_params , " ." ),
554- call = rlang :: caller_env()
544+ paste0(" `startvals` must have length " , model_struct $ n_params , " ." )
555545 )
556546 }
557547 init_params <- default_solver_options $ startvals
@@ -791,7 +781,7 @@ jvn_nowcast <- function(
791781 }
792782
793783 if (! is.null(se_warning )) {
794- warning (se_warning , call. = FALSE )
784+ rlang :: warn (se_warning )
795785 }
796786 }
797787
@@ -817,7 +807,7 @@ jvn_nowcast <- function(
817807 }
818808
819809 if (! is.null(se_warning ) && default_solver_options $ trace > 0 ) {
820- warning (se_warning , call. = FALSE )
810+ rlang :: warn (se_warning )
821811 }
822812
823813 # Update matrices at estimates + parameter table + IC ----
@@ -1624,7 +1614,7 @@ jvn_init_params <- function(model_struct, data, transform_se = TRUE) {
16241614 data <- as.matrix(data )
16251615 data_clean <- data [stats :: complete.cases(data ), , drop = FALSE ]
16261616 if (nrow(data_clean ) < ar_order + 10 ) {
1627- warning (
1617+ rlang :: warn (
16281618 " Insufficient data for smart initialization. Using fallback values."
16291619 )
16301620 return (fallback())
@@ -1753,7 +1743,9 @@ jvn_init_params <- function(model_struct, data, transform_se = TRUE) {
17531743
17541744 # ---------- 6) final validation ----------
17551745 if (any(! is.finite(params ))) {
1756- warning(" Non-finite starting values detected. Using fallback values." )
1746+ rlang :: warn(
1747+ " Non-finite starting values detected. Using fallback values."
1748+ )
17571749 return (fallback())
17581750 }
17591751
@@ -1841,11 +1833,12 @@ jvn_qml_covariance <- function(
18411833 )
18421834
18431835 if (length(c_plus ) != nT ) {
1844- stop (
1836+ rlang :: abort (
18451837 paste(
18461838 " jvn_negloglik_contrib returned different length under" ,
18471839 " perturbation; cannot form scores."
1848- )
1840+ ),
1841+ call = rlang :: caller_env()
18491842 )
18501843 }
18511844
@@ -1854,11 +1847,12 @@ jvn_qml_covariance <- function(
18541847 theta_hat - step , model_struct , y , transform_se
18551848 )
18561849 if (length(c_minus ) != nT ) {
1857- stop (
1850+ rlang :: abort (
18581851 paste(
18591852 " jvn_negloglik_contrib returned different length under" ,
18601853 " perturbation; cannot form scores."
1861- )
1854+ ),
1855+ call = rlang :: caller_env()
18621856 )
18631857 }
18641858 scores [, j ] <- (c_plus - c_minus ) / (2 * score_eps )
@@ -1883,7 +1877,12 @@ jvn_qml_covariance <- function(
18831877 if (qml_scale == " mean" ) {
18841878 Xproduct <- Xproduct / Tobs
18851879 } else if (qml_scale == " hc" ) {
1886- if (Tobs < = p ) stop(" hc scaling requires Tobs > number of parameters." )
1880+ if (Tobs < = p ) {
1881+ rlang :: abort(
1882+ " hc scaling requires Tobs > number of parameters." ,
1883+ call = rlang :: caller_env()
1884+ )
1885+ }
18871886 Xproduct <- (Tobs / (Tobs - p )) * (Xproduct / Tobs )
18881887 }
18891888
0 commit comments