Last updated: 2023-05-04
Checks: 6 1
Knit directory: survival-susie/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). 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(20230201)
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.
Using absolute paths to the files within your workflowr project makes it difficult for you and others to run your code on a different machine. Change the absolute path(s) below to the suggested relative path(s) to make your code more reproducible.
absolute | relative |
---|---|
/Users/nicholeyang/Downloads/survival-susie/code/vi_poisson.R | code/vi_poisson.R |
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 e15fd08. 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
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: analysis/.DS_Store
Ignored: analysis/.RData
Ignored: analysis/.Rhistory
Ignored: data/.DS_Store
Untracked files:
Untracked: analysis/ibss_null_model.Rmd
Untracked: code/vi_poisson.R
Untracked: data/dsc3/
Unstaged changes:
Modified: analysis/check_coxph_fit.Rmd
Modified: analysis/compare_power_fdr.Rmd
Modified: analysis/index.Rmd
Deleted: analysis/null_model_demo.Rmd
Modified: analysis/null_model_zscore.Rmd
Deleted: analysis/one_predictor_investigation.Rmd
Deleted: analysis/ser_survival.Rmd
Modified: analysis/sim_survival_with_censoring.Rmd
Modified: analysis/susie_poor_performance_example.Rmd
Modified: code/VI_exponential.R
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/vi_poisson.Rmd
) and HTML (docs/vi_poisson.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 | e15fd08 | yunqiyang0215 | 2023-05-04 | wflow_publish("analysis/vi_poisson.Rmd") |
html | 970761b | yunqiyang0215 | 2023-05-04 | Build site. |
Rmd | 56599b6 | yunqiyang0215 | 2023-05-04 | wflow_publish("analysis/vi_poisson.Rmd") |
html | fc5ae54 | yunqiyang0215 | 2023-05-04 | Build site. |
Rmd | 8d48e50 | yunqiyang0215 | 2023-05-04 | wflow_publish("analysis/vi_poisson.Rmd") |
html | ff3ec94 | yunqiyang0215 | 2023-05-04 | Build site. |
Rmd | ad12e81 | yunqiyang0215 | 2023-05-04 | wflow_publish("analysis/vi_poisson.Rmd") |
html | f2074a9 | yunqiyang0215 | 2023-05-04 | Build site. |
Rmd | 470fad9 | yunqiyang0215 | 2023-05-04 | wflow_publish("analysis/vi_poisson.Rmd") |
html | 618d64d | yunqiyang0215 | 2023-05-04 | Build site. |
Rmd | 420b623 | yunqiyang0215 | 2023-05-04 | wflow_publish("analysis/vi_poisson.Rmd") |
html | be72b92 | yunqiyang0215 | 2023-05-04 | Build site. |
Rmd | bb2de36 | yunqiyang0215 | 2023-05-04 | wflow_publish("analysis/vi_poisson.Rmd") |
Test for implementation of Poisson SER. The derivation can be found here: https://www.overleaf.com/read/rnftbwbsqrrg
source("/Users/nicholeyang/Downloads/survival-susie/code/vi_poisson.R")
sim.data = function(n, X, ss, sigma2, prior.prob){
gamma = rmultinom(1, size = 1, prob = prior.prob)
b = rnorm(1, 0, sqrt(sigma2))
b.vec = b*gamma
lambda = ss * exp( X%*% b.vec)
y = unlist(lapply(lambda, function(x) rpois(1, lambda = x)))
return(list(y = y, X = X, ss =ss, b.vec = b.vec))
}
set.seed(1)
n = 20
p = 5
ss = rep(1, 20)
X = matrix(NA, nrow = n, ncol = p)
for (i in 1:p){
X[, i] = rnorm(n)
}
dat = sim.data(n, X, ss, sigma2 = 1, prior.prob = rep(1/p, p))
dat$b.vec
# [,1]
# [1,] 0.0000000
# [2,] 0.0000000
# [3,] 0.0000000
# [4,] 0.0000000
# [5,] -0.9109216
# initializations
m.vec = rep(1, p)
v2.vec = rep(1, p)
alpha <- rep(1/p, p)
pi <- rep(1/p, p)
lower = c(-1e2, 1e-12)
upper = c(1e2, 1e4)
result <- update_q(X, dat$y, ss, m.vec, v2.vec, sigma2 = 1, pi, alpha, maxiter = 20, tol, lower, upper)
head(result$alpha)
head(result$m.vec)
head(result$v2.vec)
# [,1] [,2] [,3] [,4] [,5]
# [1,] 0.20000000 0.2000000000 0.2000000000 0.2000000000 0.2000000
# [2,] 0.07292743 0.0001021124 0.0001111229 0.0001115133 0.9267478
# [3,] 0.07423784 0.0001078727 0.0001173151 0.0001178384 0.9254191
# [4,] 0.07434965 0.0001083748 0.0001178547 0.0001183898 0.9253057
# [5,] 0.07435923 0.0001084179 0.0001179010 0.0001184372 0.9252960
# [6,] 0.07435952 0.0001084192 0.0001179024 0.0001184386 0.9252957
# [,1] [,2] [,3] [,4] [,5]
# [1,] 1.0000000 1.00000000 1.0000000 1.0000000 1.0000000
# [2,] 0.7625952 -0.10056749 0.1228895 0.1661023 -0.9296332
# [3,] 0.7590191 -0.09993402 0.1220551 0.1654071 -0.9249457
# [4,] 0.7587137 -0.09992108 0.1220375 0.1653811 -0.9245456
# [5,] 0.7587087 -0.09989792 0.1220037 0.1653811 -0.9245369
# [6,] 0.7587087 -0.09989725 0.1220010 0.1653811 -0.9245369
# [,1] [,2] [,3] [,4] [,5]
# [1,] 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000
# [2,] 0.03477561 0.05737413 0.06205704 0.03551602 0.03737578
# [3,] 0.03475016 0.05698267 0.06160822 0.03537572 0.03735103
# [4,] 0.03475007 0.05695186 0.06156815 0.03536832 0.03735236
# [5,] 0.03474685 0.05694348 0.06155843 0.03536832 0.03734782
# [6,] 0.03474685 0.05694547 0.06156837 0.03536832 0.03734782
tail(result$alpha, n = 1)
tail(result$m.vec, n = 1)
tail(result$v2.vec, n = 1)
# [,1] [,2] [,3] [,4] [,5]
# [20,] 0.07435952 0.0001084192 0.0001179024 0.0001184386 0.9252957
# [,1] [,2] [,3] [,4] [,5]
# [20,] 0.7587087 -0.0998966 0.1219836 0.1653811 -0.9245369
# [,1] [,2] [,3] [,4] [,5]
# [20,] 0.03474685 0.05694683 0.06156505 0.03536832 0.03734782
plot(result$elbo, xlab = "iter", ylab = "elbo")
Version | Author | Date |
---|---|---|
fc5ae54 | yunqiyang0215 | 2023-05-04 |
set.seed(3)
n = 200
p = 5
ss = rep(1, n)
X = matrix(NA, nrow = n, ncol = p)
for (i in 1:p){
X[, i] = rnorm(n)
}
dat = sim.data(n, X, ss, sigma2 = 1, prior.prob = rep(1/p, p))
dat$b.vec
# [,1]
# [1,] 0.0000000
# [2,] 0.0000000
# [3,] 0.0000000
# [4,] -0.9728448
# [5,] 0.0000000
# initializations
m.vec = rep(1, p)
v2.vec = rep(1, p)
alpha <- rep(1/p, p)
pi <- rep(1/p, p)
lower = c(-1e2, 1e-12)
upper = c(1e2, 1e4)
result <- update_q(X, dat$y, ss, m.vec, v2.vec, sigma2 = 1, pi, alpha, maxiter = 20, tol, lower, upper)
head(result$alpha)
head(result$m.vec)
head(result$v2.vec)
# [,1] [,2] [,3] [,4] [,5]
# [1,] 2.000000e-01 2.000000e-01 2.000000e-01 0.2 2.000000e-01
# [2,] 2.573553e-100 4.966843e-100 3.413141e-100 1.0 8.244662e-100
# [3,] 2.558142e-100 4.937279e-100 3.392754e-100 1.0 8.195830e-100
# [4,] 2.558142e-100 4.937279e-100 3.392754e-100 1.0 8.195830e-100
# [5,] 2.558142e-100 4.937279e-100 3.392754e-100 1.0 8.195830e-100
# [6,] 2.558142e-100 4.937279e-100 3.392754e-100 1.0 8.195830e-100
# [,1] [,2] [,3] [,4] [,5]
# [1,] 1.00000000 1.00000000 1.00000000 1.000000 1.0000000
# [2,] -0.05615829 -0.09768592 -0.07725215 -1.005268 0.1202053
# [3,] -0.05615829 -0.09768592 -0.07725215 -1.005268 0.1202053
# [4,] -0.05615829 -0.09768592 -0.07725215 -1.005268 0.1202053
# [5,] -0.05615829 -0.09768592 -0.07725215 -1.005268 0.1202053
# [6,] -0.05615829 -0.09768592 -0.07725215 -1.005268 0.1202053
# [,1] [,2] [,3] [,4] [,5]
# [1,] 1.000000000 1.000000000 1.000000000 1.000000000 1.000000000
# [2,] 0.005221934 0.004810562 0.004911976 0.001547982 0.004865276
# [3,] 0.005221934 0.004810562 0.004911976 0.001547982 0.004865276
# [4,] 0.005221934 0.004810562 0.004911976 0.001547982 0.004865276
# [5,] 0.005221934 0.004810562 0.004911976 0.001547982 0.004865276
# [6,] 0.005221934 0.004810562 0.004911976 0.001547982 0.004865276
tail(result$alpha, n = 1)
tail(result$m.vec, n = 1)
tail(result$v2.vec, n = 1)
# [,1] [,2] [,3] [,4] [,5]
# [20,] 2.558142e-100 4.937279e-100 3.392754e-100 1 8.19583e-100
# [,1] [,2] [,3] [,4] [,5]
# [20,] -0.05615829 -0.09768592 -0.07725215 -1.005268 0.1202053
# [,1] [,2] [,3] [,4] [,5]
# [20,] 0.005221934 0.004810562 0.004911976 0.001547982 0.004865276
plot(result$elbo, xlab = "iter", ylab = "elbo")
set.seed(5)
n = 2e3
p = 5
ss = rep(1, n)
X = matrix(NA, nrow = n, ncol = p)
for (i in 1:p){
X[, i] = rnorm(n)
}
dat = sim.data(n, X, ss, sigma2 = 1, prior.prob = rep(1/p, p))
dat$b.vec
# [,1]
# [1,] 0.0000000
# [2,] 0.0000000
# [3,] 0.0000000
# [4,] 0.1007886
# [5,] 0.0000000
# initializations
m.vec = rep(1, p)
v2.vec = rep(1, p)
alpha <- rep(1/p, p)
pi <- rep(1/p, p)
lower = c(-0.1, 0)
upper = c(10, 1e4)
result <- update_q(X, dat$y, ss, m.vec, v2.vec, sigma2 = 1, pi, alpha, maxiter = 1, tol, lower, upper)
head(result$alpha)
head(result$m.vec)
head(result$v2.vec)
tail(result$alpha, n = 1)
tail(result$m.vec, n = 1)
tail(result$v2.vec, n = 1)
plot(result$elbo, xlab = "iter", ylab = "elbo")
sessionInfo()
# R version 4.1.1 (2021-08-10)
# Platform: x86_64-apple-darwin20.6.0 (64-bit)
# Running under: macOS Monterey 12.0.1
#
# Matrix products: default
# BLAS: /usr/local/Cellar/openblas/0.3.18/lib/libopenblasp-r0.3.18.dylib
# LAPACK: /usr/local/Cellar/r/4.1.1_1/lib/R/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.6.2
#
# loaded via a namespace (and not attached):
# [1] Rcpp_1.0.8.3 pillar_1.6.4 compiler_4.1.1 bslib_0.4.1
# [5] later_1.3.0 jquerylib_0.1.4 git2r_0.28.0 highr_0.9
# [9] tools_4.1.1 digest_0.6.28 jsonlite_1.7.2 evaluate_0.14
# [13] lifecycle_1.0.1 tibble_3.1.5 pkgconfig_2.0.3 rlang_1.0.6
# [17] cli_3.1.0 rstudioapi_0.13 yaml_2.2.1 xfun_0.27
# [21] fastmap_1.1.0 stringr_1.4.0 knitr_1.36 fs_1.5.0
# [25] vctrs_0.3.8 sass_0.4.4 rprojroot_2.0.2 glue_1.4.2
# [29] R6_2.5.1 fansi_0.5.0 rmarkdown_2.11 whisker_0.4
# [33] magrittr_2.0.1 promises_1.2.0.1 ellipsis_0.3.2 htmltools_0.5.2
# [37] httpuv_1.6.3 utf8_1.2.2 stringi_1.7.5 cachem_1.0.6
# [41] crayon_1.4.1