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

FIX: resolve issue of element-wise comparison introduced in 4.3.0 #599

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

vkhodygo
Copy link
Contributor

@vkhodygo vkhodygo commented Nov 1, 2023

Running code

library("mice")
expr <- expression((wgt - 40) * (hc - 50))
boys$wgt.hc <- with(boys,  eval(expr))
meth <- make.method(boys)
meth["wgt.hc"] <- paste("~I(",  expr,  ")",  sep = "")
meth["bmi"] <- ""
pred <- make.predictorMatrix(boys)
pred[c("wgt",  "hc"),  "wgt.hc"] <- 0
imp.int <- mice(boys,  m = 1,  meth = meth,  pred = pred,  print = FALSE,  seed = 62587,  maxit = 10)


vis <- c("hgt",  "wgt",  "hc", "wgt.hc",  "gen",  "phb",  "tv",  "reg")
expr <- expression((wgt - 40) * (hc - 50))
boys$wgt.hc <- with(boys,  eval(expr))

imp.int2 <- mice(boys,  m = 1,  maxit = 1,  visitSequence = vis,
                 meth = imp.int$meth,  pred = imp.int$pred,
                 seed = 23390)

from Section 6.5.1 of the book results in the following error:

Error in maxit == 1L && !is.null(user.visitSequence) && user.visitSequence ==  : 
  'length = 8' in coercion to 'logical(1)'

This is caused by changes introduced in R4.3.0. The PR should resolve this.

Copy link
Member

@hanneoberman hanneoberman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@vkhodygo
Copy link
Contributor Author

vkhodygo commented Nov 2, 2023

@hanneoberman If you're happy with the code could you please merge it?

@stefvanbuuren stefvanbuuren merged commit 3abe393 into amices:master Nov 20, 2023
6 checks passed
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

Successfully merging this pull request may close these issues.

3 participants