How to "undifference" a time series variable 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 diffinv() function.
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:
diffinv(differenced)
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:
diffinv(differenced)[-1]
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 xi.
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.
 A: I'm afraid you've already hit upon the easiest solution, which is to pick a xi, aka the constant of integration. The alternative is to phrase any question you ask about your "undifferenced" sequence such that the constant of integration doesn't matter.
The underlying problem is that "differencing" maps many sequences of values to the same sequence of differences. If $x_n$ is your sequence, then for any constant $C$, the sequence $x_n+ C$ will have the same differences.
A: Instead of doing diff() with the actual time series data, use instead the d parameter in auto.arima function to define it. lets say your data series is val.ts and you want to do differencing only until first order to make your series stationary, then instead of using auto.arima(diff(val.ts)), do auto.arima(val.ts,d=1). I have answered it here to my actual question here
Convert double differenced forecast into actual value
A: Since the series was twice-differenced, you need the first two values of the original source data.
You mention that it is a money market, cash return proxy variable. Shouldn't it be possible to get the source data?
In your simulation, I'm assuming you are generating 100,000 series that have similar characteristics (using the fitted copula) as the twice-differenced data? You just need to choose your xi values to "re-calibrate" your differencing series back to be similar to the original.
In your example, the 0.5 is the initial value to start at when adding each differencing step back.
If I generated 100,000 differencing series, I would set xi to 0.5 to have the same starting point as the original.
