-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vianey Leos Barajas
authored
Jun 20, 2020
1 parent
7a09c08
commit 2a868df
Showing
9 changed files
with
281 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// The input data is a vector 'y' of length 'TT'. | ||
data { | ||
int<lower=1> TT; | ||
int y[TT]; | ||
|
||
int ncov; | ||
matrix[TT, ncov + 1] x; | ||
} | ||
|
||
parameters { | ||
//real<lower=0, upper=1> p; | ||
vector[ncov + 1] beta; | ||
} | ||
|
||
model { | ||
//p ~ uniform(0, 1); | ||
beta ~ normal(0, 0.5); | ||
y ~ bernoulli_logit(x*beta); | ||
} | ||
|
Binary file not shown.
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// The input data is a vector 'y' of length 'TT'. | ||
data { | ||
int<lower=1> TT; | ||
int y[TT]; | ||
|
||
int ncov; | ||
matrix[TT, ncov] x; | ||
|
||
vector[TT] bsize; | ||
vector[TT] sex; | ||
} | ||
|
||
parameters { | ||
//real<lower=0, upper=1> p; | ||
vector[ncov] beta; | ||
vector[3] alpha; | ||
} | ||
|
||
model { | ||
|
||
// Priors | ||
beta ~ normal(0, 0.5); | ||
alpha[1] ~ normal(0, 0.5); | ||
alpha[2] ~ normal(0, 0.5); | ||
//values range from -40 to 40 | ||
alpha[3] ~ normal(0, 0.1); | ||
|
||
y ~ bernoulli_logit(alpha[1] + alpha[2]*sex + alpha[3]*bsize + x*beta); | ||
} | ||
|
Binary file not shown.
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// The input data is a vector 'y' of length 'TT'. | ||
data { | ||
int<lower=1> TT; | ||
int y[TT]; | ||
|
||
int sexmissing[TT]; | ||
int ncov; | ||
matrix[TT, ncov] x; | ||
|
||
vector[TT] bsize; | ||
vector[TT] sex; | ||
} | ||
|
||
parameters { | ||
//real<lower=0, upper=1> p; | ||
vector[ncov] beta; | ||
vector[3] alpha; | ||
real<lower=0, upper=1> pi; | ||
} | ||
|
||
model { | ||
|
||
// Priors | ||
beta ~ normal(0, 0.5); | ||
alpha[1] ~ normal(0, 0.5); | ||
alpha[2] ~ normal(0, 0.5); | ||
//values range from -40 to 40 | ||
alpha[3] ~ normal(0, 0.1); | ||
|
||
for(t in 1:TT){ | ||
if(sexmissing[t] == 1){ | ||
target += log_mix(pi, | ||
bernoulli_logit_lpmf(y[t] | alpha[1] + | ||
alpha[3]*bsize + | ||
x[t]*beta), | ||
bernoulli_logit_lpmf(y[t] | alpha[1] + | ||
alpha[2] + | ||
alpha[3]*bsize[t] + | ||
x[t]*beta)); | ||
} else { | ||
y[t] ~ bernoulli_logit(alpha[1] + | ||
alpha[2]*sex[t] + | ||
alpha[3]*bsize[t] + | ||
x[t]*beta); | ||
} | ||
} | ||
} | ||
|
Binary file not shown.
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// The input data is a vector 'y' of length 'TT'. | ||
data { | ||
int<lower=1> TT; | ||
int y[TT]; | ||
|
||
int ncov; | ||
matrix[TT, ncov] x; | ||
|
||
vector[TT] bsize; | ||
vector[TT] sex; | ||
|
||
int nsharks; | ||
int sharkid[TT]; | ||
} | ||
|
||
parameters { | ||
//real<lower=0, upper=1> p; | ||
vector[ncov] beta[nsharks]; | ||
vector[3] alpha; | ||
|
||
real mu; | ||
real<lower=0> stdev; | ||
|
||
} | ||
|
||
model { | ||
|
||
// Priors | ||
mu ~ normal(0, 0.1); | ||
stdev ~ normal(0, 0.1); // by default, this is the half-normal (because stdev > 0) | ||
|
||
|
||
alpha[1] ~ normal(0, 0.5); | ||
alpha[2] ~ normal(0, 0.5); | ||
//values range from -40 to 40 | ||
alpha[3] ~ normal(0, 0.1); | ||
|
||
for(n in 1:nsharks){ | ||
beta[n] ~ normal(mu, stdev); | ||
} | ||
|
||
for(t in 1:TT){ | ||
y[t] ~ bernoulli_logit(alpha[1] + alpha[2]*sex[t] + alpha[3]*bsize[t] + x[t]*beta[sharkid[t]]); | ||
} | ||
|
||
} | ||
|
This file contains 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 characters
This file contains 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 characters