27
27
# ' @examples
28
28
# ' \dontrun{
29
29
# ' # To generate a set of MC sampled time-series to AirPassengers
30
- # ' MC_samples <- NNS.MC(AirPassengers, xmin = 0)
30
+ # ' MC_samples <- NNS.MC(AirPassengers, reps = 10, lower_rho = -1, upper_rho = 1, by = .5, xmin = 0)
31
31
# ' }
32
32
# ' @export
33
33
@@ -49,22 +49,25 @@ NNS.MC <- function(x,
49
49
rhos <- seq(lower_rho , upper_rho , by )
50
50
l <- length(rhos )
51
51
52
- neg_rhos <- abs(rhos [rhos < 0 ])
52
+ neg_rhos <- abs(rhos [rhos < = 0 ])
53
53
pos_rhos <- rhos [rhos > 0 ]
54
54
55
55
exp_rhos <- rev(c((neg_rhos ^ exp )*- 1 , pos_rhos ^ (1 / exp )))
56
-
56
+
57
57
if (is.null(target_drift )){
58
- n <- length(x )
59
- orig_coef <- fast_lm(1 : n , x )$ coef
60
- orig_intercept <- orig_coef [1 ]
61
- orig_drift <- orig_coef [2 ]
62
- target_drift <- orig_drift
58
+ if (! is.null(target_drift_scale )){
59
+ replicates <- NNS.meboot(x = x , reps = reps , rho = exp_rhos , type = type , drift = TRUE ,
60
+ target_drift_scale = target_drift_scale ,
61
+ xmin = xmin , xmax = xmax , ... )[" replicates" ,]
62
+ } else {
63
+ replicates <- NNS.meboot(x = x , reps = reps , rho = exp_rhos , type = type , drift = drift ,
64
+ xmin = xmin , xmax = xmax , ... )[" replicates" ,]
65
+ }
66
+ } else {
67
+ replicates <- NNS.meboot(x = x , reps = reps , rho = exp_rhos , type = type , drift = TRUE ,
68
+ target_drift = target_drift ,
69
+ xmin = xmin , xmax = xmax , ... )[" replicates" ,]
63
70
}
64
-
65
-
66
- replicates <- suppressWarnings(NNS.meboot(x = x , reps = reps , rho = exp_rhos , type = type , drift = drift ,
67
- target_drift = target_drift , target_drift_scale = target_drift_scale , xmin = xmin , xmax = xmax , ... ))[" replicates" ,]
68
71
69
72
70
73
ensemble <- Rfast :: rowmeans(do.call(cbind , replicates ))
0 commit comments