Last updated: 2019-11-10
Checks: 7 0
Knit directory: SMF/
This reproducible R Markdown analysis was created with workflowr (version 1.5.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(20190719)
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: .DS_Store
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: analysis/.DS_Store
Untracked files:
Untracked: analysis/poissonmeanscle.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 | a70a063 | Dongyue Xie | 2019-11-10 | wflow_publish(c(“analysis/poissonmeanscale.Rmd”, “analysis/ebpmscale.Rmd”)) |
html | bb7d2d1 | Dongyue Xie | 2019-11-08 | Build site. |
Rmd | 827d597 | Dongyue Xie | 2019-11-08 | wflow_publish(“analysis/poissonmeanscale.Rmd”) |
In poisson mean model, \(x\sim Poisson(s\lambda)\), when \(s\) is large, the posterior mean is very close to \(x/s\). Here is the example.
This is probably why we can not get sparsity in ebpmf. The scale is typically \(300-500\) in ebpmf.
library(ebmpmf)
set.seed(12345)
pi0=0.8
lamda=c()
n=100
for(i in 1:100){
idx = rbinom(1,1,pi0)
if(idx){
lamda[i] = rgamma(1,0.1,1)
}else{
lamda[i]=rgamma(1,10,2)
}
}
x = rpois(n,lamda)
#x = seq(0,50)
fit = ebpm_exp_mixture(x,scale=c(0.01,100),shape=1,nullweight = 100)
fit$fitted_g
$pi
[1] 0.8719191 0.1280809
$shape
[1] 1 1
$scale
[1] 1e-02 1e+02
attr(,"class")
[1] "gammamix"
plot(x,fit$posterior$mean,xlab = 'MLE',ylab = 'Posterior mean',pch=16)
abline(0,1)
Version | Author | Date |
---|---|---|
bb7d2d1 | Dongyue Xie | 2019-11-08 |
plot(x,col='grey80',pch=16)
lines(fit$posterior$mean,type='p',pch=3,col=2)
legend('topleft',c('MLE','Posterior mean'),col=c(1,2),pch=c(16,3))
Version | Author | Date |
---|---|---|
bb7d2d1 | Dongyue Xie | 2019-11-08 |
s=100
x = rpois(n,s*lamda)
fit = ebpm_exp_mixture(x,s,scale=c(0.0001,10000),shape=1,nullweight = 1000)
fit$fitted_g
$pi
[1] 0.95692011 0.04307989
$shape
[1] 1 1
$scale
[1] 1e-04 1e+04
attr(,"class")
[1] "gammamix"
par(mfrow=c(1,2))
plot(x/s,fit$posterior$mean,xlab = 'MLE',ylab = 'Posterior mean',pch=16)
abline(0,1)
plot(x/s,col='grey80',pch=16)
lines(fit$posterior$mean,type='p',pch=3,col=2)
legend('topleft',c('MLE','Posterior mean'),col=c(1,2),pch=c(16,3))
Version | Author | Date |
---|---|---|
bb7d2d1 | Dongyue Xie | 2019-11-08 |
If we treat \(x/s\) as observation, then
fit = ebpm_exp_mixture(x/s,scale=c(0.01,100),shape=1)
par(mfrow=c(1,2))
plot(x/s,fit$posterior$mean,xlab = 'MLE',ylab = 'Posterior mean',pch=16)
abline(0,1)
plot(x/s,col='grey80',pch=16)
lines(fit$posterior$mean,type='p',pch=3,col=2)
legend('topright',c('MLE','Posterior mean'),col=c(1,2),pch=c(16,3))
Version | Author | Date |
---|---|---|
bb7d2d1 | Dongyue Xie | 2019-11-08 |
sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/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] ebmpmf_0.1.0
loaded via a namespace (and not attached):
[1] workflowr_1.5.0 Rcpp_1.0.2 rprojroot_1.3-2 digest_0.6.21
[5] later_1.0.0 R6_2.4.0 backports_1.1.5 git2r_0.26.1
[9] magrittr_1.5 evaluate_0.14 stringi_1.4.3 rlang_0.4.0
[13] fs_1.3.1 promises_1.1.0 whisker_0.4 rmarkdown_1.16
[17] tools_3.6.1 stringr_1.4.0 glue_1.3.1 mixsqp_0.1-97
[21] httpuv_1.5.2 xfun_0.10 yaml_2.2.0 compiler_3.6.1
[25] htmltools_0.4.0 knitr_1.25