The language I use is R, but you don't have to know about R to answer the question.
Question:
I have a sequence that can be considered the main truth, and the other is a shifted version of the first, with some missing values. I would like to know how to align two.
Customization
I have a sequence ground.truththat basically is a set of times:
ground.truth <- rep( seq(1,by=4,length.out=10), 5 ) +
rep( seq(0,length.out=5,by=4*10+30), each=10 )
Think about ground.truthhow the times when I do the following:
{take a sample every 4 seconds for 10 times, then wait 30 seconds} x 5
I have a second sequence observationsthat is ground.truthshifted from 20% of the missing values:
nSamples <- length(ground.truth)
idx_to_keep <- sort(sample( 1:nSamples, .8*nSamples ))
theLag <- runif(1)*100
observations <- ground.truth[idx_to_keep] + theLag
nObs <- length(observations)
If I draw these vectors, this is what it looks like (remember, think of it as time):

, . :
- (
theLag ) idx , ground.truth[idx] == observations - theLag
, theLag. , ground.truth[1] observations[1]-theLag. , lagI ground.truth[1] == observations[1+lagI]-theLag.
, , - (ccf).
, , . - 0, ground.truth[1] == observations[1] - theLag. , , observations[1] - theLag ground.truth[1] (.. idx_to_keep, , 1).
theLag - ( ccf(x,y) == ccf(x,y-constant)?), .
, , observations , ground.truth? , theLag==0, - , , .
- , R-/, ?
.