I looked in previous posts but couldn't see this question posted before: Is it possible to make a withinsubjects version of the "FilconCoKappaJags" code? Any suggestion would be helpful.
model { for ( subjIdx in 1:nSubj ) { # Likelihood: z[subjIdx] ~ dbin( theta[subjIdx] , N[subjIdx] ) # Prior on theta: Notice nested indexing. theta[subjIdx] ~ dbeta( a[cond[subjIdx]] , b[cond[subjIdx]] )T(0.001,0.999) } for ( condIdx in 1:nCond ) { a[condIdx] < mu[condIdx] * kappa[condIdx] b[condIdx] < (1mu[condIdx]) * kappa[condIdx] # Hyperprior on mu and kappa: mu[condIdx] ~ dbeta( Amu , Bmu ) kappa[condIdx] ~ dgamma( Skappa , Rkappa ) } # Constants for hyperprior: Amu < 1 Bmu < 1 Skappa < pow(meanGamma,2)/pow(sdGamma,2) Rkappa < meanGamma/pow(sdGamma,2) meanGamma ~ dunif( 0.01 , 30 ) sdGamma ~ dunif( 0.01 , 30 ) } 
Administrator

Hi Ulf.
Withinsubject designs are challenging because there are multiple ways to approach them, depending on how the data are arranged within subjects. Ideally, there are lots of data collected within each subject, so that each subject can be modeled individually with a fullyparameterized model. Then you can put higherlevel distributions over the individualsubject parameters to get some shrinkage informed by other subjects. Conceptually, this is the most straightforward approach. An example in DBDA is the hierarchical linear regression for the data in Fig. 16.10. In that example, each subject was modeled with linear regression, and then there were higher level distributions put over the individual parameters. This kind of approach can be taken for ANOVAstyle models too. For simplicity, you might not want to put a shrinkage prior within every individual, as the model gets unwieldy (in code and concept). Thus, for every individual, estimate the deflection parameters, but maybe do not estimate the variance of the deflections within subjects. Instead put a higherlevel distribution on the corresponding deflections across subjects. But there is no uniquely "correct" model  after all, we're just trying to meaningfully and accurately describe the data. So, you could include an estimated individualsubject deflection variance, but put an acrosssubject higherlevel distribution for shrinkage. If you have only a single datum per cell within each subject, then you cannot use a fullyparameterized model for every subject, because the parameters are not identifiable (i.e., the interaction term absorbs all the noise variance). Then you have to decide on some other model (see, e.g., the "split plot" design in the blog). On Fri, Sep 27, 2013 at 8:54 AM, Ulf Ahlstrom [via Doing Bayesian Data Analysis] <[hidden email]> wrote: I looked in previous posts but couldn't see this question posted before: Is it possible to make a withinsubjects version of the "FilconCoKappaJags" code? Any suggestion would be helpful. 
Free forum by Nabble  Edit this page 