<jupyter_start><jupyter_text>Multivariate regression simple prior with estimated scalarHere I use multivariate prior (not mash mixture) for `msusie` call, but allow for the scalar of prior to be estimated. That is, I have implemeted `estimate_prior_variance` for [this class](https://github.com/gaow/mmbr/blob/1c9b14283aa9615436447738932618c81388bd41/R/bayesian_multivariate_regression.RL7).<jupyter_code>library(mmbr)
set.seed(2)
dat = mmbr_sim1(r=5,s=1)
dim(dat$X)
dim(dat$y)
true_pos = as.integer(apply(dat$b, 1, sum) != 0)
sum(true_pos)<jupyter_output><empty_output><jupyter_text>As you can see in this simulated data-set there are 5 true effects. Now I set $L=10$. Here the prior used is not oracle prior but just 0.2 times covariance of $Y$.<jupyter_code>L=10<jupyter_output><empty_output><jupyter_text>Not estimating prior variance scalar<jupyter_code>start = Sys.time()
res = mmbr::msusie(dat$X,dat$y,L=L,prior_variance=dat$V,compute_objective=T,estimate_residual_variance=F,estimate_prior_variance=F)
Sys.time() - start
res$elbo
susieR::susie_plot(res,y='PIP', main = 'Default SuSiE plot for cross-condition PIP', xlab = 'SNP positions', add_legend = T, b=true_pos)<jupyter_output><empty_output><jupyter_text>Estimating prior variance scalar<jupyter_code>start = Sys.time()
res2 = mmbr::msusie(dat$X,dat$y,L=L,prior_variance=dat$V,compute_objective=T,estimate_residual_variance=F,estimate_prior_variance=T)
Sys.time() - start
res2$elbo<jupyter_output><empty_output><jupyter_text>The ELBO is indeed better, but it takes much longer time -- per iteration time is over **100 times** compared to when the scalar is not estimated. The estimated scalars for prior variance are:<jupyter_code>res2$V<jupyter_output><empty_output><jupyter_text>As expected only the first 5 effects are non-zero.<jupyter_code>susieR::susie_plot(res2,y='PIP', main = 'Default SuSiE plot for cross-condition PIP', xlab = 'SNP positions', add_legend = T, b=true_pos)<jupyter_output><empty_output><jupyter_text>The PIP plot also appears a lot cleaner.  "Simple" method to estimate priorHere instead of estimating prior scalar I only compare it with setting it to zero:<jupyter_code>start = Sys.time()
res2 = mmbr::msusie(dat$X,dat$y,L=L,prior_variance=dat$V,compute_objective=T,estimate_residual_variance=F,estimate_prior_variance=T, estimate_prior_method='simple')
Sys.time() - start
res2$elbo
res2$V<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11249481112494811, 'fraction_numerical': 0.024076380240763803, 'mean_word_length': 8.488188976377952, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '158019', 'license': 'MIT', 'n_tokens_mistral': 942, 'n_tokens_neox': 868, 'n_words': 198, 'path': 'inst/prototypes/multivariate_est_prior.ipynb', 'repo_name': 'zouyuxin/mmbr', 'size': '2409'}