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('F' + ,'Underestimate' + ,'F' + ,'Overestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Overestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Overestimate' + ,'F' + ,'Overestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Accurate' + ,'F' + ,'Accurate' + ,'F' + ,'Overestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Underestimate' + ,'F' + ,'Overestimate' + ,'F' + ,'Overestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Accurate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Overestimate' + ,'F' + ,'Overestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Overestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Overestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Overestimate' + ,'F' + ,'Overestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Accurate' + ,'F' + ,'Overestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Overestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Accurate' + ,'F' + ,'Accurate' + ,'F' + ,'Accurate' + ,'F' + ,'Accurate' + ,'F' + ,'Overestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Underestimate' + ,'F' + ,'Overestimate' + ,'F' + ,'Overestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Accurate' + ,'F' + ,'Accurate' + ,'F' + ,'Overestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Accurate' + ,'F' + ,'Accurate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Underestimate' + ,'F' + ,'Overestimate' + ,'F' + ,'Overestimate' + ,'F' + ,'Overestimate' + ,'F' + ,'Overestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Accurate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Overestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Underestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Underestimate' + ,'F' + ,'Accurate' + ,'F' + ,'Accurate' + ,'F' + ,'Underestimate' + ,'M' + ,'Accurate' + ,'M' + ,'Overestimate' + ,'M' + ,'Accurate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Accurate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Accurate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Accurate' + ,'M' + ,'Overestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Accurate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Accurate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Accurate' + ,'M' + ,'Overestimate' + ,'M' + ,'Accurate' + ,'M' + ,'Accurate' + ,'M' + ,'Accurate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Accurate' + ,'M' + ,'Overestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Accurate' + ,'M' + ,'Underestimate' + ,'M' + ,'Accurate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Underestimate' + ,'M' + ,'Overestimate' + ,'M' + ,'Overestimate') + ,dim=c(2 + ,182) + ,dimnames=list(c('Gender' + ,'Estimate') + ,1:182)) > y <- array(NA,dim=c(2,182),dimnames=list(c('Gender','Estimate'),1:182)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } There were 50 or more warnings (use warnings() to see the first 50) > par3 = 'Pearson Chi-Square' > par2 = '2' > par1 = '1' > par3 <- 'Pearson Chi-Square' > par2 <- '2' > par1 <- '1' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: aston2 > #To cite this work: Ian E. Holliday, 2012, STARS Bullying Study (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/Ian.Holliday/rwasp_STARS_Bullying_Study_alt.wasp/ > #Source of accompanying publication: > # > cat1 <- as.numeric(par1) # > cat2<- as.numeric(par2) # > simulate.p.value=FALSE > if (par3 == 'Exact Pearson Chi Square by simulation') simulate.p.value=TRUE > x <- t(x) > (z <- array(unlist(x),dim=c(length(x[,1]),length(x[1,])))) [,1] [,2] [1,] "F" "Underestimate" [2,] "F" "Overestimate" [3,] "F" "Accurate" [4,] "F" "Overestimate" [5,] "F" "Accurate" [6,] "F" "Overestimate" [7,] "F" "Overestimate" [8,] "F" "Accurate" [9,] "F" "Accurate" [10,] "F" "Accurate" [11,] "F" "Overestimate" [12,] "F" "Accurate" [13,] "F" "Underestimate" [14,] "F" "Overestimate" [15,] "F" "Overestimate" [16,] "F" "Accurate" [17,] "F" "Accurate" [18,] "F" "Underestimate" [19,] "F" "Underestimate" [20,] "F" "Underestimate" [21,] "F" "Underestimate" [22,] "F" "Overestimate" [23,] "F" "Overestimate" [24,] "F" "Accurate" [25,] "F" "Overestimate" [26,] "F" "Underestimate" [27,] "F" "Underestimate" [28,] "F" "Underestimate" [29,] "F" "Underestimate" [30,] "F" "Underestimate" [31,] "F" "Underestimate" [32,] "F" "Underestimate" [33,] "F" "Underestimate" [34,] "F" "Overestimate" [35,] "F" "Accurate" [36,] "F" "Overestimate" [37,] "F" "Overestimate" [38,] "F" "Underestimate" [39,] "F" "Underestimate" [40,] "F" "Underestimate" [41,] "F" "Accurate" [42,] "F" "Accurate" [43,] "F" "Overestimate" [44,] "F" "Underestimate" [45,] "F" "Accurate" [46,] "F" "Overestimate" [47,] "F" "Accurate" [48,] "F" "Accurate" [49,] "F" "Accurate" [50,] "F" "Accurate" [51,] "F" "Accurate" [52,] "F" "Overestimate" [53,] "F" "Underestimate" [54,] "F" "Underestimate" [55,] "F" "Underestimate" [56,] "F" "Accurate" [57,] "F" "Underestimate" [58,] "F" "Overestimate" [59,] "F" "Overestimate" [60,] "F" "Accurate" [61,] "F" "Accurate" [62,] "F" "Accurate" [63,] "F" "Overestimate" [64,] "F" "Accurate" [65,] "F" "Accurate" [66,] "F" "Accurate" [67,] "F" "Underestimate" [68,] "F" "Underestimate" [69,] "F" "Underestimate" [70,] "F" "Accurate" [71,] "F" "Underestimate" [72,] "F" "Overestimate" [73,] "F" "Overestimate" [74,] "F" "Overestimate" [75,] "F" "Overestimate" [76,] "F" "Accurate" [77,] "F" "Accurate" [78,] "F" "Underestimate" [79,] "F" "Underestimate" [80,] "F" "Overestimate" [81,] "F" "Accurate" [82,] "F" "Underestimate" [83,] "F" "Underestimate" [84,] "F" "Underestimate" [85,] "F" "Underestimate" [86,] "F" "Accurate" [87,] "F" "Underestimate" [88,] "F" "Underestimate" [89,] "F" "Accurate" [90,] "F" "Underestimate" [91,] "F" "Accurate" [92,] "F" "Underestimate" [93,] "F" "Underestimate" [94,] "F" "Accurate" [95,] "F" "Underestimate" [96,] "F" "Underestimate" [97,] "F" "Underestimate" [98,] "F" "Accurate" [99,] "F" "Accurate" [100,] "F" "Underestimate" [101,] "M" "Accurate" [102,] "M" "Overestimate" [103,] "M" "Accurate" [104,] "M" "Overestimate" [105,] "M" "Overestimate" [106,] "M" "Accurate" [107,] "M" "Underestimate" [108,] "M" "Overestimate" [109,] "M" "Overestimate" [110,] "M" "Underestimate" [111,] "M" "Overestimate" [112,] "M" "Overestimate" [113,] "M" "Overestimate" [114,] "M" "Underestimate" [115,] "M" "Underestimate" [116,] "M" "Underestimate" [117,] "M" "Overestimate" [118,] "M" "Accurate" [119,] "M" "Underestimate" [120,] "M" "Overestimate" [121,] "M" "Accurate" [122,] "M" "Overestimate" [123,] "M" "Underestimate" [124,] "M" "Overestimate" [125,] "M" "Underestimate" [126,] "M" "Overestimate" [127,] "M" "Underestimate" [128,] "M" "Overestimate" [129,] "M" "Underestimate" [130,] "M" "Overestimate" [131,] "M" "Overestimate" [132,] "M" "Accurate" [133,] "M" "Overestimate" [134,] "M" "Overestimate" [135,] "M" "Underestimate" [136,] "M" "Accurate" [137,] "M" "Overestimate" [138,] "M" "Overestimate" [139,] "M" "Overestimate" [140,] "M" "Overestimate" [141,] "M" "Overestimate" [142,] "M" "Underestimate" [143,] "M" "Overestimate" [144,] "M" "Overestimate" [145,] "M" "Underestimate" [146,] "M" "Underestimate" [147,] "M" "Accurate" [148,] "M" "Overestimate" [149,] "M" "Accurate" [150,] "M" "Accurate" [151,] "M" "Accurate" [152,] "M" "Underestimate" [153,] "M" "Overestimate" [154,] "M" "Overestimate" [155,] "M" "Underestimate" [156,] "M" "Overestimate" [157,] "M" "Overestimate" [158,] "M" "Overestimate" [159,] "M" "Overestimate" [160,] "M" "Underestimate" [161,] "M" "Overestimate" [162,] "M" "Underestimate" [163,] "M" "Overestimate" [164,] "M" "Underestimate" [165,] "M" "Overestimate" [166,] "M" "Underestimate" [167,] "M" "Underestimate" [168,] "M" "Accurate" [169,] "M" "Overestimate" [170,] "M" "Underestimate" [171,] "M" "Overestimate" [172,] "M" "Overestimate" [173,] "M" "Accurate" [174,] "M" "Underestimate" [175,] "M" "Accurate" [176,] "M" "Underestimate" [177,] "M" "Overestimate" [178,] "M" "Underestimate" [179,] "M" "Underestimate" [180,] "M" "Underestimate" [181,] "M" "Overestimate" [182,] "M" "Overestimate" > (table1 <- table(z[,cat1],z[,cat2])) Accurate Overestimate Underestimate F 35 24 41 M 14 41 27 > (V1<-dimnames(y)[[1]][cat1]) [1] "Gender" > (V2<-dimnames(y)[[1]][cat2]) [1] "Estimate" > > #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/1k1l51338389500.tab") > (cst<-chisq.test(table1, simulate.p.value=simulate.p.value) ) Pearson's Chi-squared test data: table1 X-squared = 14.692, df = 2, p-value = 0.0006452 > 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/2zkvx1338389500.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) > a<-table.element(a, 'Chi Square Statistic', 1, TRUE) > a<-table.element(a, round(cst$statistic, digits=2), 1,FALSE) > a<-table.row.end(a) > if(!simulate.p.value){ + 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/37cdv1338389500.tab") > > > > proc.time() user system elapsed 0.361 0.065 0.416