@@ -137,7 +137,7 @@ feat_stl <- function(x, .period, s.window = 11, ...){
137137# ' @rdname unitroot
138138# ' @export
139139unitroot_kpss <- function (x , type = c(" mu" , " tau" ), lags = c(" short" , " long" , " nil" ), ... ) {
140- require_package (" urca" )
140+ check_installed (" urca" )
141141 result <- urca :: ur.kpss(x , type = type , lags = lags , ... )
142142 pval <- stats :: approx(result @ cval [1 ,], as.numeric(sub(" pct" , " " , colnames(result @ cval )))/ 100 , xout = result @ teststat [1 ], rule = 2 )$ y
143143 c(kpss_stat = result @ teststat , kpss_pvalue = pval )
@@ -151,7 +151,7 @@ unitroot_kpss <- function(x, type = c("mu", "tau"), lags = c("short", "long", "n
151151# ' @export
152152unitroot_pp <- function (x , type = c(" Z-tau" , " Z-alpha" ), model = c(" constant" , " trend" ),
153153 lags = c(" short" , " long" ), ... ) {
154- require_package (" urca" )
154+ check_installed (" urca" )
155155 result <- urca :: ur.pp(x , type = match.arg(type ), model = match.arg(model ),
156156 lags = match.arg(lags ), ... )
157157 pval <- stats :: approx(result @ cval [1 ,], as.numeric(sub(" pct" , " " , colnames(result @ cval )))/ 100 , xout = result @ teststat [1 ], rule = 2 )$ y
@@ -247,7 +247,7 @@ unitroot_nsdiffs <- function(x, alpha = 0.05, unitroot_fn = ~ feat_stl(.,.period
247247# '
248248# ' @export
249249cointegration_johansen <- function (x , ... ) {
250- require_package (" urca" )
250+ check_installed (" urca" )
251251 result <- urca :: ca.jo(x , ... )
252252
253253 pct <- as.numeric(sub(" pct" , " " , colnames(result @ cval )))/ 100
@@ -328,7 +328,7 @@ cointegration_johansen <- function(x, ...) {
328328# '
329329# ' @export
330330cointegration_phillips_ouliaris <- function (x , ... ) {
331- require_package (" urca" )
331+ check_installed (" urca" )
332332 result <- urca :: ca.po(x , ... )
333333 pval <- stats :: approx(result @ cval [1 ,], as.numeric(sub(" pct" , " " , colnames(result @ cval )))/ 100 , xout = result @ teststat [1 ], rule = 2 )$ y
334334 c(phillips_ouliaris_stat = result @ teststat , phillips_ouliaris_pvalue = pval )
@@ -370,7 +370,7 @@ n_flat_spots <- function(x) {
370370# '
371371# ' @export
372372coef_hurst <- function (x ) {
373- require_package (" fracdiff" )
373+ check_installed (" fracdiff" )
374374 # Hurst=d+0.5 where d is fractional difference.
375375 return (c(coef_hurst = suppressWarnings(fracdiff :: fracdiff(na.contiguous(x ), 0 , 0 )[[" d" ]] + 0.5 )))
376376}
0 commit comments