Last updated: 2022-06-06

Checks: 7 0

Knit directory: gsmash/

This reproducible R Markdown analysis was created with workflowr (version 1.7.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(20220606) 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 results in this page were generated with repository version 8b15558. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

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

Untracked files:
    Untracked:  analysis/log_gmm_concave_ratio.Rmd
    Untracked:  analysis/log_lmm_concave.Rmd
    Untracked:  analysis/normal_mean_penalized_optimization.Rmd
    Untracked:  analysis/normal_mean_penalty.Rmd
    Untracked:  analysis/poisson_mean_loglik_expansion.Rmd
    Untracked:  analysis/poisson_mean_loglik_expansion_optim.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 repository in which changes were made to the R Markdown (analysis/bound_log_marginal.Rmd) and HTML (docs/bound_log_marginal.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 8b15558 Dongyue Xie 2022-06-06 Publish the initial files for myproject

Introduction

Consider the model \[\mu|b\sim N(b,\sigma^2), b\sim g(\cdot).\]

The marginal density of \(\mu\) is \(f(\mu) = \int p(\mu|b)dG(b)\). We have shown that \(-\frac{1}{\sigma^2}\) is a lower bound of \((\log f(\mu))''\).

When \(g(\cdot)\) is a normal with variance \(\tau^2\), then \((\log f(\mu))'' = -1/(\sigma^2+\tau^2)\). And apparently, \(-1/(\sigma^2+\tau^2) > -1/\sigma^2\).

When \(g(\cdot)\) is a mixture of zero mean Gaussians, it’s harder to find a tighter lower bound of \((\log f(\mu))''\) because the log sum terms.

Here we try to do some simple plots and explore what’s a possible lower bound of \((\log f(\mu))''\).

We let \(b\sim \pi_0N(0,\sigma_0^2) + \pi_1 N(0,\sigma_1^2)\), then \(f(\mu) = \pi_0N(\mu;0,\sigma^2+\sigma^2_0)+\pi_1N(\mu;0,\sigma^2+\sigma^2_1)\).

We use the R function D() to evaluate the derivatives symbolically.

f = expression(log(w1/sqrt((s1_2+s2)*2*pi)*exp(-x^2/2/(s1_2+s2))+w2/sqrt((s2_2+s2)*2*pi)*exp(-x^2/2/(s2_2+s2))))
g = D(f,'x')
g2 = D(g,'x')

simu_func = function(x = seq(-5,5,length.out = 100),
                     s2 = 1,
                     w1 = 1,
                     s1_2 = 0.1,
                     s2_2 = 2){
  w2 = 1-w1
  y = eval(g2)
  plot(x,y,type='l',ylim=c(-1/s2,range(y)[2]),ylab="(log f(mu))''",xlab='mu')
  abline(h = -1/s2,lty=2)
}

We first verify if the calculations are correct by using only one component.

x = seq(-5,5,length.out = 100)
s2 = 1
s1_2 = 0
s2_2=0
w1=1
w2 = 0
eval(g2)
  [1] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
 [26] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
 [51] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
 [76] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

Now try different parameter values. The dashed line is \(-1/\sigma^2\).

simu_func(w1 = 0.5, s2 = 1, s1_2 = 0.1, s2_2 = 3)

simu_func(w1 = 0.1, s2 = 1, s1_2 = 0.1, s2_2 = 3)

simu_func(w1 = 0.9, s2 = 1, s1_2 = 0.1, s2_2 = 3)

Is \(-\sum_k w_k\frac{1}{\sigma^2+\sigma^2_k}\) a lower bound?

simu_func2 = function(x = seq(-5,5,length.out = 100),
                     s2 = 1,
                     w1 = 1,
                     s1_2 = 0.1,
                     s2_2 = 2){
  w2 = 1-w1
  y = eval(g2)
  plot(x,y,type='l',ylim=c(-1/s2,range(y)[2]),ylab="(log f(mu))''",xlab='mu')
  abline(h = -(w1/(s2+s1_2)+w2/(s2+s2_2)),lty=2)
}
simu_func2(w1 = 0.5, s2 = 1, s1_2 = 0.1, s2_2 = 3)

simu_func2(w1 = 0.1, s2 = 1, s1_2 = 0.1, s2_2 = 3)

simu_func2(w1 = 0.9, s2 = 1, s1_2 = 0.1, s2_2 = 3)

It seems not but one observation is that the function achieves the minimum at \(\mu=0\). This can be assured by evaluate \((\log f(\mu))'''\) at \(\mu=0\) and it is 0. We can plug \(\mu = 0\) to \((\log f(\mu))''\).

I’ll derive the formulas using a mixture of \(K\) components for simplicity.

\[(\log f(\mu))'' = \frac{\sum_k\frac{w_k}{\sqrt{2\pi(\sigma^2_k+\sigma^2)}}e^{-\frac{\mu^2}{2(\sigma^2_k+\sigma^2)}}\left((\frac{\mu}{\sigma^2+\sigma^2_k})^2-\frac{1}{\sigma^2+\sigma^2_k}\right)}{\sum_k\frac{w_k}{\sqrt{2\pi(\sigma^2_k+\sigma^2)}}e^{-\frac{\mu^2}{2(\sigma^2_k+\sigma^2)}}} \\ -\left(\frac{\sum_k\frac{w_k}{\sqrt{2\pi(\sigma^2_k+\sigma^2)}}e^{-\frac{\mu^2}{2(\sigma^2_k+\sigma^2)}}\frac{\mu}{\sigma^2_k+\sigma^2}}{\sum_k\frac{w_k}{\sqrt{2\pi(\sigma^2_k+\sigma^2)}}e^{-\frac{\mu^2}{2(\sigma^2_k+\sigma^2)}}}\right)^2\]

At \(\mu = 0\), we have

\[\log f(\mu))''|_{\mu=0} = -\frac{\sum_k\frac{w_k}{\sqrt{2\pi(\sigma^2_k+\sigma^2)}}\frac{1}{\sigma^2_k+\sigma^2}}{\sum_k\frac{w_k}{\sqrt{2\pi(\sigma^2_k+\sigma^2)}}}\]

simu_func3 = function(x = seq(-5,5,length.out = 100),
                     s2 = 1,
                     w1 = 1,
                     s1_2 = 0.1,
                     s2_2 = 2){
  w2 = 1-w1
  y = eval(g2)
  plot(x,y,type='l',ylim=c(-1/s2,range(y)[2]),ylab="(log f(mu))''",xlab='mu')
  n1 = w1/sqrt(2*pi*(s1_2+s2))/(s1_2+s2) + w2/sqrt(2*pi*(s2_2+s2))/(s2_2+s2) 
  d1 = w1/sqrt(2*pi*(s1_2+s2)) + w2/sqrt(2*pi*(s2_2+s2))
  abline(h = -n1/d1,lty=2)
}
simu_func3(w1 = 0.5, s2 = 1, s1_2 = 0.1, s2_2 = 3)

simu_func3(w1 = 0.1, s2 = 1, s1_2 = 0.1, s2_2 = 3)

simu_func3(w1 = 0.9, s2 = 1, s1_2 = 0.1, s2_2 = 3)


sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur/Monterey 10.16

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/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] workflowr_1.7.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8.3     highr_0.9        bslib_0.3.1      compiler_4.2.0  
 [5] pillar_1.7.0     later_1.3.0      git2r_0.30.1     jquerylib_0.1.4 
 [9] tools_4.2.0      getPass_0.2-2    digest_0.6.29    jsonlite_1.8.0  
[13] evaluate_0.15    tibble_3.1.6     lifecycle_1.0.1  pkgconfig_2.0.3 
[17] rlang_1.0.2      cli_3.3.0        rstudioapi_0.13  yaml_2.3.5      
[21] xfun_0.30        fastmap_1.1.0    httr_1.4.2       stringr_1.4.0   
[25] knitr_1.38       sass_0.4.1       fs_1.5.2         vctrs_0.4.1     
[29] rprojroot_2.0.3  glue_1.6.2       R6_2.5.1         processx_3.5.3  
[33] fansi_1.0.3      rmarkdown_2.13   callr_3.7.0      magrittr_2.0.3  
[37] whisker_0.4      ps_1.7.0         promises_1.2.0.1 htmltools_0.5.2 
[41] ellipsis_0.3.2   httpuv_1.6.5     utf8_1.2.2       stringi_1.7.6   
[45] crayon_1.5.1