Forecast Fit always one step forward I'm making a projection using time series, but I have a problem that I can't solve.
My forecast fit is always one step (month) ahead of my data. What do I mean by this?
The movement of the curve of my fit is correct, but it seems outdated.

I'm not managing to solve it. Can someone help me?
Here is my schedule:
    library(astsa)
library(smooth)
library(Mcomp)
library(xlsx)


#ImportDATA
dados <- scan()
2619
2599
2618
2599
2580
2751
2762
2717
2768
2835
2806
2881
2872
2922
2744
2765
2813
3166
3181
3169
3175
3213
3231
2445
2443
2457
2324
2270
2251
2219
2145
1996
2096
2051
1999
1817
1771

var2 = dados[1:37]
var2

var1 = ts(var2, start = c(2018,01), end=c(2021,01), freq = 12)
plot(var1)

auto.ssarima(var1, h=12)

themodel = arima(var1, order = c(0,1,0), seasonal = list(order = c(0,0,1), period = 12))
themodel

prev02=forecast(themodel,h=12)

plot(var1)
lines(prev02$fitted, col='blue')

 A: I don't have a fully satisfactory answer, but it may be helpful. If you really want to understand the details, you may want to step through the source code of forecast.Arima() (note the capital A).
Your arima() call fits an ARIMA(0,1,0)(0,0,1)[12] model. The formula for this model is
$$ (1-B)y_t = (1-\Theta B^{12})\epsilon_t, $$
where $B$ indicates the backshift operator, or
$$ y_t = y_{t-1}+\epsilon_t+\Theta\epsilon_{t-12}. $$
Running your code, we see from the output of themodel that $\Theta$ is estimated as $\widehat\Theta=0.15$.
Now, what happens when the fitted values are calculated? We can first look at a simpler model, namely an ARIMA(0,1,0) one. This is exactly your model, except for the seasonal MA term. Actually, it's a simple random walk:
$$ y_t = y_{t-1}+\epsilon_t. $$
Take a look at what the fitted values for this model are, and compare to the actuals:
forecast(arima(var1,order = c(0,1,0)),h=12)$fitted
var1

You will note that the fitted values are exactly the original values, shifted by one month.
And really, that is not surprising. In calculating the fitted value $\widehat{y}_t$ for time $t$, we take the previous observation $y_{t-1}$ plus an estimate $\widehat{\epsilon}_t$ for the innovation $\epsilon_t$ at time $t$. Since the $\epsilon_t$ are assumed to be normally distributed, one reasonable estimate is $\widehat{\epsilon}_t=0$, which is just the expectation. This leads to
$$ \hat{y}_t = y_{t-1}+0, $$
so the fitted value is just the original time series shifted by one month.
Now, for your model with the seasonal MA term, there is a slight deviation from this simple shift. It seems like $\widehat{\epsilon}_t$ is estimated as $0$, but $\widehat{\epsilon}_{t-12}$ is not, so the fitted value here is
$$ \hat{y}_t = y_{t-1}+\widehat{\epsilon}_t+\widehat\Theta\widehat{\epsilon}_{t-12}
= y_{t-1}+0+0.15\widehat{\epsilon}_{t-12} = y_{t-1}+0.15\widehat{\epsilon}_{t-12}.$$
It looks like $\widehat{\epsilon}_{t-12}$ is quite small, so the "wiggling" is small, too. I don't think this is intended. Either the innovations are estimated as zero, but then they should also be estimated that way for the seasonal lags, or they could also be estimated as the actual residuals between $y_t$ and $y_{t-1}$ in the random walk. (But then, of course, the fitted values in the random walk would be precisely the time series itself, which would also be of dubious usefulness, and your model's fitted values would wiggle a little around the time series itself.)
Incidentally, if you just use the model that auto.ssarima() fits, which is a different one (it includes a drift term!), you get a different plot:
plot(forecast(auto.ssarima(var1),h=12))


