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

Could not run example model in JOSS paper #299

Closed
lionel68 opened this issue Aug 2, 2019 · 3 comments
Closed

Could not run example model in JOSS paper #299

lionel68 opened this issue Aug 2, 2019 · 3 comments

Comments

@lionel68
Copy link

lionel68 commented Aug 2, 2019

I tried to run the example model in the JOSS paper in my R session but got the following error:

Error in dim(free_state_draws) <- c(1, dim(free_state_draws)) : 
  invalid first argument

Here is my sessionInfo():

R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=de_BE.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=de_BE.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=de_BE.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=de_BE.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] greta_0.3.0   MASS_7.3-51.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1        rstudioapi_0.10   whisker_0.3-2     magrittr_1.5      hms_0.4.2         progress_1.2.0    lattice_0.20-38   R6_2.4.0          rlang_0.3.4       globals_0.12.4   
[11] tools_3.6.0       parallel_3.6.0    grid_3.6.0        coda_0.19-2       tfruns_1.4        digest_0.6.18     assertthat_0.2.0  crayon_1.3.4      tensorflow_1.14.0 Matrix_1.2-17    
[21] base64enc_0.1-3   codetools_0.2-16  compiler_3.6.0    prettyunits_1.0.2 reticulate_1.13   jsonlite_1.6      future_1.13.0     listenv_0.7.0     pkgconfig_2.0.2  

And the code I used:

library(MASS)
library(greta)

epil$trt_id <- as.numeric(epil$trt)
baseline_y <- epil$base[!duplicated(epil$subject)]
subject_mean <- normal(0, 10)
subject_sd <- cauchy(0, 1, truncation = c(0, Inf))
subject_effects <- normal(subject_mean, subject_sd, dim = 59)
subject_sd <- cauchy(0, 1, truncation = c(0, Inf))
subject_effects <- normal(subject_mean, subject_sd, dim = 59)
baseline_rates <- exp(subject_effects)
treatment_effects <- normal(1, 1, dim = 2, truncation = c(0, Inf))
post_treatment_rates <- treatment_effects[epil$trt_id] * baseline_rates[epil$subject]
distribution(baseline_y) <- poisson(baseline_rates * 8)
distribution(epil$y) <- poisson(post_treatment_rates * 2)
m <- model(treatment_effects, subject_sd)
draws <- mcmc(m, chains = 3)
@chameroy
Copy link

chameroy commented Aug 5, 2019

I'm receiving the same error just by trying the example model under the "get started" section.

I'm running R version 3.6.1 on Windows 10

@goldingn
Copy link
Member

goldingn commented Aug 6, 2019

Thanks @lionel68.

I think this is due to you using a recent version of TF/TFP, but the CRAN (rather than dev) version of greta (0.3.0). If you install the most recent version of greta (0.3.0.9008), from GitHub I think it should work:

remotes::install_github("greta-dev/greta")

Up until now, I've been specifying minimum versions of TF and TFP as dependencies (ie. TF >= 1.10; TFP >=0.3.0). I think that's generally considered better practice than depending on specific versions. But the APIs for both of these packages (but particularly TFP) change so frequently, that errors keep occurring, making it impossible to maintain. So the development (GitHub) version of greta now depends on specific releases (TF = 1.14, TFP = 0.7.0), which is what I'm planning to do in the future.

I can see why you went for the CRAN version, and the JOSS review is for greta 0.3.0, but I'm not clear on how that works with dev versions. I'll ask the editor's opinion over on that channel.

@lionel68
Copy link
Author

lionel68 commented Aug 7, 2019

Yes, that did the job I can now smoothly run greta, thanks!

@lionel68 lionel68 closed this as completed Aug 7, 2019
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

3 participants