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

Object created from pool() is empty but producing mean estimate when using summary() #676

Open
evielopoo opened this issue Oct 10, 2024 Discussed in #675 · 4 comments
Open

Comments

@evielopoo
Copy link

Discussed in #675

Originally posted by evielopoo October 10, 2024
This code has been running fine for months:

coxfit1 <- with(imp30_mids, coxph(Surv(recid, fail) ~ vet))
summary(coxfit1)
coxfit1_pool <- pool(coxfit1)

However, starting yesterday it was returning number of observations = total number of failures, not the total number of failures + censored events. Also, my object "coxfit1_pool" is of class mipa and produces an estimate, but when I use the command view(coxfit1_pool), RStudio returns "error: object not found". Any idea what is going on here? It doesn't seem to be an issue with the imputed dataset itself (if I extract m=1 imputed dataset, it returns the correct number of observations and has no missing values).

@evielopoo evielopoo changed the title Object created from pool() is empty but producing a summary() Object created from pool() is empty but producing mean estimate when using summary() Oct 10, 2024
@stefvanbuuren
Copy link
Member

The mice package defines classes mira and mipo, but not mipa.

@stefvanbuuren
Copy link
Member

Also, try View(), not view. The devil is in the details.

@evielopoo
Copy link
Author

Sorry for the typo, the class is indeed mipo. However, whether
I use View() or view() the object returns the same error, attached in a screenshot.
Screen Shot 2024-10-11 at 11 28 05 AM

My model still runs fine, and I can see that the object is not actually empty if I use str(coxfit1_pool).

@stefvanbuuren
Copy link
Member

I am not able to reproduce your problem.

library(mice, warn.conflicts = FALSE)
library(survival)

set.seed(1)
data <- survival::lung
data$age[rbinom(nrow(data), size = 1, prob = 0.2) == 1] <- NA
data$sex[rbinom(nrow(data), size = 1, prob = 0.2) == 1] <- NA
data$ph.ecog[rbinom(nrow(data), size = 1, prob = 0.2) == 1] <- NA

imp <- mice(data, print = FALSE)
fit <- with(imp, coxph(Surv(time, status) ~ age))
summary(pool(fit))
#>   term  estimate  std.error statistic       df   p.value
#> 1  age 0.0200698 0.01067183  1.880633 38.41092 0.0676197

Created on 2024-11-21 with reprex v2.1.1

Can you try this code on your system? And, if that works, adapt it to your data?

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

2 participants