ebook img

Doubly Classified Model with R PDF

270 Pages·2018·5.319 MB·english
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Doubly Classified Model with R

Teck Kiang Tan fi Doubly Classi ed Model with R 123 Teck KiangTan Centrefor Skills, Performance andProductivity Institute for AdultLearning Singapore Singapore ISBN978-981-10-6994-9 ISBN978-981-10-6995-6 (eBook) https://doi.org/10.1007/978-981-10-6995-6 LibraryofCongressControlNumber:2017955661 ©SpringerNatureSingaporePteLtd.2017 ThisSpringerimprintispublishedbySpringerNature TheregisteredcompanyisSpringerNatureSingaporePteLtd. Theregisteredcompanyaddressis: 152BeachRoad,#21-01/04GatewayEast,Singapore189721,Singapore Foreword RichardBransononcesaid,“Thereisnogreaterthingyoucandowithyourlifeand work than to follow your passions in a way that serves the world and you.” As I supervised Teck as a graduate student and later observed his contributions to the world of research, I can truly see how this book is his heartfelt effort to help aspiring statisticians leverage on the affordances of statistics. He has done this in two profound ways. First, he noticed that despite the use- fulness of doubly classified models for categorical data analysis, it was under-discussedintextbooks.Thisledhimtoelaborateonawiderrangeofrelevant models;goingbeyondthecommonlydiscussedmodelslikeindependenceandquasi symmetry models. Second, as an active researcher, he realized that beyond under- standing the range of models available, the next step for any interested statistician would be to generate models for practical applications. Unfortunately, this would involvetheuseofstatistical software like SASorSPSS that isboth expensiveand not easily accessible. Cognizant that not everyone has access to research funds or software, Teck has taken pains to develop new syntax for generating model on Package R, a free statistical software that isgainingwidespread popularity. IamgladthatTeckhaswrittenthisbookbecauseitisnotjustaboutexplaining theintricaciesofonedoubleclassifiedmodeloveranotherbutitistohelpinterested students get an entry pass into this world and its possibilities. For example, Teck understands that not everyone is comfortable with mathematical symbols and has developed a “symbolic table” to help represent notations that are more complex. This symbolic table is a graphical tool to help readers understand the various models discussed. Although this book gives many tips and guidelines on how to develop double classified models, I can see how this book may also be useful for readers who are interested in learning about Package R and use the guided steps as a lesson of R’s functionalities. Whatever your purpose, I am sure that you would appreciate the examples included to illustrate concepts and its applications. Trivina Kang Office of Teacher Education (OTE), Policy & Leadership Studies (PLS), National Institute of Education Nanyang Technological University Singapore Preface ThemotivationinwritingthisbookcomesafterthepresentationofaposterattheR conference 2015 held at Denmark, Alborg, titled “Extending the Quasi-Symmetry Model: Quasi-Symmetry with n Degree.” I found that modeling doubly classified table is quite unknown to most conference attendees. Although there has been a dramatic growth in the development and application of doubly classified models, there is not a single book that is written in R on this subject. The applications on doubly classified modeling are also restricted to illustrate it using software like SPSSandSAS,appearedmostofteninjournalarticles(e.g.,Lawalandcolleagues). Doubly classified models are not commonly appeared in statistic textbooks. Even therearebookswrittenonthissubject,itisoftenrestrictedtoasectionoratmosta chapter.Thisisprobablytherighttimetoputthesemodelsinanorganizedwayinto a book for sharing. This book focuses on doubly classified models. The main aim of the book is to describedoublyclassifiedmodelsinawayreaderscaneasilyunderstand.Although mathematicalrepresentationsareunavoidableforpurposeofclarity,theyarealways accompanied with explanation in plain language. As doubly classified is probably not a familiar topic to a lot of people, including statisticians and data analysts, for those who have not heard of it, this book serves you well. You will find it a good startingpointtohaveabasicunderstandingaboutdoublyclassifiedmodels.Alotof examples accompanied the explanation are given in the text to illustrate the char- acteristics of the various doubly classified models. It is applied oriented however not losing its function as a basic textbook and reference. The formulas for the various doubly classified models are given, together with examples illustrating the concepts and usages. For those who are not familiar with doubly classified mod- elingwill findthisbookeasiertounderstand.Anewpresentation form,referredto assymbolic table, isused throughoutthetext asasummarized tabletoexplainthe main characteristics of doubly classified model. Researchers, data analysts, and undergraduateandpostgraduatestudentsaresuitedaudiencesandmostsuitablefor applied statisticians and researchers aim to use doubly classified model as an analytical tool for their studies. Singapore, Singapore Teck Kiang Tan September 2017 Contents 1 Introduction to R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1 What Is R?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Libraries in R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.3 Installing R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.4 Running R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.5 Installing Add-on Packages and Libraries. . . . . . . . . . . . . . . . . 4 1.6 Basic Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.6.1 Numeric. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.6.2 Integer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.6.3 Logical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.6.4 Character. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.7 Data Structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.7.1 Vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.7.2 Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 1.7.3 Data Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 1.7.4 List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 1.7.5 Factor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 1.8 Read File into R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 2 Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 2.1 Contingency, Square, and Doubly Classified Table. . . . . . . . . . 21 2.2 Generating Frequency Tables. . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.2.1 Tables from Vector . . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.2.2 Tables from Data Frame. . . . . . . . . . . . . . . . . . . . . . . 23 2.2.3 Margin Total and Proportion. . . . . . . . . . . . . . . . . . . . 24 2.2.4 xtab Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.2.5 Package gmodels, CrossTable Function . . . . . . . . . . . . 26 2.2.6 Package descr, CrossTable Function . . . . . . . . . . . . . . 26 2.3 Graphics for Tabulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 2.3.1 Bar Plot—Base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 2.3.2 Package ggplot2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.3.3 Package lattice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 2.4 Odds, Odds Ratios, Local Odds Ratios, and Margin . . . . . . . . . 30 2.4.1 Odds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.4.2 Properties and Interpretation of Odds. . . . . . . . . . . . . . 31 2.4.3 Odds Ratio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 2.4.4 Log Odds Ratio and Confidence Interval . . . . . . . . . . . 35 2.4.5 Margin Total . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 2.5 Applications of Doubly Classified Data . . . . . . . . . . . . . . . . . . 39 2.5.1 Studies on Pairs of Matched Individuals . . . . . . . . . . . 39 2.5.2 Association Between Two Essentially Similar Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 2.5.3 Two Point Longitudinal Study for a Common Variable. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 2.5.4 Inter-rater Agreement . . . . . . . . . . . . . . . . . . . . . . . . . 43 2.5.5 Two Indicators from a Scale. . . . . . . . . . . . . . . . . . . . 44 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 3 Examining Symmetry of Doubly Classified Table . . . . . . . . . . . . . . 49 3.1 McNemar’s Test of Symmetry. . . . . . . . . . . . . . . . . . . . . . . . . 50 3.2 Variations of McNemar’s Test. . . . . . . . . . . . . . . . . . . . . . . . . 51 3.2.1 Exact Binomial Test. . . . . . . . . . . . . . . . . . . . . . . . . . 51 3.2.2 Mid-P McNemar’s Test . . . . . . . . . . . . . . . . . . . . . . . 51 3.2.3 Which Test to Use? . . . . . . . . . . . . . . . . . . . . . . . . . . 54 3.3 Bower’s Test of Symmetry . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 3.4 Marginal Symmetry/Homogeneity Model . . . . . . . . . . . . . . . . . 56 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 4 Symmetry and Asymmetry Models. . . . . . . . . . . . . . . . . . . . . . . . . 63 4.1 Complete Symmetry Model. . . . . . . . . . . . . . . . . . . . . . . . . . . 63 4.1.1 Symbolic Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 4.1.2 Nonstandard Log-Linear Approach in Generating Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 4.1.3 Complete Symmetry Model—Nonstandard Log- Linear Specification . . . . . . . . . . . . . . . . . . . . . . . . . . 66 4.1.4 Properties of Complete Symmetry Model. . . . . . . . . . . 67 4.1.5 Function Model.Summary. . . . . . . . . . . . . . . . . . . . . . 68 4.1.6 A Detailed Illustration—The Dummy Specification . . . 73 4.2 Conditional Symmetry Model . . . . . . . . . . . . . . . . . . . . . . . . . 75 4.3 Odds Symmetry Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 4.3.1 Relationships of Complete Symmetry, Conditional Symmetry, Odds Symmetry I and II . . . . . . . . . . . . . . 86 4.4 Diagonal Parameters Symmetry Model. . . . . . . . . . . . . . . . . . . 87 4.4.1 Relationships of Complete Symmetry, Conditional Symmetry, and Diagonal Parameters Symmetry Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 4.5 Linear Diagonal Parameters Symmetry Model . . . . . . . . . . . . . 91 4.6 Quasi Symmetry Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 4.6.1 Relationship of Quasi Symmetry, Conditional Symmetry, and Complete Symmetry Models . . . . . . . . 97 4.7 Quasi Diagonal Parameters Symmetry Model. . . . . . . . . . . . . . 97 4.7.1 Relationships of Complete Symmetry, Conditional Symmetry, Quasi Symmetry, Diagonal Parameters Symmetry,andQuasiDiagonalParametersSymmetry Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 4.8 The 2-Ratios Parameters Symmetry Model. . . . . . . . . . . . . . . . 103 4.8.1 Relationships of Conditional Symmetry, Linear Diagonal Parameters Symmetry, and 2-Ratios Parameters Symmetry Models. . . . . . . . . . . . . . . . . . . 107 4.9 Quasi Conditional Symmetry Model . . . . . . . . . . . . . . . . . . . . 108 4.10 Quasi Odds Symmetry Model . . . . . . . . . . . . . . . . . . . . . . . . . 112 4.10.1 Relationships of Quasi Symmetry, Quasi Conditional Symmetry, and Quasi Odds Symmetry Models . . . . . . 116 4.10.2 Relationships of Odds Symmetry I, Odds Symmetry II, and Quasi Odds Symmetry Model . . . . . . . . . . . . . 116 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 5 Point Symmetry Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 5.1 Complete Point Symmetry Model . . . . . . . . . . . . . . . . . . . . . . 121 5.2 Inclined Point Symmetry Model . . . . . . . . . . . . . . . . . . . . . . . 126 5.3 Quasi Point Symmetry Model . . . . . . . . . . . . . . . . . . . . . . . . . 129 5.4 Quasi Inclined Point Symmetry Model. . . . . . . . . . . . . . . . . . . 131 5.5 Proportional Point Symmetry Model . . . . . . . . . . . . . . . . . . . . 135 5.5.1 Comparison of Proportional and Inclined Point Symmetry Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 5.6 Local Point Symmetry Model . . . . . . . . . . . . . . . . . . . . . . . . . 138 5.7 Reverse Local Point Symmetry Model . . . . . . . . . . . . . . . . . . . 140 5.8 Reverse Proportional Point Symmetry Model . . . . . . . . . . . . . . 142 5.9 Reverse Inclined Point Symmetry Model . . . . . . . . . . . . . . . . . 145 5.10 Quasi Reverse Inclined Point Symmetry Model . . . . . . . . . . . . 148 5.11 Reverse Conditional Symmetry . . . . . . . . . . . . . . . . . . . . . . . . 151 5.12 Quasi Reverse Conditional Symmetry Model . . . . . . . . . . . . . . 153 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 6 Non-independence Models. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 6.1 Independence and Non-independence Model . . . . . . . . . . . . . . 157 6.2 Principal Diagonal Models . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 6.2.1 Fixed Distance Model. . . . . . . . . . . . . . . . . . . . . . . . . 160 6.2.2 Variable Distance Model . . . . . . . . . . . . . . . . . . . . . . 162 6.3 Diagonal Band Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 6.3.1 Uniform Loyalty Model . . . . . . . . . . . . . . . . . . . . . . . 166 6.3.2 Quasi Independence Model. . . . . . . . . . . . . . . . . . . . . 169 6.3.3 Triangle Parameters Model . . . . . . . . . . . . . . . . . . . . . 172 6.4 Full Diagonal Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 6.4.1 Uniform Association Model . . . . . . . . . . . . . . . . . . . . 175 6.4.2 Diagonal D Model . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 6.4.3 Diagonal Absolute Model. . . . . . . . . . . . . . . . . . . . . . 180 6.4.4 Uniform Fixed Distance Association Model. . . . . . . . . 183 6.4.5 Uniform Variable Distance Association Model. . . . . . . 186 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 7 Asymmetry + Non-Independence Models . . . . . . . . . . . . . . . . . . . . 193 7.1 Non-Symmetry + Independence Model . . . . . . . . . . . . . . . . . . 193 7.2 Non-Symmetry + Independence Triangle Model. . . . . . . . . . . . 197 7.3 Non-Symmetry + Independence Diagonals Model. . . . . . . . . . . 199 7.4 Non-Symmetry + Independence Diagonals Absolute Model . . . 200 7.5 Non-Symmetry + Independence Diagonals Absolute Triangle Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 7.6 Non-Symmetry + Independence Models—Without Diagonal Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 8 Modeling Strategy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 8.1 Fit Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 8.2 Graphical Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 8.2.1 Heat Map Square Table . . . . . . . . . . . . . . . . . . . . . . . 210 8.2.2 Three-Dimensional Heat Map Bar Plot . . . . . . . . . . . . 214 8.2.3 Local Odds Ratio Square Table Heat Map Plot . . . . . . 217 8.2.4 Local Odds Ratio Square Table Three-dimensional Heat Map Bar Plot. . . . . . . . . . . . . . . . . . . . . . . . . . . 219 8.2.5 Package gplots Square Table Balloon Plot. . . . . . . . . . 220 8.2.6 Mosaic Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 Reference. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 9 Creating Doubly Classified Models . . . . . . . . . . . . . . . . . . . . . . . . . 225 9.1 Reverse Complete Symmetry Model . . . . . . . . . . . . . . . . . . . . 225 9.2 Parallel Diagonal Symmetry Model . . . . . . . . . . . . . . . . . . . . . 227 9.3 Quasi-Symmetry with N Degree Models . . . . . . . . . . . . . . . . . 229 Reference. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 10 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 10.1 Symbolic Table Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 10.2 R Syntax Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 10.3 Hierarchical Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 10.3.1 Hierarchical Tree—Asymmetry Models . . . . . . . . . . . . 250 10.3.2 Hierarchical Tree—Point Symmetry Models. . . . . . . . . 256 10.4 Nested Models—Chi-Square Difference Test . . . . . . . . . . . . . . 256 10.4.1 Chi-Square Difference Test—Complete Symmetry and Conditional Symmetry Model. . . . . . . . . . . . . . . . 256 10.4.2 Chi-Square Difference Test—Complete Point Symmetry and Inclined Point Symmetry Model . . . . . . 258 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 Index .... .... .... .... .... ..... .... .... .... .... .... ..... .... 263 Symbols n Observed frequency for cell(i, j) ij m Expected frequency for cell(i, j) ij m^ Fitted frequency for cell(i, j) ij (cid:1) (cid:3) lij Log of estimated frequency, ln m^ij p Probability for cell(i, j) ij D Expected group cells of upper diagonal upper D Expected group cells of lower diagonal lower X Odds 1(cid:1)pp(cid:4) dk dk ¼pij pji where k ¼j(cid:1)i s Log of odds, lnðdÞ hij Odds ratio, ^hij ¼mm^^ii;jjm^þ(cid:1)i1þm^1i;jþ(cid:3)þ11;j Uij Log of odds ratio ln hij X H ðij;stÞ ðij;stÞ H ðst;ijÞ Hðij;stÞ ppisppjt js it

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.