# Matrix with eigenvalues greater than 1
x <- matrix(
data = c(
1.2, 0.3,
0.4, 0.9
),
nrow = 2
)
SpectralRadius(x = x) # > 1
SpectralRadius(x = ProjectToStability(x = x)) # < 1
# Matrix already stable is returned unchanged
x <- matrix(
data = c(
0.5, 0.3,
0.2, 0.4
),
nrow = 2
)
identical(ProjectToStability(x = x), x)
Run the code above in your browser using DataLab