Last active
September 26, 2016 06:25
-
-
Save mages/2160bc4d4fb73f3f52f79fdbb923b0af to your computer and use it in GitHub Desktop.
Revisions
-
mages revised this gist
Sep 26, 2016 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,12 +20,12 @@ print(fit, probs=c(0.025, 0.5, 0.975)) ## post-warmup draws per chain=500, total post-warmup draws=2000. ## ## mean se_mean sd 2.5% 50% 97.5% n_eff Rhat ## mu 4.22 0.01 0.17 3.88 4.22 4.53 771 1 ## sigma 1.82 0.00 0.13 1.57 1.81 2.10 2000 1 ## y_ppc 4.22 0.04 1.86 0.70 4.21 7.88 2000 1 ## lp__ -200.32 0.03 0.97 -203.02 -200.02 -199.41 1016 1 ## ## Samples were drawn using NUTS(diag_e) at Mon Sep 26 07:25:09 2016. ## For each parameter, n_eff is a crude measure of effective sample size, ## and Rhat is the potential scale reduction factor on split chains (at ## convergence, Rhat=1). -
mages revised this gist
Sep 25, 2016 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,10 +8,9 @@ summary(y) ## Min. 1st Qu. Median Mean 3rd Qu. Max. ## -0.4294 3.0120 4.2280 4.2180 5.3830 8.8030 ret <- stanc(file="NormaLDistribution.stan") # Check Stan file ret_sm <- stan_model(stanc_ret = ret) # Compile Stan code fit <- sampling(ret_sm, warmup=100, iter=600, seed=1, data=list(y, N=length(y))) stan_trace(fit, inc_warmup = TRUE) stan_hist(fit) -
mages revised this gist
Sep 25, 2016 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,4 +29,9 @@ print(fit, probs=c(0.025, 0.5, 0.975)) ## Samples were drawn using NUTS(diag_e) at Sun Sep 25 20:32:45 2016. ## For each parameter, n_eff is a crude measure of effective sample size, ## and Rhat is the potential scale reduction factor on split chains (at ## convergence, Rhat=1). summary(extract(fit, "y_ppc")[["y_ppc"]]) ## Min. 1st Qu. Median Mean 3rd Qu. Max. ## -1.483 2.959 4.213 4.222 5.451 10.540 plot(ecdf(y), main="Posterior predictive check") lines(ecdf(extract(fit, "y_ppc")[["y_ppc"]]), col="#B2001D") -
mages revised this gist
Sep 25, 2016 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,18 +15,18 @@ fit <- sampling(ret_sm, warmup=100, iter=600, data=list(y, N=length(y))) stan_trace(fit, inc_warmup = TRUE) stan_hist(fit) print(fit, probs=c(0.025, 0.5, 0.975)) ## Inference for Stan model: NormaLDistribution. ## 4 chains, each with iter=600; warmup=100; thin=1; ## post-warmup draws per chain=500, total post-warmup draws=2000. ## ## mean se_mean sd 2.5% 50% 97.5% n_eff Rhat ## mu 4.21 0.01 0.17 3.85 4.21 4.54 631 1 ## sigma 1.82 0.00 0.13 1.57 1.81 2.10 1808 1 ## y_ppc 4.20 0.04 1.85 0.69 4.20 7.83 1992 1 ## lp__ -200.50 0.03 1.02 -203.36 -200.18 -199.53 873 1 ## ## Samples were drawn using NUTS(diag_e) at Sun Sep 25 20:32:45 2016. ## For each parameter, n_eff is a crude measure of effective sample size, ## and Rhat is the potential scale reduction factor on split chains (at ## convergence, Rhat=1). -
mages created this gist
Sep 25, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ library(rstan) library(MASS) set.seed(1) y <- rnorm(100, 4, 2) truehist(y, col="#B2001D") lines(density(y), col="skyblue", lwd=2) summary(y) ## Min. 1st Qu. Median Mean 3rd Qu. Max. ## -0.4294 3.0120 4.2280 4.2180 5.3830 8.8030 ret <- stanc(file="NormaLDistribution.stan") ret_sm <- stan_model(stanc_ret = ret) fit <- sampling(ret_sm, warmup=100, iter=600, seed=1, data=list(y, N=length(y))) stan_trace(fit, inc_warmup = TRUE) stan_hist(fit) print(fit, probs=c(0.25, 0.5, 0.75)) ## Inference for Stan model: NormaLDistribution. ## 4 chains, each with iter=600; warmup=100; thin=1; ## post-warmup draws per chain=500, total post-warmup draws=2000. ## ## mean se_mean sd 25% 50% 75% n_eff Rhat ## mu 4.21 0.01 0.17 4.11 4.21 4.33 631 1 ## sigma 1.82 0.00 0.13 1.72 1.81 1.90 1808 1 ## y_ppc 4.20 0.04 1.85 2.92 4.20 5.42 1992 1 ## lp__ -200.50 0.03 1.02 -200.92 -200.18 -199.77 873 1 ## ## Samples were drawn using NUTS(diag_e) at Sun Sep 25 20:16:49 2016. ## For each parameter, n_eff is a crude measure of effective sample size, ## and Rhat is the potential scale reduction factor on split chains (at ## convergence, Rhat=1).