library(BSPBSS)
This is a basic example which shows you how to solve a common problem.
First we load the package and generate simulated images with a probabilistic ICA model:
library(BSPBSS)
set.seed(612)
= sim_2Dimage(length = 30, sigma = 5e-4, n = 30, smooth = 6) sim
The true source signals are three 2D geometric patterns (set
smooth=0
to generate patterns with sharp edges).
levelplot2D(sim$S,lim = c(-0.04,0.04), sim$coords)
which generate observed images such as
levelplot2D(sim$X[1:3,], lim = c(-0.12,0.12), sim$coords)
Then we generate initial values for mcmc,
= init_bspbss(sim$X, sim$coords, q = 3, ker_par = c(0.1,50), num_eigen = 50) ini
and run!
= mcmc_bspbss(ini$X,ini$init,ini$prior,ini$kernel,n.iter=2000,n.burn_in=1000,thin=10,show_step=100)
res #> iter 100 Fri Nov 25 10:01:05 2022
#>
#> zeta0.154297 stepsize_zeta 0.00712258 accp_rate_zeta 0.45
#> iter 200 Fri Nov 25 10:01:05 2022
#>
#> zeta0.182201 stepsize_zeta 0.00783484 accp_rate_zeta 0.35
#> iter 300 Fri Nov 25 10:01:05 2022
#>
#> zeta0.205042 stepsize_zeta 0.00861832 accp_rate_zeta 0.45
#> iter 400 Fri Nov 25 10:01:06 2022
#>
#> zeta0.189928 stepsize_zeta 0.00948015 accp_rate_zeta 0.42
#> iter 500 Fri Nov 25 10:01:06 2022
#>
#> zeta0.199043 stepsize_zeta 0.0104282 accp_rate_zeta 0.39
#> iter 600 Fri Nov 25 10:01:06 2022
#>
#> zeta0.197815 stepsize_zeta 0.011471 accp_rate_zeta 0.39
#> iter 700 Fri Nov 25 10:01:06 2022
#>
#> zeta0.22763 stepsize_zeta 0.0126181 accp_rate_zeta 0.34
#> iter 800 Fri Nov 25 10:01:07 2022
#>
#> zeta0.166707 stepsize_zeta 0.0138799 accp_rate_zeta 0.31
#> iter 900 Fri Nov 25 10:01:07 2022
#>
#> zeta0.188473 stepsize_zeta 0.0152679 accp_rate_zeta 0.22
#> iter 1000 Fri Nov 25 10:01:07 2022
#>
#> zeta0.208003 stepsize_zeta 0.0152679 accp_rate_zeta 0.27
#> iter 1100 Fri Nov 25 10:01:07 2022
#>
#> zeta0.176799 stepsize_zeta 0.0152679 accp_rate_zeta 0.24
#> iter 1200 Fri Nov 25 10:01:08 2022
#>
#> zeta0.180526 stepsize_zeta 0.0152679 accp_rate_zeta 0.28
#> iter 1300 Fri Nov 25 10:01:08 2022
#>
#> zeta0.158511 stepsize_zeta 0.0152679 accp_rate_zeta 0.31
#> iter 1400 Fri Nov 25 10:01:08 2022
#>
#> zeta0.127507 stepsize_zeta 0.0152679 accp_rate_zeta 0.28
#> iter 1500 Fri Nov 25 10:01:08 2022
#>
#> zeta0.18967 stepsize_zeta 0.0152679 accp_rate_zeta 0.23
#> iter 1600 Fri Nov 25 10:01:09 2022
#>
#> zeta0.198324 stepsize_zeta 0.0152679 accp_rate_zeta 0.3
#> iter 1700 Fri Nov 25 10:01:09 2022
#>
#> zeta0.183634 stepsize_zeta 0.0152679 accp_rate_zeta 0.3
#> iter 1800 Fri Nov 25 10:01:09 2022
#>
#> zeta0.140081 stepsize_zeta 0.0152679 accp_rate_zeta 0.26
#> iter 1900 Fri Nov 25 10:01:09 2022
#>
#> zeta0.244967 stepsize_zeta 0.0152679 accp_rate_zeta 0.29
#> iter 2000 Fri Nov 25 10:01:10 2022
#>
#> zeta0.226313 stepsize_zeta 0.0152679 accp_rate_zeta 0.27
Then the results can be summarized by
= sum_mcmc_bspbss(res, ini$X, ini$kernel, start = 101, end = 200, select_p = 0.5) res_sum
and shown by
levelplot2D(res_sum$S, lim = c(-1.3,1.3), sim$coords)
For comparison, we show the estimated sources provided by informax ICA here.
levelplot2D(ini$init$ICA_S, lim = c(-1.7,1.7), sim$coords)