Last updated: 2019-10-23

Checks: 7 0

Knit directory: ebpmf_demo/

This reproducible R Markdown analysis was created with workflowr (version 1.4.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20190923) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/

Untracked files:
    Untracked:  analysis/.ipynb_checkpoints/
    Untracked:  analysis/ebpmf_demo.Rmd
    Untracked:  analysis/ebpmf_rank1_demo2.Rmd
    Untracked:  analysis/softmax_experiments.ipynb
    Untracked:  data/poisson-normal.pkl
    Untracked:  data/trash/
    Untracked:  docs/figure/Experiment_ebpmf_rankk.Rmd/
    Untracked:  docs/figure/test.Rmd/
    Untracked:  verbose_log_1571583163.21966.txt
    Untracked:  verbose_log_1571583324.71036.txt
    Untracked:  verbose_log_1571583741.94199.txt
    Untracked:  verbose_log_1571588102.40356.txt

Unstaged changes:
    Modified:   analysis/ebpmf_rank1_demo.Rmd
    Modified:   analysis/ebpmf_rankk_demo.Rmd
    Modified:   analysis/ebvae-poisson-normal.ipynb
    Modified:   analysis/softmax_experiments.Rmd

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the R Markdown and HTML files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view them.

File Version Author Date Message
Rmd 7fbc1f9 zihao12 2019-10-23 update Compare_ebvaepm_ebpm.Rmd
html 66940d1 zihao12 2019-10-23 Build site.
html 234f9af zihao12 2019-10-23 Build site.
Rmd b33470b zihao12 2019-10-23 update compare vae with ebpm
html 4be9b78 zihao12 2019-10-23 Build site.
Rmd cef9f2e zihao12 2019-10-23 update compare vae with ebpm
html 6954317 zihao12 2019-10-23 Build site.
Rmd 7f57658 zihao12 2019-10-23 compare vae with ebpm

Here I show and compare the results from ebvae_pm and ebpmf. ebvae_pm was implemented and experimented here: https://zihao12.github.io/ebpmf_demo/ebvae-poisson-normal.html .

Now ebvae_pm does much worse even than the mle. It seems to be shrinking too much.

devtools::load_all("../ebpm")
Loading ebpm
library(ggplot2)
library(reticulate)

show VAE results

vae_out = py_load_object("data/poisson-normal.pkl", pickle = "pickle")
vae_out = data.frame(vae_out)

## This is what data looks like
ggplot(vae_out)+
  geom_histogram(aes(x = x), bins = 100)

Version Author Date
4be9b78 zihao12 2019-10-23
6954317 zihao12 2019-10-23
ggplot(vae_out)+
  geom_point(aes(x = x, y = posterior_vae))

Version Author Date
4be9b78 zihao12 2019-10-23

Compare with EBPM

library(ebpm)
fit_ebpm = ebpm_exponential_mixture(as.vector(vae_out$x), s = 1, m = 2^0.25)
vae_out[["posterior_ebpm"]] = fit_ebpm$posterior$mean
ggplot(vae_out)+
  geom_point(aes(x = x, y = posterior_ebpm))

Version Author Date
4be9b78 zihao12 2019-10-23
6954317 zihao12 2019-10-23
## biggest weight
max(fit_ebpm$fitted_g$pi)
[1] 1
## the mean  of the exponential component corresponding to the biggest weight
fit_ebpm$fitted_g$scale[which.max(fit_ebpm$fitted_g$pi)]
[1] 10.76347

Compare RMSE

## rmse(fit_vae, lam)
sqrt(mean((vae_out$posterior_vae - vae_out$lam)^2))
[1] 5.788469
## rmse(fit_ebpm, lam)
sqrt(mean((fit_ebpm$posterior$mean - vae_out$lam)^2))
[1] 2.962624
## rmse(mle, lam)
sqrt(mean((vae_out$x- vae_out$lam)^2))
[1] 3.197445

sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.14

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] reticulate_1.12 ggplot2_3.2.1   ebpm_0.0.0.9001 testthat_2.2.1 

loaded via a namespace (and not attached):
 [1] gtools_3.8.1        tidyselect_0.2.5    xfun_0.8           
 [4] remotes_2.1.0       purrr_0.3.2         lattice_0.20-38    
 [7] colorspace_1.4-1    usethis_1.5.1       htmltools_0.3.6    
[10] yaml_2.2.0          rlang_0.4.0         pkgbuild_1.0.3     
[13] mixsqp_0.1-121      pillar_1.4.2        glue_1.3.1         
[16] withr_2.1.2         sessioninfo_1.1.1   stringr_1.4.0      
[19] munsell_0.5.0       gtable_0.3.0        workflowr_1.4.0    
[22] devtools_2.2.1.9000 memoise_1.1.0       evaluate_0.14      
[25] labeling_0.3        knitr_1.25          callr_3.2.0        
[28] ps_1.3.0            Rcpp_1.0.2          backports_1.1.5    
[31] scales_1.0.0        desc_1.2.0          pkgload_1.0.2      
[34] jsonlite_1.6        fs_1.3.1            digest_0.6.22      
[37] stringi_1.4.3       processx_3.3.1      dplyr_0.8.1        
[40] rprojroot_1.3-2     grid_3.5.1          cli_1.1.0          
[43] tools_3.5.1         magrittr_1.5        lazyeval_0.2.2     
[46] tibble_2.1.3        crayon_1.3.4        whisker_0.3-2      
[49] pkgconfig_2.0.3     ellipsis_0.3.0      Matrix_1.2-17      
[52] prettyunits_1.0.2   assertthat_0.2.1    rmarkdown_1.13     
[55] rstudioapi_0.10     R6_2.4.0            git2r_0.25.2       
[58] compiler_3.5.1