Here is a description of my example. I am fitting my models on simulated data at this stage. Once i get a model that is working well enough I will make the attempt to apply it to real data. The model I am sharing here does not converge (I think too much latency, not enough data) so I have more work ahead of me. What I have loved about STAN so far is that it has enabled me to fail (so far) so quickly. Someone else tried a similar model using the EM algorithm and there was weeks of development time and several overnight runs to find out it didn't converge.
I want to predict the probability of a behaviour (e) displayed by entities. These entities are controlled by one or more directors. Each director has some level of desire (d) and opportunity (o) for the entity to carry out the behaviour. The e, d and o all emit some data x_e, x_d and x_o which I have set up as a regression relationship. Opportunity for a director (o) depends on desire of that director (d) and the behaviour (e) depends on the opportunity and desire of all directors. The behaviour (e) is observed as a binary variable (e-hat) I have attached a word document containing a DAG for this model.
My model assumes vague priors for all of the regression parameters. I assume a beta(1,1) for d. I use a beta prior for o where the parameters depend on d. I use a beta prior for e where the parameters depend on d and o.
I use rstan to fit this model. My session info is pasted in at the end of this post.
I attach an R-script that generates my data, defines my STAN code and runs the model.
Thanks for your interest.
Jon.
R version 3.0.1 (2013-05-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_New Zealand.1252 LC_CTYPE=English_New Zealand.1252 LC_MONETARY=English_New Zealand.1252
[4] LC_NUMERIC=C LC_TIME=English_New Zealand.1252
attached base packages:
[1] stats4 stats graphics grDevices utils datasets methods base
other attached packages:
[1] rstan_1.3.0 codetools_0.2-8 Rcpp_0.10.3 inline_0.3.11
loaded via a namespace (and not attached):
[1] tools_3.0.1
![]()