
An Advanced User’s Guide to Stat-JR version 1.0.1 Programming and Documentation by William J. Browne, Christopher M.J. Charlton, Danius T. Michaelides*, Richard M.A. Parker, Bruce Cameron, Camille Szmaragd, Huanjia Yang*, Zhengzheng Zhang, Harvey Goldstein, Kelvyn Jones, George Leckie and Luc Moreau* Centre for Multilevel Modelling, University of Bristol. *Electronics and Computer Science, University of Southampton. March 2014 i An Advanced User’s Guide to Stat-JR version 1.0.1 © 2014. William J. Browne, Christopher M.J. Charlton, Danius T. Michaelides, Richard M.A. Parker, Bruce Cameron, Camille Szmaragd, Huanjia Yang, Zhengzheng Zhang, Harvey Goldstein, Kelvyn Jones, George Leckie and Luc Moreau. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, for any purpose other than the owner's personal use, without the prior written permission of one of the copyright holders. ISBN: To be confirmed Printed in the United Kingdom ii Contents 1. About Stat-JR ................................................................................................................................... 1 1.1 Stat-JR: software for scaling statistical heights. ..................................................................... 1 1.2 About the Advanced User’s Guide .......................................................................................... 2 2 Installation instructions .................................................................................................................. 3 3 A simple regression template example ........................................................................................... 4 3.1 Running a first template ......................................................................................................... 4 3.2 Opening the bonnet and looking at the code ......................................................................... 8 3.2.1 Inputs ................................................................................................................................... 10 3.2.2 Model ................................................................................................................................... 11 3.2.3 Latex ..................................................................................................................................... 13 3.2.4 Some points to note ............................................................................................................. 14 3.3 Writing your own first template ........................................................................................... 15 4 Running templates with the eStat engine .................................................................................... 15 4.1 Algebra and Code Generation ..................................................................................................... 15 4.2 The algebraic software system ................................................................................................... 22 5 Including Interoperability .............................................................................................................. 25 5.1 eStat.py ....................................................................................................................................... 26 5.2 Regression2.py ............................................................................................................................ 27 5.3 WinBUGS and Winbugsscript.py ................................................................................................. 27 5.4 MLwiN ......................................................................................................................................... 31 5.5 R .................................................................................................................................................. 36 5.6 Other packages ........................................................................................................................... 42 6 Input, Data manipulation and output templates .......................................................................... 43 6.1 Generate template (generate.py) ............................................................................................... 43 6.2 Recode template (recode.py) ..................................................................................................... 47 6.3 AverageAndCorrelation template ............................................................................................... 49 iii 6.4 XYPlot template .......................................................................................................................... 52 7 Single level models of all flavours – A logistic regression example .............................................. 54 7.1 Inputs .......................................................................................................................................... 56 7.2 Engines ........................................................................................................................................ 57 7.3 Model .......................................................................................................................................... 58 7.4 Latex ............................................................................................................................................ 59 8 Including categorical predictors .................................................................................................... 60 9 Multilevel models ......................................................................................................................... 64 9.1 2LevelMod template ................................................................................................................... 64 9.2 NLevelMod template .................................................................................................................. 68 10 Using the Preccode method ...................................................................................................... 74 10.1 The 1LevelProbitRegression template ...................................................................................... 74 10.3 preccode and deviancecode attributes .................................................................................... 77 11 Multilevel models with Random slopes and the inclusion of Wishart priors ........................... 80 11.1 An example with random slopes .............................................................................................. 80 11.2 Preccode for NLevelRS .............................................................................................................. 84 12 Improving mixing (1LevelBlock and 1LevelOrthogParam) ........................................................ 87 12.1 Rats example ............................................................................................................................. 87 12.2 The 1LevelBlock template ......................................................................................................... 89 12.3 The 1LevelOrthogParam template ............................................................................................ 91 12.4 Multivariate Normal response models ..................................................................................... 95 12.5 The preccode function for this template .................................................................................. 98 13 Out of sample predictions ....................................................................................................... 103 13.1 The 1LevelOutSampPred template – using the zxfd trick ....................................................... 104 14 Solutions to the exercises .............................................................................................................. 106 References .......................................................................................................................................... 107 iv Acknowledgements The Stat-JR software is very much a team effort and is the result of work funded under three ESRC grants: the LEMMA 2 and LEMMA 3 programme nodes (Grant: RES-576-25-0003 & Grant:RES-576- 25-0032) as part of the National Centre for Research Methods programme, and the e-STAT node (Grant: RES-149-25-1084) as part of the Digital Social Research programme. We are therefore grateful to the ESRC for financial support to allow us to produce this software. All nodes have many staff that, for brevity, we have not included in the list on the cover. We acknowledge therefore the contributions of: Fiona Steele, Rebecca Pillinger, Paul Clarke, Mark Lyons-Amos, Liz Washbrook, Sophie Pollard, Robert French, Nikki Hicks, Mary Takahama and Hilary Browne from the LEMMA nodes at the Centre for Multilevel Modelling. David De Roure, Tao Guan, Alex Fraser, Toni Price, Mac McDonald, Ian Plewis, Mark Tranmer, Pierre Walthery, Paul Lambert, Emma Housley, Kristina Lupton and Antonina Timofejeva from the e-STAT node. A final acknowledgement to Jon Rasbash who was instrumental in the concept and initial work of this project. We miss you and hope that the finished product is worthy of your initials. WJB November 2013. v 1. About Stat-JR 1.1 Stat-JR: software for scaling statistical heights. The use of statistical modelling by researchers in all disciplines is
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages112 Page
-
File Size-