matthiasspeidel / hmi

Hierarchical Multiple Imputation
5 stars 1 forks source link

"Using formula(x) is deprecated" and "subscript out of bounds" #2

Open laurenberny opened 2 years ago

laurenberny commented 2 years ago

I am interested in using this package to impute some categorical (both binary and >2 levels) and semi-continuous variables for which there is missing data. The data is longitudinal with timepoints nested within person. My code is:

measurevar <- "surisk" groupvars <- c("sexabuse","attacked","physabuse","caii","sc_safety","sc_ppi","sc_npi","(1|famid)") model_formula <- as.formula(paste(measurevar, paste(groupvars, collapse="+"), sep="~")) result_multi <- hmi(data = dat, model_formula, family = logit)

When I run this, I get the following error messages:

Using formula(x) is deprecated when x is a character vector of length > 1. Consider formula(paste(x, collapse = " ")) instead.Imputation progress: 0% 20% 40% 60% 80% 100% |Error in zdraws_pre[, leftpart] : subscript out of bounds

When I run what is considered, I get the following:

formula(paste(model_formula, collapse = " ")) Error in str2lang(x) : :1:10: unexpected symbol 1: ~ surisk sexabuse ^

I am unsure what the unexpected symbol is. Any feedback on that or the subscript out of bounds error (unsure if they are related) would be helpful!

matthiasspeidel commented 2 years ago

Hello, I assume the problem arises with the shape of your data. Can you provide a minimal reproducible example (cf. for example https://stackoverflow.com/help/minimal-reproducible-example)? What is the result if you run list_of_types_maker(dat) ? Best regards

Am Fr., 11. Feb. 2022 um 22:00 Uhr schrieb Lauren Berny < @.***>:

I am interested in using this package to impute some categorical (both binary and >2 levels) and semi-continuous variables for which there is missing data. The data is longitudinal with timepoints nested within person. My code is:

model_formula <- surisk ~ sexabuse + attacked + physabuse + caii + sc_safety + sc_ppi + sc_npi + (1|famid) result_multi <- hmi(data = dat, model_formula, family = logit)

When I run this, I get the following error messages:

Using formula(x) is deprecated when x is a character vector of length > 1. Consider formula(paste(x, collapse = " ")) instead.Imputation progress: 0% 20% 40% 60% 80% 100% |Error in zdraws_pre[, leftpart] : subscript out of bounds

Any feedback would be helpful. Thanks!

— Reply to this email directly, view it on GitHub https://github.com/matthiasspeidel/hmi/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE24EAB72OKNK7BSLATHUI3U2V2HLANCNFSM5OFKPVKA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>