# Imputing nested time series data with R

Does anyone know what is the superior algorithm to impute data in time series? I had strong dropouts over time because it was free to participants how many times to participate in my study (otherwise I would have received a even samller sample).
Now I wished I could impute the missing measurements at least till the 5th or 6th meeting but preferably for all measurements. Since I want to find out if there are effects over time, I don`t want to use the LOCF algorithm (and would rather prefer chained equations or something similiar).
Another difficulty is that I have nested data (people in groups) and need an algorithm that considers the structure of my data. Can someone help me? ## 1 Answer

If I understand correctly, you have longitudinal data, i.e., data over time for each participant. If this is the case, then you can use a mixed-effects model or a multivariate regression model. In this type of models and provided that you define the mean and covariances structures appropriately/flexibly, you do not need to do any multiple-imputation. Estimating the models under a likelihood framework (e.g., maximum likelihood or Bayesian), will provide you with correct estimates and standard errors under the missing at random missing data mechanism (also under the missing completely at random mechanism). You will need some extra if you have missing not at random missing data.

P.s., above I'm talking about missing data in the outcome variable. If you have missing data in the covariates, then multiple-imputation is indeed used.

• Thank you! The students with missing values have those missings at the input and outcome variable. E.g. a lot of participants finished the third measurement but then did never take part on later measurements so they have no values for later measurements. I made the same observation for all later measurements (see graphic). – Nadine M. Oct 16 '18 at 8:48
• Further, my participants were students in groups. It happend that 2 students of one group met 13 times but a 3rd student of this group only participated in 3 measurements. I want to first plot decision trees and thought it could be critical to plot probabilities for decisions when there are students in the sample having much more measurements than others – Nadine M. Oct 16 '18 at 8:54
• This seems as dropout to me, i.e., some participants have only one measurement and then they dropped out, some the first two and then they dropped out, and so on. This setting could be handled with the models I suggested. Also, in these models, you can control for covariates you have recorded, e.g., groups differences between the students. – Dimitris Rizopoulos Oct 16 '18 at 12:09