Download - Tokyo r #43
LaplacesDemonによる ベイズ統計モデリング
TokyoR #43 2014 0920 @siero5335
自己紹介 Twitter ID: @siero5335
仕事: 某大学で 化学物質曝露影響の解析 測定法の開発してます 専門: 環境化学、分析化学
測定結果の解析に統計を使用
MCMC流行ってますね
先日の会でもWinBUGSの次に来るMCMC interfaceについての話題がちらほらと
JAGS, Stan, MCMCglmm...etc
中でもJAGS, Stanが注目株?
JAGS
デメリット
確率分布の指定が難しい
ギブスサンプラーしか搭載してない
メリット
BUGSの資産を活かしやすい
ほとんどの尤度についてちゃんと入力できる
サンプリングの設定が割と簡単
Stan
デメリット
確率分布の指定が難しい(JAGSよりは簡単?)
コンパイルにかかる時間がそれなりに長い http://www.sumsar.net/blog/2013/06/three-ways-to-run-bayesian-models-in-r/ 参照
他になんか良さそうなinterface無いの?
メリット
NUTS, HMCによる高速な処理
コミュニティが活発
自由なモデリング
No-U-Turn samplerの詳細をいじる必要がない
LaplacesDemon
LaplacesDemon
hHp://www.bayesian-‐inference.com/soOwaredownload より入手可能
Tutorial hHp://www.icesi.edu.co/CRAN/web/packages/LaplacesDemon/vigneHes/LaplacesDemonTutorial.pdf
Examples hHp://www.icesi.edu.co/CRAN/web/packages/LaplacesDemon/vigneHes/Examples.pdf
Rで記述されたBayesian Laplacian interface 大量のMCMCアルゴリズム、確率分布、解析例を内蔵
ラプラス近似, 変分ベイズ, 並列計算, ベイズファクターに対応 パラメータ・変数重要度算出, 感度分析, 各種プロットなどに対応
LaplacesDemon メリット
Rのみで記述されている
Rに内蔵されている確率分布を使える
MCMCアルゴリズムが充実している
対応している手法も充実している デメリット
RなのでJAGS, Stanに比べると遅い(rcppに移す作業中
JAGS, Stanほど自由にモデリングはできない? 尤度などがRのfunctionで表現できるものに縛られる
コミュニティが小さく発展途上
例題データ (demonsnacks) 概要
例題データ (demonsnacks) row.names Serving.Size Calories Total.Fat Saturated.Fat Cholesterol Sodium Total.Carbohydrate Dietary.Fiber Sugars Protein
Apple 125 65 0 0 0 1 17 3 13 0
Apricots.Dried 250 213 0 0 0 10 55 7 49 3
Banana.Chips 85 441 29 25 0 5 50 7 30 2
Banana 225 200 1 0 0 2 51 6 28 2
Beef.Jerky 20 82 5 2 10 443 2 0 2 7
Beer.Light 29 9 0 0 0 1 0 0 0 0
Bit.O.Honey 40 150 3 2 0 118 32 0 19 1
Carrots.Baby 15 5 0 0 0 12 1 0 1 0
Cherries 155 77 0 0 0 5 19 2 13 2
Cranberries.Dried 40 123 1 0 0 1 33 2 26 0
Dates 24 66 0 0 0 0 18 2 16 0
Fritolay 28 137 6 1 0 92 19 2 2 2
Granola.Bar 24 116 6 1 0 68 15 1 0 2
Grapes 92 62 0 0 0 2 16 1 15 1
Jellybeans 11 41 0 0 0 5 10 0 8 0
Mangos 165 107 0 0 0 3 28 3 24 1
M&Ms 208 1023 44 27 29 127 148 6 132 9
Marshmallows 50 159 0 0 0 40 41 0 29 1
Nuts.Mixed 142 876 80 12 0 595 30 13 6 24
Nuts.Pistachio 123 702 57 7 0 12 34 13 10 26
…
39行 × 11列のデータ カロリーを予測するモデルを作る
例題データ (demonsnacks) library(pgirmess) pairsrp(demonsnacks[1:10],meth="spearman",pansmo=TRUE,abv=TRUE)
例題データ (demonsnacks) library(pgirmess) pairsrp(demonsnacks[1:10],meth="spearman",pansmo=TRUE,abv=TRUE)
LaplacesDemon書式
どんな書き方? Fit <-‐ LaplacesDemon(Model, Data=MyData, Iniaal.Values, Covar=NULL, Iteraaons=2000, Status=100, Thinning=2, Algorithm="AMWG", Specs=list(Periodicity=10))
入力Data作成 Fit <-‐ LaplacesDemon(Model, Data=MyData, Iniaal.Values, Covar=NULL, Iteraaons=2000, Status=100, Thinning=2, Algorithm="AMWG", Specs=list(Periodicity=10)) data(demonsnacks)
N<-‐ nrow (demonsnacks) #行数の指定 J <-‐ ncol (demonsnacks) #列数の指定 y <-‐ log(demonsnacks$Calories) #目的変数 X <-‐ cbind(1, as.matrix(demonsnacks[,c(1, 3:10)])) #説明変数 for (j in 2:J) {X[,j] <-‐ CenterScale(X[,j])} #中心化
mon.names <-‐ c(“LP”,“sigma”) #残差の項追加? parm.names <-‐ as.parm.names(list(beta=rep(0,J), log.sigma=0)) #標準化 MyData <-‐ list(J=J, X=X, mon.names=mon.names, parm.names=parm.names, y=y)
Model入力: Linear modelの場合 Fit <-‐ LaplacesDemon(Model, Data=MyData, Iniaal.Values, Covar=NULL, Iteraaons=2000, Status=100, Thinning=2, Algorithm="AMWG", Specs=list(Periodicity=10))
Model <-‐ funcaon(parm, Data) { beta <-‐ parm[1:Data$J] sigma <-‐ exp(parm[Data$J+1])
beta.prior <-‐ sum(dnormv(beta, 0, 1000, log=TRUE)) #無情報事前分布 sigma.prior <-‐ dhalfcauchy(sigma, 25, log=TRUE) #標準偏差の事前分布
mu <-‐ tcrossprod(Data$X, t(beta)) LL <-‐ sum(dnorm(Data$y, mu, sigma, log=TRUE)) #対数尤度
LP <-‐ LL + beta.prior + sigma.prior #事後分布 Modelout <-‐ list(LP=LP, Dev=-‐2*LL, Monitor=c(LP,sigma), yhat=rnorm(length(mu), mu, sigma), parm=parm) return(Modelout) }
Fit <-‐ LaplacesDemon(Model, Data=MyData, Iniaal.Values, Covar=NULL, Iteraaons=2000, Status=100, Thinning=2, Algorithm="AMWG", Specs=list(Periodicity=10)) Iniaal.Values <-‐ c(rep(0,J), log(1)) 今回は特に事前情報がないので適当な値を入れていく。
ランダムに適当な初期値をセットするための GIV (Generate ini9al values) 関数というのもあるようだが… チュートリアルに使い方が載ってないので割愛
初期値の設定
Fit <-‐ LaplacesDemon(Model, Data=MyData, Iniaal.Values, Covar=NULL, Iteraaons=2000, Status=100, Thinning=2, Algorithm="AMWG", Specs=list(Periodicity=10))
Cover: ユーザが分散、共分散ベクトルを指定しているかどうか
Iteraaons: 何回MCMCサンプリングするか
Status: 何サンプリングごとにコンソールにメッセージを表示するか
Thinning: 計算高速化のための間引き率
Algorithm: MCMCアルゴリズムの選択
Specs: MCMCアルゴリズムのチューニング
AMWG法の場合にはperiodicity(周期)の設定が必要 10回の読み込みごとに上手く改変して再当てはめ?
その他のアルゴリズムの場合はAdapaveなどを設定
その他設定
Fit <-‐ LaplacesDemon(Model, Data=MyData, Iniaal.Values, Covar=NULL, Iteraaons=2000, Status=100, Thinning=2, Algorithm="AMWG", Specs=list(Periodicity=10))
MCMCアルゴリズム色々
Metropolis-‐within-‐Gibbs (MWG) Mulaple-‐Try Metropolis (MTM) No-‐U-‐Turn Sampler (NUTS) Precondiaoned Crank-‐Nicolson (pCN) Oblique Hyperrectangle Slice Sampler (OHSS) Random Dive Metropolis-‐Hasangs (RDMH) Random-‐Walk Metropolis (RWM) Reflecave Slice Sampler (RSS) Refracave Sampler (Refracave) Reversible-‐Jump (RJ) Robust Adapave Metropolis (RAM) Sequenaal Adapave Metropolis-‐within-‐Gibbs (SAMWG) Sequenaal Metropolis-‐within-‐Gibbs (SMWG) Slice Sampler (Slice) Stochasac Gradient Langevin Dynamics (SGLD) Tempered Hamiltonian Monte Carlo (THMC) t-‐walk (twalk) Univariate Eigenvector Slice Sampler (UESS) Updaang Sequenaal Adapave Metropolis-‐within-‐Gibbs (USAMWG) Updaang Sequenaal Metropolis-‐within-‐Gibbs (USMWG)
Adapave Direcaonal Metropolis-‐within-‐Gibbs (ADMG) Adapave Griddy-‐Gibbs (AGG) Adapave Hamiltonian Monte Carlo (AHMC) Adapave Metropolis (AM) Adapave Metropolis-‐within-‐Gibbs (AMWG) Adapave-‐Mixture Metropolis (AMM) Affine-‐Invariant Ensemble Sampler (AIES) Componentwise Hit-‐And-‐Run Metropolis (CHARM) Delayed Rejecaon Adapave Metropolis (DRAM) Delayed Rejecaon Metropolis (DRM) Differenaal Evoluaon Markov Chain (DEMC) Ellipacal Slice Sampler (ESS) Gibbs Sampler (Gibbs) Griddy-‐Gibbs (GG) Hamiltonian Monte Carlo (HMC) Hamiltonian Monte Carlo with Dual-‐Averaging (HMCDA) Hit-‐And-‐Run Metropolis (HARM) Independence Metropolis (IM) Interchain Adaptaaon (INCA) Metropolis-‐Adjusted Langevin Algorithm (MALA) Metropolis-‐Coupled Markov Chain Monte Carlo (MCMCMC)
hHp://www.bayesian-‐inference.com/mcmc に各アルゴリズムの特徴記載
書き方まとめ Data, model, 初期値についてはじめに記述 それぞれをベクトルとして保存
Fit <-‐ LaplacesDemon(Model, Data=MyData, Iniaal.Values, Covar=NULL, Iteraaons=XX, Status=XX, Thinning=XX, Algorithm=”XX", Specs=list(Periodicity=10))
上記式のXX部分を埋めてモデルを完成させる
動かす!
書き方まとめ Data, model, 初期値についてはじめに記述 それぞれをベクトルとして保存
Fit <-‐ LaplacesDemon(Model, Data=MyData, Iniaal.Values, Covar=NULL, Iteraaons=XX, Status=XX, Thinning=XX, Algorithm=”XX", Specs=list(Periodicity=10))
上記式のXX部分を埋めてモデルを完成させる
動かす! Modelの方は線形回帰以外に何ができるの?
他にどんなモデルがつくれる?(一部略) ANCOVA ANOVA, One-‐Way Approximate Bayesian Computaaon (ABC) ARCH-‐M(1,1) Autoregressive Condiaonal Heteroskedasacity, ARCH(1,1) Autoregressive Moving Average, ARMA(1,1) Beta-‐Binomial Binary Logit Binomial Probit Change Point Regression Cluster Analysis Condiaonal Autoregression (CAR), Poisson Dynamic Linear Model (DLM): 1, 2, 3, 4 Exponenaal Smoothing Factor Analysis Factor Regression Gamma Regression GARCH(1,1) Geographically Weighted Regression Hidden Markov Model Hierarchical Bayes Inverse Gaussian Regression Kriging LASSO Latent Dirichlet Allocaaon (LDA)
MANOVA Missing Values: 1, 2, 3 Mixture Model Mulalevel Model Mulavariate Laplace Regression Mulavariate Regression Panel, Autoregression Poisson Penalized Spline Regression Poisson-‐Gamma Regression Polynomial Regression Power Priors Quanale Regression Ridge Regression Robust Regression Seemingly Unrelated Regression (SUR) Simultaneous Equaaons Spaaal Autoregression (SAR) Survival Model TARCH(1) Threshold Autoregression (TAR) Topic Model Variable Selecaon Vector Autoregression, VAR(1) Weighted Regression Zero-‐Inflated Poisson (ZIP)
以下にそれぞれのモデルの記述例あり hHp://www.icesi.edu.co/CRAN/web/packages/LaplacesDemon/vigneHes/Examples.pdf
結果の表示、モデル最適化
結果の表示 Fit Call: LaplacesDemon(Model = Model, Data = MyData, Iniaal.Values = Iniaal.Values, Covar = NULL, Iteraaons = 2000, Status = 100, Thinning = 2, Algorithm = "AMWG", Specs = list(Periodicity = 10)) Acceptance Rate: 0.43832 (0.15 < 0.5が良好) Algorithm: Adapave Metropolis-‐within-‐Gibbs Covariance Matrix: (NOT SHOWN HERE; diagonal shown instead) beta[1] beta[2] beta[3] beta[4] beta[5] beta[6] beta[7] beta[8] beta[9] 0.1972066 0.6575873 0.8393190 0.4202711 0.8110877 0.3030530 1.1820196 0.5230650 1.4233538 beta[10] log.sigma 0.5077560 0.4703056 Covariance (Diagonal) History: (NOT SHOWN HERE) Deviance Informaaon Criterion (DIC): All Staaonary Dbar 83.312 81.464 pD 110.028 9.120 DIC 193.340 90.584
Iniaal Values: [1] 0 0 0 0 0 0 0 0 0 0 0
結果の表示 Consort関数で確認
Consort(Fit): Fitの結果+ Iteraaons: 2000 Log(Marginal Likelihood): NA Minutes of run-‐ame: 0.13 Model: (NOT SHOWN HERE) Monitor: (NOT SHOWN HERE) Parameters (Number of): 11 Posterior1: (NOT SHOWN HERE) Posterior2: (NOT SHOWN HERE) Recommended Burn-‐In of Thinned Samples: 800 Recommended Burn-‐In of Un-‐thinned Samples: 1600 Recommended Thinning: 40 Specs: (NOT SHOWN HERE) Status is displayed every 100 iteraaons Summary1: (SHOWN BELOW) Summary2: (SHOWN BELOW) Thinned Samples: 1000 Thinning: 2
Demonic Suggesaon(次項で詳細
Mean SD MCSE ESS LB Median UB
beta[1] 5.01 0.27 0.03 149.37 4.80 5.04 5.25
beta[2] -0.41 0.42 0.06 82.20 -1.12 -0.41 0.41
beta[3] -0.27 0.94 0.26 13.61 -2.15 -0.29 1.61
beta[4] -0.18 0.71 0.16 35.43 -1.58 -0.17 1.24
beta[5] -0.37 0.51 0.12 27.36 -1.39 -0.37 0.61
beta[6] -0.48 0.32 0.04 123.22 -1.09 -0.47 0.12
beta[7] 2.20 0.59 0.13 38.16 0.99 2.24 3.32
beta[8] 0.57 0.47 0.09 63.28 -0.35 0.58 1.51
beta[9] -0.14 0.60 0.11 41.60 -1.43 -0.10 0.91
beta[10] 1.52 0.74 0.19 23.28 -0.10 1.46 2.93
log.sigma -0.36 0.17 0.02 122.82 -0.60 -0.37 -0.05
Deviance 83.31 14.83 2.08 104.30 73.75 81.38 98.20
LP -89.07 7.42 1.04 104.29 -96.52 -88.11 -84.29
sigma 0.71 0.17 0.02 86.15 0.55 0.69 0.95
Mean SD MCSE ESS LB Median UB
beta[1] 5.03 0.11 0.01 89.96 4.80 5.02 5.24
beta[2] -0.48 0.40 0.10 24.97 -1.10 -0.51 0.43
beta[3] -0.43 0.68 0.26 7.09 -2.42 -0.33 0.82
beta[4] -0.15 0.65 0.23 9.00 -1.35 -0.23 1.03
beta[5] -0.50 0.33 0.06 31.35 -1.21 -0.45 0.12
beta[6] -0.43 0.24 0.04 64.41 -0.93 -0.44 -0.05
beta[7] 2.13 0.47 0.17 15.12 1.19 2.10 2.96
beta[8] 0.58 0.39 0.10 22.62 -0.11 0.51 1.66
beta[9] 0.02 0.45 0.16 15.25 -0.80 0.03 0.87
beta[10] 1.73 0.45 0.14 16.81 0.99 1.69 2.57
log.sigma -0.37 0.12 0.02 64.38 -0.57 -0.39 -0.12
Deviance 81.46 4.27 0.72 61.31 74.56 81.64 91.93
LP -88.15 2.14 1.04 61.24 -93.38 -88.24 -84.70
sigma 0.69 0.08 0.02 63.20 0.56 0.68 0.88
Summary of all samples
Summary of staaonary samples
Demonic Suggestion(悪魔の囁き) Consort(XX)関数で確認
Demonic Suggesaonシステムで収束したかを確認してくれる
以下5つの項目から収束診断
1. 使ったMCMCアルゴリズム 2. Acceptance rate (0.15-‐0.5の範囲内が望ましい) 3. Montecarlo standard error (< 6.27が望ましい) 4. Effecave sample size (ESS) (100以上であること) 5. 何サンプル目から定常分布になったか
悪魔の囁き(モデル最適化) Consort(Fit)
略
Demonic Suggesaon
Due to the combinaaon of the following condiaons,
1. Adapave Metropolis-‐within-‐Gibbs 2. The acceptance rate (0.4383182) is within the interval [0.15,0.5] 3. At least one target MCSE is >= 6.27% of its marginal posterior standard deviaaon. 4. At least one target distribuaon has an effecave sample size (ESS) less than 100. The worst mixing chain is: beta[3] (ESS=13.60738). 5. Each target distribuaon became staaonary by 801 iteraaons.
中略
Laplace's Demon has not been appeased, and suggests copy/pasang the following R code into the R console, and running it.
Iniaal.Values <-‐ as.iniaal.values(Fit) Fit <-‐ LaplacesDemon(Model, Data=MyData, Iniaal.Values, Covar=NULL, Iteraaons=40000, Status=200, Thinning=40, Algorithm="CHARM", Specs=NULL)
次にどういう設定で回せばいいかもついてくる
囁きに従った結果1 Fit2 Call: LaplacesDemon(Model = Model, Data = MyData, Iniaal.Values = Iniaal.Values, Covar = NULL, Iteraaons = 40000, Status = 200, Thinning = 40, Algorithm = "CHARM", Specs = NULL)
Acceptance Rate: 0.76534 (0.15 < 0.5が良好)
Algorithm: Componentwise Hit-‐And-‐Run Metropolis
Covariance Matrix: (NOT SHOWN HERE; diagonal shown instead) beta[1] beta[2] beta[3] beta[4] beta[5] beta[6] beta[7] beta[8] 0.01240755 0.14417120 0.93733150 0.54973268 0.25152772 0.08115080 0.27561874 0.18940992 beta[9] beta[10] log.sigma 0.30695378 0.57556990 0.01964738
Covariance (Diagonal) History: (NOT SHOWN HERE) Deviance Informaaon Criterion (DIC): All Staaonary Dbar 82.246 82.246 pD 17.579 17.579 DIC 99.825 99.825
Iniaal Values: [1] 4.9974512 -‐0.1382687 -‐1.4346129 0.8539510 -‐1.1331011 -‐0.4643098 1.8609538 0.5793896 [9] -‐0.6495910 2.3852500 -‐0.2692097
悪魔の囁き2(モデル最適化) Consort(Fit2)
略
Demonic Suggesaon
Due to the combinaaon of the following condiaons,
1. Componentwise Hit-‐And-‐Run Metropolis 2. The acceptance rate (0.7638741) is above 0.5. 3. At least one target MCSE is >= 6.27% of its marginal posteriorstandard deviaaon. 4. Each target distribuaon has an effecave sample size (ESS) of at least 100. 5. Each target distribuaon became staaonary by 1 iteraaon.
中略
Laplace's Demon has not been appeased, and suggests copy/pasang the following R code into the R console, and running it.
Iniaal.Values <-‐ as.iniaal.values(Fit) Fit <-‐ LaplacesDemon(Model, Data=MyData, Iniaal.Values, Covar=NULL, Iteraaons=364000, Status=94545, Thinning=364, Algorithm="CHARM", Specs=list(alpha.star=0.44)) まだ基準を満たさないからおかわり
囁きに従った結果2 Fit3 Call: LaplacesDemon(Model = Model, Data = MyData, Iniaal.Values = Iniaal.Values, Covar = NULL, Iteraaons = 364000, Status = 94545, Thinning = 364, Algorithm = "CHARM", Specs = list(alpha.star = 0.44))
Acceptance Rate: 0.43995
Algorithm: Componentwise Hit-‐And-‐Run Metropolis Covariance Matrix: (NOT SHOWN HERE; diagonal shown instead) beta[1] beta[2] beta[3] beta[4] beta[5] beta[6] beta[7] beta[8] 0.01358412 0.13479294 0.90407192 0.50149095 0.27029404 0.08264718 0.29542627 0.17658442 beta[9] beta[10] log.sigma 0.31023915 0.59911801 0.01874272
Covariance (Diagonal) History: (NOT SHOWN HERE) Deviance Informaaon Criterion (DIC): All Staaonary Dbar 82.246 82.246 pD 15.478 15.478 DIC 97.724 97.724
Iniaal Values: [1] 5.139087920 0.138937856 -‐1.348943603 0.002571293 -‐1.075622908 -‐0.481418573 2.260021886 [8] 0.211831011 0.013342143 2.442091371 -‐0.359196954
悪魔の囁き3(モデル最適化) Consort(Fit3)
略
Demonic Suggesaon
Due to the combinaaon of the following condiaons,
1. Componentwise Hit-‐And-‐Run Metropolis 2. The acceptance rate (0.4399505) is within the interval [0.15,0.5]. #基準内にはいった 3. Each target MCSE is < 6.27% of its marginal posterior standard deviaaon. #SDが基準内 4. Each target distribuaon has an effecave sample size (ESS) of at least 100. #十分サンプリングされた 5. Each target distribuaon became staaonary by 1 iteraaon. #最初から定常分布
Laplace's Demon has been appeased, and suggests the marginal posterior samples should be ploHed and subjected to any other MCMC diagnosac deemed fit before using these samples for inference.
Laplace's Demon is finished consorang.
基準を満たせばそれ以上囁かれない
収束後の結果表示
結果確認(サンプリング確認) 悪魔の囁き前 悪魔の囁き後
BurnIn <-‐ Fit$Rec.BurnIn.Thinned plot(Fit, BurnIn, MyData, PDF=FALSE)
結果確認(信頼区間の図示) caterpillar.plot(Fit3, Parms=1:10)
Pred <-‐ predict(Fit, Model, MyData, CPUs=1) summary(Pred, Discrep="Chi-‐Square")
Bayesian Predicave Informaaon Criterion: Dbar pD BPIC 81.464 9.12 99.704
Concordance: 0.9487179 Discrepancy Staasac: 23.848 L-‐criterion: 36.25, S.L: 0.32
Concordance: 実測値が予測値の95%信頼区間内にあった回数の割合
Discrepancy Staasac: 当てはまり悪いと値大きい
L-‐criterion: 実測と予測値が近いと小さい値に
Bayesian Predicave Informaaon Criterion: 特定のfamilyの確率分布に真の分布が含まれていない時に、予想される分布の対数尤度の事後平均を推測するために使う…らしい
結果確認 (posterior predicave check)
plot(Pred, Style="Covariates", Data=MyData) plot(Pred, Style="Density", Rows=1:9)
結果確認 (posterior predicave check)
Posterior predic9veを図で確認 共変量・事後密度などを使用
Importance(Fit, Model, MyData, Discrep="Chi-‐Square")
結果確認(変数重要度)
BPIC Concordance Discrep L-‐criterion
Full 99.704 0.949 25.916 36.12
X[,-‐1] 253266.467 0 1713.563 198.796
X[,-‐2] 151.015 0.974 23.364 37.656
X[,-‐3] 467.209 0.974 24.068 39.14
X[,-‐4] 200.881 0.949 22.644 37.693
X[,-‐5] 147.276 0.974 26.614 37.343
X[,-‐6] 109.596 0.949 28.831 37.282
X[,-‐7] 1758.897 0.872 82.402 49.687
X[,-‐8] 175.367 0.949 30.726 36.935
X[,-‐9] 121.804 0.974 25.534 36.761
X[,-‐10] 1172.784 0.872 59.493 45.012
変数を取り除いた際の目的変数の推定値と実測値とずれの量からImportanceを計算
ベンチマークテスト(Stanとの比較)
ベンチマークテスト LaplaceDemon基準の収束まで 計866000サンプリング 操作終了まで9.50分,最終828000サンプリングに8.47分
Stanでは同一サンプリング回数で5.68分, サンプリング回数10000の設定で53.7秒(収束確認 Rhat < 1.1)
ベンチマークテスト LaplaceDemon基準の収束まで 計866000サンプリング 操作終了まで9.50分,最終828000サンプリングに8.47分
Stanでは同一サンプリング回数で5.68分, サンプリング回数10000の設定で53.7秒(収束確認 Rhat < 1.1)
ベンチマークテスト LaplaceDemon基準の収束まで 計866000サンプリング 操作終了まで9.50分,最終828000サンプリングに8.47分
Stanでは同一サンプリング回数で5.68分, サンプリング回数10000の設定で53.7秒(収束確認 Rhat < 1.1)
なんか早くする方法ないの?
ベンチマークテスト LaplaceDemon基準の収束まで 計866000サンプリング 操作終了まで9.50分,最終828000サンプリングに8.47分
Stanでは同一サンプリング回数で5.68分, サンプリング回数10000の設定で53.7秒(収束確認 Rhat < 1.1)
なんか早くする方法ないの?
LaplacesDemon.hpc!
高速化検討 LaplacesDemon.hpc(Model, Data, Iniaal.Values, Covar=NULL, Iteraaons=X, Status=X, Thinning=X, Algorithm=”X", Specs=NULL, Chains=X, CPUs=X, Packages=NULL, Dyn.libs=NULL) Chain: 並列計算させる数 CPUs: 使うCPUの数 Packages: パッケージに依存してModelが作られてる時に必要 Dyn.libs: DLL依存でchainに何かしら工夫したいときに必要
が、何故か8コア使ったのに12.6分…
並列処理に変換するだけで3分近く消費
より大規模なデータならご利益がある?
誰か検証してみてください
LaplacesDemon.hpc
まとめ Modelを設定する必要があるので書き方としてはStanなどと大きくは変わらない印象 ただしexampleが充実している点はgood 悪魔が囁いて収束判定っぽいことをしてくれる 結果の表示に関するコマンドも充実してる印象 Stanと比べるとだいぶ遅い Rcppにぶん投げられるようにC++に書き換えてるらしいので将来的に期待