R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- array(list(12 + ,53 + ,11 + ,86 + ,14 + ,66 + ,12 + ,67 + ,21 + ,76 + ,12 + ,78 + ,22 + ,53 + ,11 + ,80 + ,10 + ,74 + ,13 + ,76 + ,10 + ,79 + ,8 + ,54 + ,15 + ,67 + ,14 + ,54 + ,10 + ,87 + ,14 + ,58 + ,14 + ,75 + ,11 + ,88 + ,10 + ,64 + ,13 + ,57 + ,7 + ,66 + ,14 + ,68 + ,12 + ,54 + ,14 + ,56 + ,11 + ,86 + ,9 + ,80 + ,11 + ,76 + ,15 + ,69 + ,14 + ,78 + ,13 + ,67 + ,9 + ,80 + ,15 + ,54 + ,10 + ,71 + ,11 + ,84 + ,13 + ,74 + ,8 + ,71 + ,20 + ,63 + ,12 + ,71 + ,10 + ,76 + ,10 + ,69 + ,9 + ,74 + ,14 + ,75 + ,8 + ,54 + ,14 + ,52 + ,11 + ,69 + ,13 + ,68 + ,9 + ,65 + ,11 + ,75 + ,15 + ,74 + ,11 + ,75 + ,10 + ,72 + ,14 + ,67 + ,18 + ,63 + ,14 + ,62 + ,11 + ,63 + ,12 + ,76 + ,13 + ,74 + ,9 + ,67 + ,10 + ,73 + ,15 + ,70 + ,20 + ,53 + ,12 + ,77 + ,12 + ,77 + ,14 + ,52 + ,13 + ,54 + ,11 + ,80 + ,17 + ,66 + ,12 + ,73 + ,13 + ,63 + ,14 + ,69 + ,13 + ,67 + ,15 + ,54 + ,13 + ,81 + ,10 + ,69 + ,11 + ,84 + ,19 + ,80 + ,13 + ,70 + ,17 + ,69 + ,13 + ,77 + ,9 + ,54 + ,11 + ,79 + ,10 + ,30 + ,9 + ,71 + ,12 + ,73 + ,12 + ,72 + ,13 + ,77 + ,13 + ,75 + ,12 + ,69 + ,15 + ,54 + ,22 + ,70 + ,13 + ,73 + ,15 + ,54 + ,13 + ,77 + ,15 + ,82 + ,10 + ,80 + ,11 + ,80 + ,16 + ,69 + ,11 + ,78 + ,11 + ,81 + ,10 + ,76 + ,10 + ,76 + ,16 + ,73 + ,12 + ,85 + ,11 + ,66 + ,16 + ,79 + ,19 + ,68 + ,11 + ,76 + ,16 + ,71 + ,15 + ,54 + ,24 + ,46 + ,14 + ,82 + ,15 + ,74 + ,11 + ,88 + ,15 + ,38 + ,12 + ,76 + ,10 + ,86 + ,14 + ,54 + ,13 + ,70 + ,9 + ,69 + ,15 + ,90 + ,15 + ,54 + ,14 + ,76 + ,11 + ,89 + ,8 + ,76 + ,11 + ,73 + ,11 + ,79 + ,8 + ,90 + ,10 + ,74 + ,11 + ,81 + ,13 + ,72 + ,11 + ,71 + ,20 + ,66 + ,10 + ,77 + ,15 + ,65 + ,12 + ,74 + ,14 + ,82 + ,23 + ,54 + ,14 + ,63 + ,16 + ,54 + ,11 + ,64 + ,12 + ,69 + ,10 + ,54 + ,14 + ,84 + ,12 + ,86 + ,12 + ,77 + ,11 + ,89 + ,12 + ,76 + ,13 + ,60 + ,11 + ,75 + ,19 + ,73 + ,12 + ,85 + ,17 + ,79 + ,9 + ,71 + ,12 + ,72 + ,19 + ,69 + ,18 + ,78 + ,15 + ,54 + ,14 + ,69 + ,11 + ,81 + ,9 + ,84 + ,18 + ,84 + ,16 + ,69) + ,dim=c(2 + ,162) + ,dimnames=list(c('Depression' + ,'Belonging') + ,1:162)) > y <- array(NA,dim=c(2,162),dimnames=list(c('Depression','Belonging'),1:162)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = 'Pearson Chi-Squared' > par2 = '2' > par1 = '1' > main = 'Association Plot' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Dr. Ian E. Holliday > #To cite this work: Ian E. Holliday, 2009, YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: > #Technical description: > library(vcd) Loading required package: MASS Loading required package: grid Loading required package: colorspace > cat1 <- as.numeric(par1) # > cat2<- as.numeric(par2) # > simulate.p.value=FALSE > if (par3 == 'Exact Pearson Chi-Squared by Simulation') simulate.p.value=TRUE > x <- t(x) > (z <- array(unlist(x),dim=c(length(x[,1]),length(x[1,])))) [,1] [,2] [1,] 12 53 [2,] 11 86 [3,] 14 66 [4,] 12 67 [5,] 21 76 [6,] 12 78 [7,] 22 53 [8,] 11 80 [9,] 10 74 [10,] 13 76 [11,] 10 79 [12,] 8 54 [13,] 15 67 [14,] 14 54 [15,] 10 87 [16,] 14 58 [17,] 14 75 [18,] 11 88 [19,] 10 64 [20,] 13 57 [21,] 7 66 [22,] 14 68 [23,] 12 54 [24,] 14 56 [25,] 11 86 [26,] 9 80 [27,] 11 76 [28,] 15 69 [29,] 14 78 [30,] 13 67 [31,] 9 80 [32,] 15 54 [33,] 10 71 [34,] 11 84 [35,] 13 74 [36,] 8 71 [37,] 20 63 [38,] 12 71 [39,] 10 76 [40,] 10 69 [41,] 9 74 [42,] 14 75 [43,] 8 54 [44,] 14 52 [45,] 11 69 [46,] 13 68 [47,] 9 65 [48,] 11 75 [49,] 15 74 [50,] 11 75 [51,] 10 72 [52,] 14 67 [53,] 18 63 [54,] 14 62 [55,] 11 63 [56,] 12 76 [57,] 13 74 [58,] 9 67 [59,] 10 73 [60,] 15 70 [61,] 20 53 [62,] 12 77 [63,] 12 77 [64,] 14 52 [65,] 13 54 [66,] 11 80 [67,] 17 66 [68,] 12 73 [69,] 13 63 [70,] 14 69 [71,] 13 67 [72,] 15 54 [73,] 13 81 [74,] 10 69 [75,] 11 84 [76,] 19 80 [77,] 13 70 [78,] 17 69 [79,] 13 77 [80,] 9 54 [81,] 11 79 [82,] 10 30 [83,] 9 71 [84,] 12 73 [85,] 12 72 [86,] 13 77 [87,] 13 75 [88,] 12 69 [89,] 15 54 [90,] 22 70 [91,] 13 73 [92,] 15 54 [93,] 13 77 [94,] 15 82 [95,] 10 80 [96,] 11 80 [97,] 16 69 [98,] 11 78 [99,] 11 81 [100,] 10 76 [101,] 10 76 [102,] 16 73 [103,] 12 85 [104,] 11 66 [105,] 16 79 [106,] 19 68 [107,] 11 76 [108,] 16 71 [109,] 15 54 [110,] 24 46 [111,] 14 82 [112,] 15 74 [113,] 11 88 [114,] 15 38 [115,] 12 76 [116,] 10 86 [117,] 14 54 [118,] 13 70 [119,] 9 69 [120,] 15 90 [121,] 15 54 [122,] 14 76 [123,] 11 89 [124,] 8 76 [125,] 11 73 [126,] 11 79 [127,] 8 90 [128,] 10 74 [129,] 11 81 [130,] 13 72 [131,] 11 71 [132,] 20 66 [133,] 10 77 [134,] 15 65 [135,] 12 74 [136,] 14 82 [137,] 23 54 [138,] 14 63 [139,] 16 54 [140,] 11 64 [141,] 12 69 [142,] 10 54 [143,] 14 84 [144,] 12 86 [145,] 12 77 [146,] 11 89 [147,] 12 76 [148,] 13 60 [149,] 11 75 [150,] 19 73 [151,] 12 85 [152,] 17 79 [153,] 9 71 [154,] 12 72 [155,] 19 69 [156,] 18 78 [157,] 15 54 [158,] 14 69 [159,] 11 81 [160,] 9 84 [161,] 18 84 [162,] 16 69 > (table1 <- table(z[,cat1],z[,cat2])) 30 38 46 52 53 54 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 9 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 1 0 2 0 0 1 0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 0 0 0 0 15 0 0 0 0 0 1 0 0 0 0 0 0 1 16 0 0 1 0 0 0 0 0 0 0 0 0 0 17 0 0 1 0 0 0 0 0 0 0 0 0 0 18 0 1 0 0 0 0 1 0 0 0 0 0 0 19 0 0 0 1 0 0 0 0 0 0 0 0 0 20 0 0 0 0 0 0 0 0 0 0 0 0 0 21 0 0 0 0 0 0 0 0 0 0 0 0 0 22 0 0 0 0 0 0 0 0 0 0 0 0 0 23 0 0 0 0 0 0 0 0 0 0 0 0 0 24 0 0 0 0 0 0 0 0 0 0 0 0 0 > (V1<-dimnames(y)[[1]][cat1]) [1] "Depression" > (V2<-dimnames(y)[[1]][cat2]) [1] "Belonging" > postscript(file="/var/wessaorg/rcomp/tmp/1b9g41323855463.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > assoc(ftable(z[,cat1],z[,cat2],row.vars=1,dnn=c(V1,V2)),shade=T) > dev.off() null device 1 > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Tabulation of Results',ncol(table1)+1,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,paste(V1,' x ', V2),ncol(table1)+1,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, ' ', 1,TRUE) > for(nc in 1:ncol(table1)){ + a<-table.element(a, colnames(table1)[nc], 1, TRUE) + } > a<-table.row.end(a) > for(nr in 1:nrow(table1) ){ + a<-table.element(a, rownames(table1)[nr], 1, TRUE) + for(nc in 1:ncol(table1) ){ + a<-table.element(a, table1[nr, nc], 1, FALSE) + } + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/2uhi01323855463.tab") > (cst<-chisq.test(table1, simulate.p.value=simulate.p.value) ) Pearson's Chi-squared test data: table1 X-squared = 699.3441, df = 629, p-value = 0.02665 Warning message: In chisq.test(table1, simulate.p.value = simulate.p.value) : Chi-squared approximation may be incorrect > if (par3 == 'McNemar Chi-Squared') { + (cst <- mcnemar.test(table1)) + } > if (par3=='Fisher Exact Test') { + (cst <- fisher.test(table1)) + } > if ((par3 != 'McNemar Chi-Squared') & (par3 != 'Fisher Exact Test')) { + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Tabulation of Expected Results',ncol(table1)+1,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,paste(V1,' x ', V2),ncol(table1)+1,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a, ' ', 1,TRUE) + for(nc in 1:ncol(table1)){ + a<-table.element(a, colnames(table1)[nc], 1, TRUE) + } + a<-table.row.end(a) + for(nr in 1:nrow(table1) ){ + a<-table.element(a, rownames(table1)[nr], 1, TRUE) + for(nc in 1:ncol(table1) ){ + a<-table.element(a, round(cst$expected[nr, nc], digits=2), 1, FALSE) + } + a<-table.row.end(a) + } + a<-table.end(a) + table.save(a,file="/var/wessaorg/rcomp/tmp/3eitt1323855463.tab") + } > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Statistical Results',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, cst$method, 2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > if (par3=='Pearson Chi-Squared') a<-table.element(a, 'Pearson Chi Square Statistic', 1, TRUE) > if (par3=='Exact Pearson Chi-Squared by Simulation') a<-table.element(a, 'Exact Pearson Chi Square Statistic', 1, TRUE) > if (par3=='McNemar Chi-Squared') a<-table.element(a, 'McNemar Chi Square Statistic', 1, TRUE) > if (par3=='Fisher Exact Test') a<-table.element(a, 'Odds Ratio', 1, TRUE) > if (par3=='Fisher Exact Test') { + if ((ncol(table1) == 2) & (nrow(table1) == 2)) { + a<-table.element(a, round(cst$estimate, digits=2), 1,FALSE) + } else { + a<-table.element(a, '--', 1,FALSE) + } + } else { + a<-table.element(a, round(cst$statistic, digits=2), 1,FALSE) + } > a<-table.row.end(a) > if(!simulate.p.value){ + if(par3!='Fisher Exact Test') { + a<-table.row.start(a) + a<-table.element(a, 'Degrees of Freedom', 1, TRUE) + a<-table.element(a, cst$parameter, 1,FALSE) + a<-table.row.end(a) + } + } > a<-table.row.start(a) > a<-table.element(a, 'P value', 1, TRUE) > a<-table.element(a, round(cst$p.value, digits=2), 1,FALSE) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/4ibxr1323855463.tab") > > try(system("convert tmp/1b9g41323855463.ps tmp/1b9g41323855463.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 6.769 0.145 6.925