hi jthornton1,
in the past i did something similar to what you mention. it is not the fastest or simplest but it could do the job.
once you have a duration column and a difference column (and the time you had from the source) you can complicate the imputation formula as much as you like.
Names Default To Here( 1 );
// open original data set
dt = Open( "$SAMPLE_DATA/Time Series/CO2.jmp" );
// delete about 25 random rows
For( i = 1, i <= 25, i++,
x = Random Integer( 161 );
dt:co2[x] = .;
);
// at this point you just have a data with missing values.
// add a column for time - if you have one you do not need it.
dt << New Column( "t" );
For Each Row( :t = Row() );
// here is where you start
// subset the original table and delete the rows with missing values.
dtSub = dt << Subset( All rows, columns( :CO2, :t ) );
dtSub << delete rows( dtSub << get rows where( Is Missing( :co2 ) ) );
// introduce the duration column
dtSub << New Column( "Duration" );
For Each Row( :Duration = Lag( :t, -1 ) - :t );
// introduce the change in co2 from row to row.
dtSub << New Column( "co2 change" );
For Each Row( :Name( "co2 change" ) = Lag( :Name( "co2" ), -1 ) - :Name( "co2" ) );
// update the duration and difference to the original table;
dt << update( with( dtSub ), Match Columns( :t = :t ) );
// close the subset table
Close( dtSub, no save );
// fill the missing rows - need for the next step
For Each Row( :Duration = If( Is Missing( :Duration ), Lag( :Duration, 1 ), :Duration ) );
For Each Row( :Name( "co2 change" ) = If( Is Missing( :Name( "co2 change" ) ), Lag( :Name( "co2 change" ), 1 ), :Name( "co2 change" ) ) );
// now you can fill in the missing values with a formula into a new column or in to the existing one
dt << New Column( "co2 full" );
For Each Row(
:Name( "co2 full" ) = If(
Row() == 1, :CO2,
:Duration == 1, :CO2,
:Duration > 1, Lag( :Name( "co2 full" ), 1 ) + (:Name( "co2 change" ) / :Duration)
)
);