I am doing forecasts for US counties on a few economic criteria. I am using the "forecast" package in R.

How do you set up the forecast so that the effect of the trend decreases as it approaches a certain point? Meaning, I want to show that as the unemployment rate declines, it becomes increasingly difficult for it to decline further. Almost like an asymptote.

I tried specifying the lower bounds, but this didn't seem to help. The counties that reached the theoretical minimum weren't affluent counties that had come close to reaching it already, but "problematic" counties that had seen the unemployment rate drop several percentage points in the last few years. Obviously this rate of improvement is unsustainable.

unemp_data=data.frame("Area"=c("County 1", "County 2", "County 3"), "2017"=c(6.4, 6.8, 10.9), "2018"=c(5.8, 6.1, 9.9), "2019"=c(5.5, 5.7, 9.4), "2020"=c(4.7, 5.0, 7.7))
unemp_data <- melt(unemp_data)
unemp_data = cast(unemp_data[order(unemp_data$County),], variable~County, mean)
unemp_data <- ts(unemp_data[,-1], f=1, s=2017, e=2020)
years <- c("2021", "2022", "2023", "2024", "2025")

#Creating Output Table

ns = ncol(unemp_data)
h = 5
fcast1 <- matrix(NA, nrow=h, ncol=ns)

#Forecasting Loop
for(i in 1:ns) { fcast1[,i] <- forecast(unemp_data[,i], h=h)$mean }


#Custom Forecast Function

fcast_fnc <- function(y) { (b-a)*exp(forecast(ets(unemp_fcast[,y]), h=h)$mean)/(1+exp(forecast(ets(unemp_fcast[,y]), h=h)$mean))+a }

#Performing the Forecast

unemp_fcast <- log((unemp_data-alpha)/(beta-unemp_data))

fcast2 <- sapply(1:NCOL(unemp_fcast), fcast_fnc)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.