library(BSPBSS)
#> 载入需要的程辑包:movMF
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 Thu Sep 1 21:54:10 2022
#>
#> stepsize_zeta 0.00712258 acc_rate_zeta 0.54
#> iter 200 Thu Sep 1 21:54:10 2022
#>
#> stepsize_zeta 0.00783484 acc_rate_zeta 0.47
#> iter 300 Thu Sep 1 21:54:11 2022
#>
#> stepsize_zeta 0.00861832 acc_rate_zeta 0.45
#> iter 400 Thu Sep 1 21:54:11 2022
#>
#> stepsize_zeta 0.00948015 acc_rate_zeta 0.44
#> iter 500 Thu Sep 1 21:54:11 2022
#>
#> stepsize_zeta 0.0104282 acc_rate_zeta 0.42
#> iter 600 Thu Sep 1 21:54:12 2022
#>
#> stepsize_zeta 0.011471 acc_rate_zeta 0.41
#> iter 700 Thu Sep 1 21:54:12 2022
#>
#> stepsize_zeta 0.0126181 acc_rate_zeta 0.36
#> iter 800 Thu Sep 1 21:54:13 2022
#>
#> stepsize_zeta 0.0138799 acc_rate_zeta 0.39
#> iter 900 Thu Sep 1 21:54:13 2022
#>
#> stepsize_zeta 0.0152679 acc_rate_zeta 0.41
#> iter 1000 Thu Sep 1 21:54:13 2022
#>
#> stepsize_zeta 0.0167947 acc_rate_zeta 0.34
#> iter 1100 Thu Sep 1 21:54:14 2022
#>
#> stepsize_zeta 0.0167947 acc_rate_zeta 0.46
#> iter 1200 Thu Sep 1 21:54:14 2022
#>
#> stepsize_zeta 0.0167947 acc_rate_zeta 0.3
#> iter 1300 Thu Sep 1 21:54:15 2022
#>
#> stepsize_zeta 0.0167947 acc_rate_zeta 0.29
#> iter 1400 Thu Sep 1 21:54:15 2022
#>
#> stepsize_zeta 0.0167947 acc_rate_zeta 0.39
#> iter 1500 Thu Sep 1 21:54:15 2022
#>
#> stepsize_zeta 0.0167947 acc_rate_zeta 0.32
#> iter 1600 Thu Sep 1 21:54:16 2022
#>
#> stepsize_zeta 0.0167947 acc_rate_zeta 0.29
#> iter 1700 Thu Sep 1 21:54:16 2022
#>
#> stepsize_zeta 0.0167947 acc_rate_zeta 0.34
#> iter 1800 Thu Sep 1 21:54:17 2022
#>
#> stepsize_zeta 0.0167947 acc_rate_zeta 0.32
#> iter 1900 Thu Sep 1 21:54:17 2022
#>
#> stepsize_zeta 0.0167947 acc_rate_zeta 0.31
#> iter 2000 Thu Sep 1 21:54:17 2022
#>
#> stepsize_zeta 0.0167947 acc_rate_zeta 0.37
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)