Lag the time-series slots in a Data
object by a specified number of time-steps
Source: R/Data_Functions.R
Lag_Data.Rd
Lag the time-series slots in a Data
object by a specified number of time-steps
Details
By default, all simulated data in the forward projections are provided up to the
previous time-step. That is, in projection year t
, the simulated data are up to
and including t-1
.
This function will lag the time-series values by the specified value. For example,
Data_Lag=5
will mean in projection time-step t
the data will be up to and
including t-6
.
Note: The Data@Year
slot is not lagged by this function.
Many built-in MPs use the length of Data@Year
to determine the number of
years of data for smoothing over recent years etc. This may not be appropriate
so check the MP is behaving as you expect if you use Lag_Data
.
Examples
# Lag all time-series slots by 2 time-steps (usually years)
Data <- Example_datafile
Lagged_1 <- Lag_Data(Data, 2)
length(Data@Year)
#> [1] 13
length(Lagged_1@Year)
#> [1] 13
length(Data@Cat[1,])
#> [1] 13
length(Lagged_1@Cat[1,])
#> [1] 11
length(Data@Ind[1,])
#> [1] 13
length(Lagged_1@Ind[1,])
#> [1] 11
# Lag CAA by 5 and Ind by 3 time-steps
Lagged_2 <- Lag_Data(Data, Data_Lag=list(CAA=5, Ind=3))
length(Lagged_2@Year)
#> [1] 13
length(Lagged_2@Cat[1,])
#> [1] 13
dim(Data@CAA[1,,])
#> [1] 13 16
dim(Lagged_2@CAA[1,,])
#> [1] 8 16
length(Data@Ind[1,])
#> [1] 13
length(Lagged_2@Ind[1,])
#> [1] 10