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

Unable to set seed=NULL in simulate residuals #254

Closed
jmniehaus opened this issue Feb 24, 2021 · 3 comments
Closed

Unable to set seed=NULL in simulate residuals #254

jmniehaus opened this issue Feb 24, 2021 · 3 comments

Comments

@jmniehaus
Copy link

Hello,

I am attempting to write my own simulate function for a package I am implementing that will rely on dharma. I am trying to use dharma's getRandomState function at the beginning of my simulate function, similarly to dharma's simulateResiduals function. However, when I use seed=NULL, I get an error due to a logical problem in getRandomState, I think.

Reprex:

y = rnorm(100)
x = rnorm(100)
mod = lm(y~x) 
simulateResiduals(mod, seed=NULL)

> Error in if (is.logical(seed) & seed == F) { : argument is of length zero

Because seed=NULL, NULL==F returns a zero-length vector.

@florianhartig
Copy link
Owner

OK, but why is that a problem? What would be your desired behaviour for seed = NULL?

@florianhartig
Copy link
Owner

OK, sorry, I see that the help specifies that this should work. I will have to dig into that!

@florianhartig
Copy link
Owner

This was indeed a bug, thanks for reporting this. I am just running the tests and will push this to master in a second (for how to install, see start page).

About your simulate function - is this a regression package, or a package that requires simulations? If the former, note https://github.com/florianhartig/DHARMa/wiki/Adding-new-R-packages-to-DHARMA, if the latter, note that DHARMa as internal S3 wrappers for the supported package in file compatibility.R, see ?DHARMa::getSimulations

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