I was wondering if EViews has root-finding capabilities for a univariate function (Brent's method, bisecetion, secant, or something similar).
Simple example: there is an indicator (monthly sales). There are forecast monthly logarithmic growth rates (pre-defined). There is a forecast annual figure for the total monthly sales. The goal is to find such a constant that, when added to all monthly growth rates, would produce a series of levels that add up to the annual figure. In other words, we want to make an additive adjustment of a series and find the correct adjustment factor. This is the quick working example in R:
Code: Select all
r <- c(-0.063, 0.018, -0.084, 0.160, 0.033, -0.082, 0.049, 0.074, 0.058, -0.031, 0.151, 0.039)
y.ann.sum.desired <- 15
y <- exp(cumsum(r)) # Levels from log-growth rates
y.ann.sum <- sum(y) # 13.02 -- lower than the desired 15
Code: Select all
sumCorr <- function(x = 0) sum(exp(cumsum(r + x)))
sumCorr(0.01) # = 13.96, closer to the truth
sumCorr(x = 0.0201) # = 15.0007, overshoot
sumCorr(x = 0.020093) # = 14.9999, almost correct
Code: Select all
uniroot(function(x) sumCorr(x) - y.ann.sum.desired, interval = c(0.01, 0.03), tol = 1e-10)
# $root = 0.02009369
sum(exp(cumsum(r + 0.0200936879))) # 15.000000005, great!
Many thanks in advance!
Yours sincerly,
Andreï V. Kostyrka