Last updated: 2018-05-18

workflowr checks: (Click a bullet for more information)
  • R Markdown file: up-to-date

    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.

  • Repository version: 5eb3d95

    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
        Ignored:    analysis/BH_robustness_cache/
        Ignored:    analysis/FDR_Null_cache/
        Ignored:    analysis/FDR_null_betahat_cache/
        Ignored:    analysis/Rmosek_cache/
        Ignored:    analysis/StepDown_cache/
        Ignored:    analysis/alternative2_cache/
        Ignored:    analysis/alternative_cache/
        Ignored:    analysis/ash_gd_cache/
        Ignored:    analysis/average_cor_gtex_2_cache/
        Ignored:    analysis/average_cor_gtex_cache/
        Ignored:    analysis/brca_cache/
        Ignored:    analysis/cash_deconv_cache/
        Ignored:    analysis/cash_fdr_1_cache/
        Ignored:    analysis/cash_fdr_2_cache/
        Ignored:    analysis/cash_fdr_3_cache/
        Ignored:    analysis/cash_fdr_4_cache/
        Ignored:    analysis/cash_fdr_5_cache/
        Ignored:    analysis/cash_fdr_6_cache/
        Ignored:    analysis/cash_plots_2_cache/
        Ignored:    analysis/cash_plots_cache/
        Ignored:    analysis/cash_sim_1_cache/
        Ignored:    analysis/cash_sim_2_cache/
        Ignored:    analysis/cash_sim_3_cache/
        Ignored:    analysis/cash_sim_4_cache/
        Ignored:    analysis/cash_sim_5_cache/
        Ignored:    analysis/cash_sim_6_cache/
        Ignored:    analysis/cash_sim_7_cache/
        Ignored:    analysis/correlated_z_2_cache/
        Ignored:    analysis/correlated_z_3_cache/
        Ignored:    analysis/correlated_z_cache/
        Ignored:    analysis/create_null_cache/
        Ignored:    analysis/cutoff_null_cache/
        Ignored:    analysis/design_matrix_2_cache/
        Ignored:    analysis/design_matrix_cache/
        Ignored:    analysis/diagnostic_ash_cache/
        Ignored:    analysis/diagnostic_correlated_z_2_cache/
        Ignored:    analysis/diagnostic_correlated_z_3_cache/
        Ignored:    analysis/diagnostic_correlated_z_cache/
        Ignored:    analysis/diagnostic_plot_2_cache/
        Ignored:    analysis/diagnostic_plot_cache/
        Ignored:    analysis/efron_leukemia_cache/
        Ignored:    analysis/fitting_normal_cache/
        Ignored:    analysis/gaussian_derivatives_2_cache/
        Ignored:    analysis/gaussian_derivatives_3_cache/
        Ignored:    analysis/gaussian_derivatives_4_cache/
        Ignored:    analysis/gaussian_derivatives_5_cache/
        Ignored:    analysis/gaussian_derivatives_cache/
        Ignored:    analysis/gd-ash_cache/
        Ignored:    analysis/gd_delta_cache/
        Ignored:    analysis/gd_lik_2_cache/
        Ignored:    analysis/gd_lik_cache/
        Ignored:    analysis/gd_w_cache/
        Ignored:    analysis/knockoff_10_cache/
        Ignored:    analysis/knockoff_2_cache/
        Ignored:    analysis/knockoff_3_cache/
        Ignored:    analysis/knockoff_4_cache/
        Ignored:    analysis/knockoff_5_cache/
        Ignored:    analysis/knockoff_6_cache/
        Ignored:    analysis/knockoff_7_cache/
        Ignored:    analysis/knockoff_8_cache/
        Ignored:    analysis/knockoff_9_cache/
        Ignored:    analysis/knockoff_cache/
        Ignored:    analysis/knockoff_var_cache/
        Ignored:    analysis/marginal_z_alternative_cache/
        Ignored:    analysis/marginal_z_cache/
        Ignored:    analysis/mosek_reg_2_cache/
        Ignored:    analysis/mosek_reg_4_cache/
        Ignored:    analysis/mosek_reg_5_cache/
        Ignored:    analysis/mosek_reg_6_cache/
        Ignored:    analysis/mosek_reg_cache/
        Ignored:    analysis/pihat0_null_cache/
        Ignored:    analysis/plot_diagnostic_cache/
        Ignored:    analysis/poster_obayes17_cache/
        Ignored:    analysis/real_data_simulation_2_cache/
        Ignored:    analysis/real_data_simulation_3_cache/
        Ignored:    analysis/real_data_simulation_4_cache/
        Ignored:    analysis/real_data_simulation_5_cache/
        Ignored:    analysis/real_data_simulation_cache/
        Ignored:    analysis/rmosek_primal_dual_2_cache/
        Ignored:    analysis/rmosek_primal_dual_cache/
        Ignored:    analysis/seqgendiff_cache/
        Ignored:    analysis/simulated_correlated_null_2_cache/
        Ignored:    analysis/simulated_correlated_null_3_cache/
        Ignored:    analysis/simulated_correlated_null_cache/
        Ignored:    analysis/simulation_real_se_2_cache/
        Ignored:    analysis/simulation_real_se_cache/
        Ignored:    analysis/smemo_2_cache/
        Ignored:    data/LSI/
        Ignored:    docs/.DS_Store
        Ignored:    docs/figure/.DS_Store
        Ignored:    output/fig/
    
    
    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.
Expand here to see past versions:
    File Version Author Date Message
    Rmd 5eb3d95 LSun 2018-05-18 wflow_publish(c(“analysis/gd_lik_2.rmd”,
    Rmd bd9644e Lei Sun 2018-05-18 lfsr
    html d51ff50 LSun 2018-05-18 Build site.
    Rmd 7c1e2f8 LSun 2018-05-18 wflow_publish(c(“analysis/cash_plots_2.rmd”,

Introduction

The analytic form of lfsr in CASH has been derived and implemented.

lfsr

Following the steps laid out in the posterior calculations, the lfsr in CASH should be defined as \[ \begin{array}{rcl} \text{Pr}\left(\theta_j \ge 0 \mid X_j, s_j, \hat g, \hat f\right) &=& \displaystyle \int_{0^+}^\infty p\left(\theta_j \ge 0 \mid X_j, s_j, \hat g, \hat f\right) \mathrm{d}\theta_j \\ &=&\frac{1}{\sum_k\sum_l\pi_k\omega_l p_{jkl}} \sum_k\sum_l\pi_k\omega_l \displaystyle \int_0^\infty N\left(\theta_j \mid \mu_k, \sigma_k^2\right) \frac{1}{s_j}\frac{1}{\sqrt{l!}} \varphi^{(l)}\left(\frac{X_j - \theta_j}{s_j}\right) \mathrm{d}\theta_j \end{array} \]

The key is to get the analytic form for \[ \tau_{jkl} =: \int_{0^+}^\infty N\left(\theta_j \mid \mu_k, \sigma_k^2\right) \frac{1}{s_j}\frac{1}{\sqrt{l!}} \varphi^{(l)}\left(\frac{X_j - \theta_j}{s_j}\right) \mathrm{d}\theta_j \ . \]

First, recognize that \[ \begin{array}{rrcl} &\varphi\left(x\right) &=& s_j N\left(s_jx \mid 0, s_j^2\right) \\\Rightarrow& \varphi^{(l)}\left(x\right) &=& s_j^{l + 1} N^{(l)}\left(s_jx \mid 0, s_j^2\right) \\\Rightarrow& \varphi^{(l)}\left(\frac{X_j - \theta_j}{s_j}\right) &=& s_j^{l + 1} N^{(l)}\left(X_j - \theta_j \mid 0, s_j^2\right) \ . \end{array} \]

Then \[ \begin{array}{rcl} \tau_{jkl} &=& \displaystyle \frac{s_j^l}{\sqrt{l!}} \int_{0^+}^\infty N\left(\theta_j \mid \mu_k, \sigma_k^2\right) N^{(l)}\left(X_j - \theta_j \mid 0, s_j^2\right) \mathrm{d}\theta_j \\ &=& \displaystyle \frac{s_j^l \Phi\left(\frac{\mu_k}{\sigma_k}\right) } {\sqrt{l!}} \int_{-\infty}^\infty TN\left(\theta_j \mid \mu_k, \sigma_k^2, 0, \infty\right) N^{(l)}\left(X_j - \theta_j \mid 0, s_j^2\right) \mathrm{d}\theta_j \ , \end{array} \] where \(TN\left(\cdot \mid \mu, \sigma^2, a, b\right)\) is the pdf of the truncated normal distribution. The key part in \(s\left(X_j\right)\) is \[ \displaystyle \int_{-\infty}^\infty TN\left(\theta_j \mid \mu_k, \sigma_k^2, 0, \infty\right) N^{(l)}\left(X_j - \theta_j \mid 0, s_j^2\right) \mathrm{d}\theta_j \] which is the convolution of \(TN\left(\cdot \mid \mu_k, \sigma_k^2, 0, \infty\right)\) and \(N^{(l)}\left(\cdot \mid 0, s_j^2\right)\). According to the property of convolution, \[ \begin{array}{rl} &\displaystyle\int_{-\infty}^\infty TN\left(\theta_j \mid \mu_k, \sigma_k^2, 0, \infty\right) N^{(l)}\left(X_j - \theta_j \mid 0, s_j^2\right) \mathrm{d}\theta_j \\ =& TN\left(\cdot \mid \mu_k, \sigma_k^2, 0, \infty\right) \circledast N^{(l)}\left(\cdot \mid 0, s_j^2\right)\left(X_j\right) \\=& \left(TN\left(\cdot \mid \mu_k, \sigma_k^2, 0, \infty\right) \circledast N\left(\cdot \mid 0, s_j^2\right)\right)^{(l)}\left(X_j\right) \end{array} \] Algebra shows that the convolution of a truncated normal and a zero-mean normal is \[ \begin{array}{rl} &TN\left(\cdot \mid \mu_k, \sigma_k^2, 0, \infty\right) \circledast N\left(\cdot \mid 0, s_j^2\right)\left(X_j\right) \\ =& \frac{1}{\sqrt{s_j^2 + \sigma_k^2}\Phi\left(\frac{\mu_k}{\sigma_k}\right)} \frac{1}{\sqrt{2\pi}}e^{-\frac{\left(X_j - \mu_k\right)^2}{2\left(s_j^2 + \sigma_k^2\right)}} \Phi\left(\frac{\sigma_k^2X_j + s_j^2\mu_k}{s_j\sigma_k\sqrt{s_j^2 + \sigma_k^2}}\right) \\ =& \frac{1}{\sqrt{s_j^2 + \sigma_k^2}\Phi\left(\frac{\mu_k}{\sigma_k}\right)} \varphi\left(\frac{X_j - \mu_k}{\sqrt{s_j^2 + \sigma_k^2}}\right) \Phi\left(\frac{\sigma_k^2X_j + s_j^2\mu_k}{s_j\sigma_k\sqrt{s_j^2 + \sigma_k^2}}\right) \end{array} \]

Therefore, \[ \begin{array}{rcl} \tau_{jkl} &=& \frac{s_j^l \Phi\left(\frac{\mu_k}{\sigma_k}\right) } {\sqrt{l!}} \left( \frac{1}{\sqrt{s_j^2 + \sigma_k^2}\Phi\left(\frac{\mu_k}{\sigma_k}\right)} \varphi\left(\frac{X_j - \mu_k}{\sqrt{s_j^2 + \sigma_k^2}}\right) \Phi\left(\frac{\sigma_k^2X_j + s_j^2\mu_k}{s_j\sigma_k\sqrt{s_j^2 + \sigma_k^2}}\right) \right)^{(l)}\\ &=& \frac{s_j^l } {\sqrt{l!}\sqrt{s_j^2 + \sigma_k^2}} \left( \varphi\left(\frac{X_j - \mu_k}{\sqrt{s_j^2 + \sigma_k^2}}\right) \Phi\left(\frac{\sigma_k^2X_j + s_j^2\mu_k}{s_j\sigma_k\sqrt{s_j^2 + \sigma_k^2}}\right) \right)^{(l)} \\ &=& \frac{s_j^l } {\sqrt{l!}\sqrt{s_j^2 + \sigma_k^2}^{l + 1}} \left( \sum\limits_{m = 0}^{l} \binom{l}{m} \left(\frac{\sigma_k}{s_j}\right)^m \varphi^{(m - 1)} \left(\frac{\sigma_k^2X_j + s_j^2\mu_k}{s_j\sigma_k\sqrt{s_j^2 + \sigma_k^2}}\right) \varphi^{(l - m)} \left(\frac{X_j - \mu_k}{\sqrt{s_j^2 + \sigma_k^2}}\right) \right) \end{array} \]

Note that this expression also works in the special cases such as \(l = 0\) when we don’t take derivatives and \(\sigma_k = 0\) when \(N\left(\mu_k, \sigma_k^2\right)\) is a point mass at \(\mu_k\).

In the latter case, when \(\sigma_k = 0\),

  • If \(\mu_k < 0\), \(\frac{\sigma_k^2X_j + s_j^2\mu_k}{s_j\sigma_k\sqrt{s_j^2 + \sigma_k^2}} \to -\infty\), \(\Phi\left(\frac{\sigma_k^2X_j + s_j^2\mu_k}{s_j\sigma_k\sqrt{s_j^2 + \sigma_k^2}}\right) = 0\), \(\tau_{jkl} = 0\).

  • If \(\mu_k > 0\), \(\frac{\sigma_k^2X_j + s_j^2\mu_k}{s_j\sigma_k\sqrt{s_j^2 + \sigma_k^2}} \to \infty\), \(\Phi\left(\frac{\sigma_k^2X_j + s_j^2\mu_k}{s_j\sigma_k\sqrt{s_j^2 + \sigma_k^2}}\right) = 1\), \(\tau_{jkl} = \frac{1}{s_j}\frac{1}{\sqrt{l!}}\varphi\left(\frac{X_j - \mu_k}{s_j}\right)\).

  • If \(\mu_k = 0\), since the integral is taken from \(0^+\) to \(\infty\), \(\mu_k\) is on the left of the starting point of the integral and essentially \(0^{-}\), so \(\Phi\left(\frac{\sigma_k^2X_j + s_j^2\mu_k}{s_j\sigma_k\sqrt{s_j^2 + \sigma_k^2}}\right) \to 0\) and \(\tau_{jkl} = 0\).

Numerically, the above expresion is not stable, as \(\frac{\sigma_k}{s_j}\) could be large and \(\left(\frac{\sigma_k}{s_j}\right)^m\) could easily blow up. Thus we come up with the following normalized expression to stablize the implementation. \[ \tau_{jkl} = \frac{1}{\sqrt{s_j^2 + \sigma_k^2}} \sum\limits_{m = 0}^l \sqrt{\binom{l}{m}} \left(\frac{\sigma_k}{\sqrt{s_j^2 + \sigma_k^2}}\right)^m \frac{1}{\sqrt{m!}} \varphi^{(m - 1)} \left(\frac{\sigma_k^2X_j + s_j^2\mu_k}{s_j\sigma_k\sqrt{s_j^2 + \sigma_k^2}}\right) \left(\frac{s_j}{\sqrt{s_j^2 + \sigma_k^2}}\right)^{l - m} \frac{1}{\sqrt{(l - m)!}} \varphi^{(l - m)} \left(\frac{X_j - \mu_k}{\sqrt{s_j^2 + \sigma_k^2}}\right). \] When \(\mu_k \equiv 0\), \[ \tau_{jkl} = \frac{1}{\sqrt{s_j^2 + \sigma_k^2}} \sum\limits_{m = 0}^l \sqrt{\binom{l}{m}} \left(\frac{\sigma_k}{\sqrt{s_j^2 + \sigma_k^2}}\right)^m \frac{1}{\sqrt{m!}} \varphi^{(m - 1)} \left(\frac{X_j}{\sqrt{s_j^2 + \sigma_k^2}}\frac{\sigma_k}{s_j}\right) \left(\frac{s_j}{\sqrt{s_j^2 + \sigma_k^2}}\right)^{l - m} \frac{1}{\sqrt{(l - m)!}} \varphi^{(l - m)} \left(\frac{X_j}{\sqrt{s_j^2 + \sigma_k^2}}\right). \] This is the version implemented in CASH, with the special case \(\sigma_0 = 0\) taken care of numerically.


This reproducible R Markdown analysis was created with workflowr 1.0.1