Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metrics of stability following Ives et al examples #21

Open
nicholasjclark opened this issue Jul 31, 2023 · 0 comments
Open

Add metrics of stability following Ives et al examples #21

nicholasjclark opened this issue Jul 31, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@nicholasjclark
Copy link
Owner

ar1 = 0.5
ar2 = -0.1
ar3 = -0.1
series <- arima.sim(model = list(ar = c(ar1, ar2, ar3)),
                    n = 100, sd = 1)

# Characteristic return rate (Ives et al 2003; 2010) is an 
# indicator of how quickly a dynamic process returns to 
# its stationary distribution following a perturbance; values
# approaching 1 (or greater than 1) indicate a longer time needed
# before the process returns to stability. To calculate this, all we 
# need is the AR coefficients in matrix form
B <- matrix(c(ar1, 1, 0,
              ar2, 0, 1,
              ar3, 0, 0),
           nrow = 3)

# Calculate eigenvalues of the AR coefficient matrix
evalues <- eigen(B)$values

# Complex eigenvalues indicate quasi-cyclic dynamics in
# which the process shows a characteristic periodicity
if(is.complex(evalues)){
  return_rate <- Re(evalues[1])
  period <- 2 * (pi / Im(evalues[1]))
} else {
  return_rate <- evalues[1]
  period <- NA
}
return_rate
period

plot(series)

@nicholasjclark nicholasjclark added the enhancement New feature or request label Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant