numberPredictableObservations
is a function to determine the number of observations in a given dataset that can be predicted based on the availability of previous observations, considering a specified time-lag.
numberPredictableObservations(Data, yVars, Beep, Day = NULL, ID,
xContinuous = NULL, xFactor = NULL, Lags, ...)
The number of predictable observations for each endogenous variable per subject, considering a specified time-lag.
The total number of predictable observations summed over all subjects in the dataset for each endogenous variable, considering a specified time-lag.
The data provided in a data.frame.
An integer vector specifying the position of the column(s) in dataframe Data
that contain the endogenous variables (= the VAR time series).
An integer specifying the position of the column in dataframe Data
that contains the time-point.
Optional. An integer specifying the position of the column in dataframe Data
that contains the variable that indicates the day of measurement. If Day
is supplied here, measurements on the previous day are not used to predict measurements on the current day. Instead, the first Lags
observations within each day are excluded from the calculation of VAR coefficients.
An integer specifying the position of the column in dataframe Data
that contains the ID variable for every participant.
Optional argument. An integer vector specifying the position of the column(s) in dataframe Data that contain the continuous exogenous variable(s), if present. Exogenous variables are also known as covariates or as moderators for the within-person mean.
Optional argument. An integer vector specifying the position of the column(s) in dataframe Data that contain the categorical exogenous variable(s), if present. Exogenous variables are also known as covariates or as moderators for the within-person mean.
An integer or integer vector specifying the number of VAR(p) lags to consider. Needs to be a sequence of subsequent integers. The maximum number supported is Lags = 3
.
Additional arguments passed to the function.
Anja Ernst & Jonas Haslbeck
This function determines the number of observations in a given dataset that can be predicted based on previous observations. For instance, in a lag-1 model, if an observation is missing, the observation at the next time-point cannot be predicted. Similarly, in a lag-2 model, if an observation is missing, the observations at the next two time-points cannot be predicted. The output gives the number of predictable observations for each of the endogenous variables that was specified under yVars
. The number of predictable observations is the same for all endogenous variables.
# \donttest{
head(SyntheticData)
Obs <- numberPredictableObservations(Data = SyntheticData, yVars = 1:4,
Beep = 9, Day = 10, ID = 5, Lags = 1:3)
Obs
Obs$`Predictable observations per subject`$`1 Lag`
# }
Run the code above in your browser using DataLab