Error when trying to use imputed data for sem using "mi" package

69 Views Asked by At

I am trying to conduct a path model with my imputed data but I can't figure out how to get my code to work.

A regular regression like this works fine with the pool function

analysis <- pool(outcome1 ~ variable1 + variable2,
             data = imputations, m = NULL)

But when I try to make it a path model it gives me errors.

e.g., of code I've tried

analysis <- pool(outcome1 + outcome2 ~ variable1 + variable2,
             data = imputations, m = NULL)

Error in pool(outcome1 + outcome2 ~ variable1 + variable2, data = imputations, : no variable called outcome1 + outcome2 possibly due to typo or transformation, in which case you need to specify 'FUN' explicitly

analysis <- sem(pool(outcome1 + outcome2 ~ variable1 + variable2,
             data = imputations, m = NULL))

Error in pool(outcome1 + outcome2 ~ variable1 + variable2, data = imputations, : no variable called outcome1 + outcome2 possibly due to typo or transformation, in which case you need to specify 'FUN' explicitly

analysis <- pool(outcome1 ~ variable1 + variable2
                  outcome2 ~ variable1 + variable2,
             data = imputations, m = NULL)

Error: unexpected ',' in " data = imputations,"

analysis <- 'outcome1 ~ variable1 + variable2
              outcome2 ~ variable1 + variable2'

 path <- sem(pool(analysis, data=imputations, m=NULL))

.Error in pool(analysis, data = imputations, m = NULL) : 'formula' must be a formula

I'm still new to r, any ideas of what I'm doing wrong?

0

There are 0 best solutions below