Your code is not easily readable. Please copy it from your R session and enclose it with 3 backticks before and after in your posting to make it better readable.
I am not an expert on mediation analysis and imputation so I probably can't help you.
However I would expect that this code would not run because the imp3
variable is nowhere defined in your code. Also I don't see which packages you are using. So you probably did not insert all code.
The best way to avoid these issues is to present a reprex. This will at the same time resolve the formatting issue.