Comments (5)
Yeah, this is a mysterious issue. The map2stan argument is rng_seed
. It's passed to stan as seed
but seems not to have an effect. No idea why, since passing a value in a raw stan call works. But I can't yet figure out a way that my code is the issue. You can even check the internal stanfit
object and see that stan is saving the passed seed. It just doesn't appear to use it?
Maybe something will occur to me. In the meantime, just use set.seed
before the map2stan call.
from rethinking.
It might be the init
parameter in lines 1356 and 1358 of map2stan.R. The comment in this SO question suggests that seed
only covers the RNG from the Boost library, and that init
draws separately.
set.seed()
coupled with set_rng
does appear to work:
library(rethinking)
data("Howell1")
d <- Howell1
d2 <- d[ d$age >= 18 , ]
set.seed(5)
m1 <- map2stan(
alist(
height ~ dnorm(mu, sigma),
mu ~ dnorm(178, 20),
sigma ~ dunif(0, 50)),
data = d2,
WAIC = FALSE,
rng_seed = 8
)
set.seed(5)
m2 <- map2stan(
alist(
height ~ dnorm(mu, sigma),
mu ~ dnorm(178, 20),
sigma ~ dunif(0, 50)),
data = d2,
WAIC = FALSE,
rng_seed = 8
)
m1
m2
all.equal(m1, m2)
The only differences are in the date, time, dso, and model_cpp.
from rethinking.
On Tuesday, August 30, 2016, Kevin Middleton [email protected]
wrote:
The comment in this SO question
http://stackoverflow.com/questions/27204096/supplying-seed-to-stan-doesnt-guarantee-the-same-chains
suggests that seed only covers the RNG from the Boost library, and that
init draws separately.Yes, that's correct. If any initial value generation is being done in R
(whether by you or by passing a function toinit
) then you'll have to set
both the R seed and the seed for the Boost library.
from rethinking.
Thanks. Sounds like an easy fix, with this information. Will try to roll it into the next push.
from rethinking.
This is fixed in experimental branch.
from rethinking.
Related Issues (20)
- How to construct a spline model using ulam() HOT 4
- cannot install rethinking HOT 1
- Error in link(), R code 4.67 HOT 1
- Poisson response imputation compilation error
- Random Effect in Zero-Inflated Model
- Rethink package is NOT getting installed HOT 8
- Sampling issue for the Cat Adoptions Survival model.
- Random walk in ulam HOT 2
- problem in precis command
- Can multiple outcomes be regressed on the same linear model?
- ulam fits missing @stanfit slot? HOT 2
- WAIC not computing from ulam() model, even with log_lik = TRUE HOT 4
- Problem installing cmdstanr HOT 1
- ulam fits giving odd errors HOT 4
- errata 2nd Edition page 130
- log_lik fails with matrices in models fit by ulam HOT 6
- Where is sim_globe, and the rest of the code shown in the videos? HOT 2
- Panda_nuts Nut-Cracking Frequency? HOT 6
- The garden of forking data - 2 blue from 1? HOT 3
- quap allows incorrect(?) definition with categorical variable HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rethinking.