Last active
August 29, 2015 14:03
-
-
Save jrnold/78594018af5b8aa36652 to your computer and use it in GitHub Desktop.
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
data { | |
int jj_n; | |
int jj_idx[jj_n]; | |
int jj_groups[jj_n]; | |
... | |
} | |
parameters { | |
vector[3] beta; | |
... | |
} | |
model { | |
beta ~ normal(0, 10); | |
for (i in 1:jj_n) { | |
y[jj_idx[i]] ~ normal(beta[jj_groups[i]] * x[jj_idx[i]], sigma); | |
} | |
... | |
} |
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
jj<-c(1,2,3,NA,NA,NA,1,2,3,NA,NA,NA,1,2,3) | |
jj_n <- sum(!is.na(jj)) | |
jj_idx <- which(!is.na(jj)) | |
jj_groups <- jj[!is.na(jj)] |
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
data { | |
int n_groups; | |
int beta2_const_n; | |
int beta2_const_idx[beta2_obs_n]; | |
int beta2_param_n; | |
int beta2_param_idx[beta2_obs_n]; | |
} | |
parameters { | |
vector[n_groups] beta1; | |
vector[beta2_n_obs] beta2_param; | |
... | |
} | |
transformed parameters { | |
vector[N] p; | |
vector[n_groups] beta2; | |
for (i in 1:beta2_const_n) { | |
beta2[beta2_const_idx[i]] <- 0.0; | |
} | |
for (i in 1:beta2_param_n) { | |
beta2[beta2_param_idx[i]] <- beta2_param[i]; | |
} | |
for (i in 1:N) { | |
p[i] <- beta1[kk[n]] * x1[gg[n]]] + beta2[kk[n]] * x2[gg[n]]; | |
} | |
... | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment