Skip to main content

Posts

Showing posts with the label rm

Bayesian Approach to Analyse Oneway RM ANOVA

Last post I analysed the fake data set using frequentists approach.  This time, I will use the Bayesian method to analyse the same data set by using Kruschkes code (which you may be able to download from Kruschkes blog).  The result will cross-examine against the frequentists approach to see if they show consistently result (supposedly we should get the same conclusion, because the difference is quite big). First I loaded the data and did some pre-processes.  I modified Kruschkes code a bit, because my machine is operated by Linux.  Also remember to load rjags, so you can use BUGS and JAGS directly by calling it in R.  tab14 . 3 < - read . table ( " tab14.3.txt " , header = T ) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Bayesian RM - ANOVA # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - fileNameRoot = " ANOVAonewayJagsWithinSubj " # for constructing output filenames if ( . Platform $OS . type ! = " unix ...

Bayesian Approach to Analyse Oneway RM ANOVA II

After finishing the model specification, I went back to the R environment and stored data from the data frame, tab14.3 , into several independent vectors. # Load the data : y = tab14 . 3$Score x1 = tab14 . 3$Wk S = tab14 . 3$Subj x1names = unique ( tab14 . 3$Wk ) Snames = unique ( tab14 . 3$Subj ) Ntotal = length ( y ) Nx1Lvl = length ( unique ( x1 ) ) NSLvl = length ( unique ( S ) ) The above codes extract dependent variable (y) and independent variables (x1 and S) and store them into separate vectors.  The label for each level of the two independent variables were assigned to x1names and Snames , respectively. For the BUGS code, i and j1, I also created the variables, Ntotal, Nx1Lv1 and NSLv1.  Later, they were sent as a data list to BUGS.   ySDorig = sd ( y ) yMorig = mean ( y ) z = ( y - yMorig ) / ySDorig dataList = list ( y = z , x1 = x1 , S = S , Ntotal = Ntotal , Nx1Lvl = Nx1Lvl , NSLvl = NSLvl ) This step converted the predic...