Skip to content

Commit

Permalink
fix: incorrect warning
Browse files Browse the repository at this point in the history
warning for phi >=1 was not set properly. Simplified code so it will correctly warn when phi >=1.
  • Loading branch information
k-doering-NOAA committed Apr 1, 2024
1 parent ba9ef37 commit 10a9cc6
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions R/initOM_create_devs_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ sample_vals <- function(mean,
# need to think more about if this is correct or not. this isn't exactly
# an ar 1 process as described....because the variance isn't constant.
samps <- vector(mode = "numeric", length = ndevs)
nonstat_warning <- TRUE
for (d in seq_len(ndevs)) {
if (d == 1) {
past_samp <- 0 # I think
Expand All @@ -256,12 +255,9 @@ sample_vals <- function(mean,
stats::rnorm(1, mean = 0, sd = sd[d] / sqrt(1 / (1 - ar_1_phi[d]^2)))
} else {
samps[d] <- mean[d] + ar_1_phi[d] * past_samp + stats::rnorm(1, mean = 0, sd = sd[d])
nonstat_warning <- TRUE
warning("An AR1 process with phi >= 1 was called, therefore will be nonstationary.")
}
}
if (nonstat_warning) {
warning("An AR1 process with phi >= 1 was called, therefore will be nonstationary.")
}
}
samps
}
Expand Down

0 comments on commit 10a9cc6

Please sign in to comment.