Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: object "imputations" not found when using smcfcs Surv() #27

Open
hao-jiasi opened this issue Sep 23, 2024 · 6 comments
Open

Error: object "imputations" not found when using smcfcs Surv() #27

hao-jiasi opened this issue Sep 23, 2024 · 6 comments

Comments

@hao-jiasi
Copy link

hao-jiasi commented Sep 23, 2024

Hello!
Recently I ran smcfcs using "coxph" for the substantive model:

imp_init <- smcfcs(MIdf,
                   smtype="coxph", 
                   smformula="Surv(time_mort, event_mort) ~ age_1 + agesq_1  + chol_1 + education", 
                   method=c("", "", "norm", "age_1*age_1", "norm", "mlogit"),
                   predictorMatrix=MIpredMatrix, # an array initiated with mice::make.predictorMatrix, and I further modified it. All variables have assigned predictors.
                   rjlimit=2000,
                   m=2, 
                   numit=20)

Immediately I ran into an error:

Error in eval(temp, environment(formula$terms), parent.frame()) :
object 'imputations' not found


After trying everything (e.g., if the data frame and variables were in the right type, and checked methods and prediction matrix), it still did not work. I could not find similar posts to solve this issue either. Could you please help with the reasons for this error and possible solutions?

Many thanks!!

@jwb133
Copy link
Owner

jwb133 commented Sep 23, 2024

I'm sorry I cannot see what the problem could be with this. Is it possible you can share a sample dataset along with the code that reproduces the problem? Otherwise it is pretty tricky to diagnose.

Alternatively, I would suggest reducing your dataset down to just one or or two of the covariates, and (hopefully) get it running. Then add back in covariates and see at which point it breaks - this may give a clue as to which variable is causing the problem and why.

@hao-jiasi
Copy link
Author

Thank you for your prompt response!!

I have tried excluding covariates, but it reports the same error even with only one covariate age_1. Additionally, 1) the error always comes at the very first variable which needs to be imputed; 2) although I do have repeated measurements to impute (not included in the substantive model already), the total number of variables is not crazy (N= ~100 wide format, while N_patient= ~8000).

Very unfortunately I am not allowed to share the data... But based on my description, are there any possibilities in your mind that I could try myself?

@jwb133
Copy link
Owner

jwb133 commented Sep 23, 2024

Sorry, I really can't think of what is causing it.

Can you reproduce the error with a simulated dataset that has the same characteristics (or indeed reproduce it at all with a simulated dataset)?

Otherwise, you could install the package source code using devtools package, then call the function after using devtools::load_all(). This would enable you to see where in the R source file the error is occurring. But without knowing too much about how the program is coded it could be tough to figure out the problem.

Sorry.

@hao-jiasi
Copy link
Author

I see. I can surely try them out. It might take some time for me to provide a simulated dataset that has the same characteristics. So we might leave this issue open for now and I will get back to you!

Thanks for your help!

@tom-metherell
Copy link
Contributor

I had the same problem but I think I've found a fix – see #28.

@jwb133
Copy link
Owner

jwb133 commented Nov 15, 2024

Tom's proposed fix has now been incorporated. Please try installing the development version:

install.packages("devtools")

devtools::install_github("jwb133/smcfcs")

and see if this resolves the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants