Skip to content

Commit

Permalink
squash before rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
yiz committed Feb 26, 2020
1 parent 8256e3f commit d4c69b0
Show file tree
Hide file tree
Showing 34 changed files with 5,338 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "stan"]
path = stan
url = https://github.com/stan-dev/stan
branch = mpi_warmup_v2
46 changes: 46 additions & 0 deletions examples/arK-arK/arK-arK.data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
K <- 5

T <- 200

y <- c(
0.7293852753, 0.8297635923, 0.7839527091, 1.0259589105, 0.9696824412,
1.0828859218, 0.7063891465, 0.7769243971, 0.4618029476, 0.6385997565,
0.3742344429, 0.0854966416, -0.1260149233, -0.2934151326, -0.2617308802,
-0.3359221372, -0.5019895766, -0.6417399532, -0.6224629523, -0.8508997238,
-0.8678351807, -1.0163853144, -1.0558901454, -0.9694812319, -1.0672519169,
-0.8430989055, -0.6827006149, -0.4446573489, -0.5920387090, -0.5105689815,
-0.4178858435, -0.1736168751, -0.1072500940, -0.0355025516, 0.3432168459,
0.3841903414, 0.4960876950, 0.7084511605, 0.5962806615, 0.6414424152,
0.6513222735, 0.5942153484, 0.7779414176, 0.7307762325, 0.4822472694,
0.5320372234, 0.4851022175, 0.3685521219, 0.3533268113, 0.1633690002,
0.2530389410, 0.0006621430, -0.0157674958, -0.0144909054, -0.0252628993,
-0.0056256128, -0.3189177332, -0.0227791612, -0.0716865707, -0.1850182514,
-0.2350075682, -0.1243111880, -0.1304923565, -0.1994777726, 0.0775739320,
-0.1628522111, 0.0234645663, -0.0646807914, 0.0845324981, 0.0550150773,
0.1417424074, 0.0876638222, -0.0528467198, 0.0695217092, -0.1014499970,
-0.0688806547, -0.2512073227, -0.3902872828, -0.1676283611, -0.2791635517,
-0.3121253506, -0.2865502547, -0.4117701622, -0.4982098458, -0.5028522787,
-0.7394004480, -0.2492280924, -0.4710158859, -0.4645727076, -0.4457058117,
-0.2844237121, -0.0227786998, -0.0605507196, 0.0662256249, 0.1405232927,
0.2763394882, 0.3772233671, 0.6103044598, 0.8808694697, 0.7885174270,
0.8013632395, 0.6609678195, 0.8097669196, 0.8205077274, 0.9807562966,
0.7240388847, 0.9318587166, 0.8504881551, 0.4805918638, 0.5085811342,
0.4161126092, 0.3146685518, -0.0281539189, -0.0717016521, -0.1439206592,
-0.5223661051, -0.4033621109, -0.6886329349, -0.6947170572, -0.6496557077,
-0.9926992981, -0.9354098817, -0.8969864546, -0.9781523572, -1.0668406080,
-0.9535621424, -0.7570773682, -0.8425755431, -0.6977697431, -0.3165581858,
-0.3878217300, -0.0671166462, -0.0385154999, 0.0895646813, 0.1454578935,
0.1852131654, 0.3956127617, 0.6852644284, 0.5563107812, 0.7108445288,
0.7462804690, 0.6684519285, 0.6936535333, 0.7379992741, 0.6627708128,
0.6900939802, 0.6807304694, 0.3733191989, 0.4536740601, 0.3137682260,
0.4500334320, -0.0337947734, 0.0047340737, -0.0856874439, 0.1082543270,
-0.1398269720, -0.0429735449, -0.4541637356, -0.3326428149, -0.2333534103,
-0.2014612607, -0.1826792426, -0.2278848137, -0.0415383584, -0.1210077677,
-0.0724354048, -0.0482025571, 0.1580149098, 0.0583926960, -0.1117559432,
-0.0381725259, 0.1789819529, -0.0148415779, 0.0500966207, -0.1980592117,
-0.1400114013, -0.1746734639, -0.1767850853, -0.2154143864, -0.4144745850,
-0.3405434088, -0.4482790416, -0.6571159536, -0.3546433053, -0.5257081174,
-0.6564372310, -0.5245263017, -0.4758655851, -0.3631316786, -0.3366915389,
-0.3254437415, 0.0006694692, 0.2080422414, 0.0023164951, 0.1124752107,
0.3494037146, 0.4717023945, 0.5906600432, 0.6048634064, 0.9331979099)

27 changes: 27 additions & 0 deletions examples/arK-arK/arK-arK.stan
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
data {
int<lower=0> K;
int<lower=0> T;
real y[T];
}

parameters {
real alpha;
real beta[K];
real<lower=0> sigma;
}

model {
alpha ~ normal(0, 10);
beta ~ normal(0, 10);
sigma ~ cauchy(0, 2.5);

for (t in (K+1):T) {
real mu;
mu = alpha;

for (k in 1:K)
mu = mu + beta[k] * y[t - k];

y[t] ~ normal(mu, sigma);
}
}
46 changes: 46 additions & 0 deletions examples/arK/arK.data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
K <- 5

T <- 200

y <- c(
0.7293852753, 0.8297635923, 0.7839527091, 1.0259589105, 0.9696824412,
1.0828859218, 0.7063891465, 0.7769243971, 0.4618029476, 0.6385997565,
0.3742344429, 0.0854966416, -0.1260149233, -0.2934151326, -0.2617308802,
-0.3359221372, -0.5019895766, -0.6417399532, -0.6224629523, -0.8508997238,
-0.8678351807, -1.0163853144, -1.0558901454, -0.9694812319, -1.0672519169,
-0.8430989055, -0.6827006149, -0.4446573489, -0.5920387090, -0.5105689815,
-0.4178858435, -0.1736168751, -0.1072500940, -0.0355025516, 0.3432168459,
0.3841903414, 0.4960876950, 0.7084511605, 0.5962806615, 0.6414424152,
0.6513222735, 0.5942153484, 0.7779414176, 0.7307762325, 0.4822472694,
0.5320372234, 0.4851022175, 0.3685521219, 0.3533268113, 0.1633690002,
0.2530389410, 0.0006621430, -0.0157674958, -0.0144909054, -0.0252628993,
-0.0056256128, -0.3189177332, -0.0227791612, -0.0716865707, -0.1850182514,
-0.2350075682, -0.1243111880, -0.1304923565, -0.1994777726, 0.0775739320,
-0.1628522111, 0.0234645663, -0.0646807914, 0.0845324981, 0.0550150773,
0.1417424074, 0.0876638222, -0.0528467198, 0.0695217092, -0.1014499970,
-0.0688806547, -0.2512073227, -0.3902872828, -0.1676283611, -0.2791635517,
-0.3121253506, -0.2865502547, -0.4117701622, -0.4982098458, -0.5028522787,
-0.7394004480, -0.2492280924, -0.4710158859, -0.4645727076, -0.4457058117,
-0.2844237121, -0.0227786998, -0.0605507196, 0.0662256249, 0.1405232927,
0.2763394882, 0.3772233671, 0.6103044598, 0.8808694697, 0.7885174270,
0.8013632395, 0.6609678195, 0.8097669196, 0.8205077274, 0.9807562966,
0.7240388847, 0.9318587166, 0.8504881551, 0.4805918638, 0.5085811342,
0.4161126092, 0.3146685518, -0.0281539189, -0.0717016521, -0.1439206592,
-0.5223661051, -0.4033621109, -0.6886329349, -0.6947170572, -0.6496557077,
-0.9926992981, -0.9354098817, -0.8969864546, -0.9781523572, -1.0668406080,
-0.9535621424, -0.7570773682, -0.8425755431, -0.6977697431, -0.3165581858,
-0.3878217300, -0.0671166462, -0.0385154999, 0.0895646813, 0.1454578935,
0.1852131654, 0.3956127617, 0.6852644284, 0.5563107812, 0.7108445288,
0.7462804690, 0.6684519285, 0.6936535333, 0.7379992741, 0.6627708128,
0.6900939802, 0.6807304694, 0.3733191989, 0.4536740601, 0.3137682260,
0.4500334320, -0.0337947734, 0.0047340737, -0.0856874439, 0.1082543270,
-0.1398269720, -0.0429735449, -0.4541637356, -0.3326428149, -0.2333534103,
-0.2014612607, -0.1826792426, -0.2278848137, -0.0415383584, -0.1210077677,
-0.0724354048, -0.0482025571, 0.1580149098, 0.0583926960, -0.1117559432,
-0.0381725259, 0.1789819529, -0.0148415779, 0.0500966207, -0.1980592117,
-0.1400114013, -0.1746734639, -0.1767850853, -0.2154143864, -0.4144745850,
-0.3405434088, -0.4482790416, -0.6571159536, -0.3546433053, -0.5257081174,
-0.6564372310, -0.5245263017, -0.4758655851, -0.3631316786, -0.3366915389,
-0.3254437415, 0.0006694692, 0.2080422414, 0.0023164951, 0.1124752107,
0.3494037146, 0.4717023945, 0.5906600432, 0.6048634064, 0.9331979099)

27 changes: 27 additions & 0 deletions examples/arK/arK.stan
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
data {
int<lower=0> K;
int<lower=0> T;
real y[T];
}

parameters {
real alpha;
real beta[K];
real<lower=0> sigma;
}

model {
alpha ~ normal(0, 10);
beta ~ normal(0, 10);
sigma ~ cauchy(0, 2.5);

for (t in (K+1):T) {
real mu;
mu = alpha;

for (k in 1:K)
mu = mu + beta[k] * y[t - k];

y[t] ~ normal(mu, sigma);
}
}
6 changes: 6 additions & 0 deletions examples/eight_schools/eight_schools.data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
J <- 8

y <- c(28, 8, -3, 7, -1, 1, 18, 12)

sigma <- c(15, 10, 16, 11, 9, 11, 10, 18)

21 changes: 21 additions & 0 deletions examples/eight_schools/eight_schools.stan
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
data {
int <lower=0> J; // number of schools
real y[J]; // estimated treatment
real<lower=0> sigma[J]; // std of estimated effect
}
parameters {
vector[J] theta_trans; // transformation of theta
real mu; // hyper-parameter of mean
real<lower=0> tau; // hyper-parameter of sd
}
transformed parameters{
vector[J] theta;
// original theta
theta=theta_trans*tau+mu;
}
model {
theta_trans ~ normal (0,1);
y ~ normal(theta , sigma);
mu ~ normal(0, 5); // a non-informative prior
tau ~ cauchy(0, 5);
}
37 changes: 37 additions & 0 deletions examples/garch-garch11/garch-garch11.data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
T <- 200
sigma1 <- 0.5
y <- c(
4.9376697, 4.8899168, 5.0254610, 4.3556765, 3.8357394, 6.4251189,
6.2174959, 5.3789445, 6.1202710, 5.1143114, 7.6245731, -1.8588047,
5.5093409, 6.4493257, 5.1634192, 3.4463904, 4.1698488, 4.1064708,
4.3614838, 5.9580466, 4.0459563, 3.1268747, 3.0014272, 7.2568532,
0.6181061, -0.1529171, 9.1520129, 4.2929169, 8.4797655, 3.4712109,
-0.7844602, 6.3643689, 7.3924605, 7.4482162, 7.9462958, 7.4520089,
4.9160684, 7.0783740, 2.2755717, 4.3338510, 5.3356670, 7.7133457,
3.8465556, 6.5227739, 3.8073106, 5.5854836, 4.0171510, 3.9905454,
5.3564230, 5.6389753, 5.8895307, 6.0430888, 7.0166372, 5.2398473,
7.5704829, 7.1371788, 5.0647421, 3.9293894, 3.4554177, 4.3275448,
8.2122458, 5.4182330, 4.7841770, 3.9840486, 8.2691524, 3.3376053,
2.0656949, 1.5275422, 1.8313308, 3.4272586, 10.6728548, 9.1516989,
5.0237735, 9.3370065, 6.2413672, 6.0495085, 5.1750646, 3.5839200,
2.5954829, 4.8390738, 3.9602637, 5.8275888, 4.2354627, 7.2289368,
2.6012532, 4.6906417, 1.9171748, 4.6100141, 5.4795416, 5.1599669,
6.1819383, 4.3444092, 4.4134581, 6.6869847, 3.3489950, 6.8327026,
4.1952444, 6.7873446, 3.3809638, 6.9186328, 3.6888826, 6.2622409,
3.4474512, 0.5621525, 12.0983927, -3.9476306, -3.2151898, 8.9190162,
6.9925151, 8.6113043, 0.7972950, 0.7407605, 6.6504390, -1.0102533,
6.0100541, 1.0596830, 6.8292719, 4.1636762, 5.1217723, 5.3588360,
2.9456964, 3.0978778, 4.2588637, 7.3676196, 2.1469861, 7.3753851,
4.8272418, 4.5120439, 5.7304457, 4.4193964, 2.7559061, 4.3644689,
7.1601115, 8.2984161, 2.8166543, 3.9179671, 9.7952480, -4.7242886,
5.4548679, 6.5446901, 6.5973368, 6.2416000, 3.0396850, 1.2093547,
5.2636842, 8.6437868, 7.4910598, 6.4736415, 4.5251063, 6.7226653,
4.9341330, 4.1566114, 4.5100764, 6.2950699, 3.1982652, 5.0967501,
3.2661672, 5.5375760, 6.2441927, 7.2051307, 3.0704887, 2.7454787,
0.9819569, 5.2894448, 3.8637890, 3.2133096, 5.9141655, 7.2122398,
5.7235900, 6.8712588, 2.7826501, 3.9139987, 5.8714783, 4.8225299,
6.4460635, 4.9013858, 4.7609188, 6.5644727, 2.6157804, 7.2306003,
4.3068921, 3.9418201, 8.9272450, 3.4283380, 1.1672301, 0.8543514,
12.1460656, -6.3507524, 7.7055931, 4.5136553, 4.9229184, 6.4621882,
0.2856913, 3.6447997, 6.2438314, 7.6303149, 8.8403182, 6.9152914,
4.1049014, 5.2848041)
24 changes: 24 additions & 0 deletions examples/garch-garch11/garch-garch11.stan
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* stan_code(posterior("garch-garch11", pdb = pd)) */
data {
int<lower=0> T;
real y[T];
real<lower=0> sigma1;
}

parameters {
real mu;
real<lower=0> alpha0;
real<lower=0, upper=1> alpha1;
real<lower=0, upper=(1-alpha1)> beta1;
}

model {
real sigma[T];
sigma[1] = sigma1;
for (t in 2:T)
sigma[t] = sqrt( alpha0
+ alpha1 * square(y[t - 1] - mu)
+ beta1 * square(sigma[t - 1]));

y ~ normal(mu, sigma);
}
Loading

0 comments on commit d4c69b0

Please sign in to comment.