I am familiarizing myself with SEM and the lavaan package for R bc I would like to run a mediation analysis. My problem is that the data I have is nested and currently I don't see how I could do a mediation analysis on this type of data using lavaan.
The data is from a cognitive psychology study where participants recall answers on a memory test for questions presented in a study phase. The data is clustered by participant (ID ~ 50) and by the topic of the questions (topics = 8). The outcome variable is recall (0/1) the predictor is a variable reflecting if the question is related to a previous reading (0/1) and the mediator is a curiosity rating (1-5). The data is trial level (80 responses/participant), clustered by participants and question topic (all participants read all the questions - 10 resps/topic).
How would you implement a mediation analysis on this data using lavaan, taking into account the clustering of the data? Any help is appreciated.