# Computing the fitted value for the first observation in a time series

Given coefficients from an arima model, how do you calculate the "fitted value" for the first observation of the series?

For example, given the data (called xshort):

and a call to R:

mod<-Arima(xshort,order=c(1,0,0))
mod$coef  it is simple to produce the fitted values. For example the second entry in the series is: mod$coef[1]*xshort[1]+((1-mod$coef[1])*mod$coef[2])

But, how is the first fitted value calculated, which from Arima should be 1038.3884776139?

The problem exists with more than just the first observation. Take a $$p$$th order AR process. It is only the $$p+1$$st observation that can be expressed as the estimated function of the previous $$p$$ values. For the initial values, you need a set of values estimated by the model as occurring before the first observation. This is done by fitting the series and then predicting backwards. Box and Jenkins call this backcasting. So for the AR($$p$$) process, you need to generate $$p$$ starting values prior to X1. Then you can use these starting values and the model to fit the first $$p-1$$ observations.