I need to "undifference" or "integrate" a time series variable. In its current state, it is twice-differenced (a money market, cash return proxy variable that was I(2) to achieve stationarity). I simulated the variable, along with others, to generate 100,000 observations from a fitted copula, so I have no initial reference value to start off the "undifferencing" function as in R's
Here is a simplified problem to illustrate (using R):
Create an arbitrary original series:
undifferenced = c(0.5, -0.1, 0.2, 0.08, -0.02)
Difference the series:
differenced = diff(undifferenced)
Output: -0.60 0.30 -0.12 -0.10
Attempt to "undifference" the series:
Output: 0.00 -0.60 -0.30 -0.42 -0.52,
which is not the original series
Or if you want to remove the
0.00 to clean up:
Output: -0.60 -0.30 -0.42 -0.52,
which in any event is not the original series
If you "somehow" know, a priori, the initial value of the original series, the output is correct:
diffinv(fff, xi = 0.5)
Output: 0.50 -0.10 0.20 0.08 -0.02,
which IS the original series.
In my simulation, I have no way of specifying
At this point, if anyone has any experience "undifferencing" correctly or could help figure out the problem, I would appreciate any help.
As an aside, for non-R users, I can export the data to work with in Excel.
Thanks in advance.
@Andy @Glen_b I appreciate the help, thank you. I'm gna evaluate under the pretext that the
mean of the original series is a good enough proxy to initialize the
diffinv() function (in a context of simulation where you don't have an actual original value to initialize). The assumption then that the simulated differenced data is of the same quality as the original differenced data.
A problem came up though in initializing
xi = mean(undifferenced) - this scalar value works on a smaller set of observations (~240 obs), but the scalar doesn't let the
diffinv() function operate on the simulated series of 100,000 observations.
R's help file describes
xi as a "
numeric vector, matrix, or time series containing the initial values for the integrals". Any ideas or reference? There's no guidance of what the length the
xi vector should be and I would've thought just one scalar would suffice in kicking off the undifferencing process.