jtextor / dagitty

Graphical analysis of structural causal models / graphical causal models.
GNU General Public License v2.0
282 stars 46 forks source link

set.seed for simulateSEM function #12

Closed felixthoemmes closed 6 years ago

felixthoemmes commented 7 years ago

To increase reproducibility, it would be good to have a set.seed() function for simulateSEM, like

dat1 <- simulateSEM(dag1,b.default = .3,N=500,set.seed=1234)

That way, one could always generate the same (simulated) data, across different runs of R code.

jtextor commented 6 years ago

Not sure I understand this, what is wrong with simply calling "set.seed" before running simulateSEM?

felixthoemmes commented 6 years ago

Not sure I understand either, since it's been a while I posted this, and TBH I don't recall details. But if just putting set.seed works, then that's great and the issue can be closed.

On Oct 31, 2017 7:41 PM, "Johannes Textor" notifications@github.com wrote:

Not sure I understand this, what is wrong with simply calling "set.seed" before running simulateSEM?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jtextor/dagitty/issues/12#issuecomment-340938770, or mute the thread https://github.com/notifications/unsubscribe-auth/AQSMYjsLgOCjGWchyw3QSFCHweq8t2Oqks5sx7AUgaJpZM4MYi4U .

jtextor commented 6 years ago

Yes this works as you can testify by running the following multiple times:

set.seed(123); with(simulateSEM( "dag{x->y}" ),cov(x,y))

Closing this as having a separate argument seems unnecessary.