R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-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(210907 + ,56 + ,120982 + ,56 + ,176508 + ,54 + ,179321 + ,89 + ,123185 + ,40 + ,52746 + ,25 + ,385534 + ,92 + ,33170 + ,18 + ,101645 + ,63 + ,149061 + ,44 + ,165446 + ,33 + ,237213 + ,84 + ,173326 + ,88 + ,133131 + ,55 + ,258873 + ,60 + ,180083 + ,66 + ,324799 + ,154 + ,230964 + ,53 + ,236785 + ,119 + ,135473 + ,41 + ,202925 + ,61 + ,215147 + ,58 + ,344297 + ,75 + ,153935 + ,33 + ,132943 + ,40 + ,174724 + ,92 + ,174415 + ,100 + ,225548 + ,112 + ,223632 + ,73 + ,124817 + ,40 + ,221698 + ,45 + ,210767 + ,60 + ,170266 + ,62 + ,260561 + ,75 + ,84853 + ,31 + ,294424 + ,77 + ,101011 + ,34 + ,215641 + ,46 + ,325107 + ,99 + ,7176 + ,17 + ,167542 + ,66 + ,106408 + ,30 + ,96560 + ,76 + ,265769 + ,146 + ,269651 + ,67 + ,149112 + ,56 + ,175824 + ,107 + ,152871 + ,58 + ,111665 + ,34 + ,116408 + ,61 + ,362301 + ,119 + ,78800 + ,42 + ,183167 + ,66 + ,277965 + ,89 + ,150629 + ,44 + ,168809 + ,66 + ,24188 + ,24 + ,329267 + ,259 + ,65029 + ,17 + ,101097 + ,64 + ,218946 + ,41 + ,244052 + ,68 + ,341570 + ,168 + ,103597 + ,43 + ,233328 + ,132 + ,256462 + ,105 + ,206161 + ,71 + ,311473 + ,112 + ,235800 + ,94 + ,177939 + ,82 + ,207176 + ,70 + ,196553 + ,57 + ,174184 + ,53 + ,143246 + ,103 + ,187559 + ,121 + ,187681 + ,62 + ,119016 + ,52 + ,182192 + ,52 + ,73566 + ,32 + ,194979 + ,62 + ,167488 + ,45 + ,143756 + ,46 + ,275541 + ,63 + ,243199 + ,75 + ,182999 + ,88 + ,135649 + ,46 + ,152299 + ,53 + ,120221 + ,37 + ,346485 + ,90 + ,145790 + ,63 + ,193339 + ,78 + ,80953 + ,25 + ,122774 + ,45 + ,130585 + ,46 + ,112611 + ,41 + ,286468 + ,144 + ,241066 + ,82 + ,148446 + ,91 + ,204713 + ,71 + ,182079 + ,63 + ,140344 + ,53 + ,220516 + ,62 + ,243060 + ,63 + ,162765 + ,32 + ,182613 + ,39 + ,232138 + ,62 + ,265318 + ,117 + ,85574 + ,34 + ,310839 + ,92 + ,225060 + ,93 + ,232317 + ,54 + ,144966 + ,144 + ,43287 + ,14 + ,155754 + ,61 + ,164709 + ,109 + ,201940 + ,38 + ,235454 + ,73 + ,220801 + ,75 + ,99466 + ,50 + ,92661 + ,61 + ,133328 + ,55 + ,61361 + ,77 + ,125930 + ,75 + ,100750 + ,72 + ,224549 + ,50 + ,82316 + ,32 + ,102010 + ,53 + ,101523 + ,42 + ,243511 + ,71 + ,22938 + ,10 + ,41566 + ,35 + ,152474 + ,65 + ,61857 + ,25 + ,99923 + ,66 + ,132487 + ,41 + ,317394 + ,86 + ,21054 + ,16 + ,209641 + ,42 + ,22648 + ,19 + ,31414 + ,19 + ,46698 + ,45 + ,131698 + ,65 + ,91735 + ,35 + ,244749 + ,95 + ,184510 + ,49 + ,79863 + ,37 + ,128423 + ,64 + ,97839 + ,38 + ,38214 + ,34 + ,151101 + ,32 + ,272458 + ,65 + ,172494 + ,52 + ,108043 + ,62 + ,328107 + ,65 + ,250579 + ,83 + ,351067 + ,95 + ,158015 + ,29 + ,98866 + ,18 + ,85439 + ,33 + ,229242 + ,247 + ,351619 + ,139 + ,84207 + ,29 + ,120445 + ,118 + ,324598 + ,110 + ,131069 + ,67 + ,204271 + ,42 + ,165543 + ,65 + ,141722 + ,94 + ,116048 + ,64 + ,250047 + ,81 + ,299775 + ,95 + ,195838 + ,67 + ,173260 + ,63 + ,254488 + ,83 + ,104389 + ,45 + ,136084 + ,30 + ,199476 + ,70 + ,92499 + ,32 + ,224330 + ,83 + ,135781 + ,31 + ,74408 + ,67 + ,81240 + ,66 + ,14688 + ,10 + ,181633 + ,70 + ,271856 + ,103 + ,7199 + ,5 + ,46660 + ,20 + ,17547 + ,5 + ,133368 + ,36 + ,95227 + ,34 + ,152601 + ,48 + ,98146 + ,40 + ,79619 + ,43 + ,59194 + ,31 + ,139942 + ,42 + ,118612 + ,46 + ,72880 + ,33 + ,65475 + ,18 + ,99643 + ,55 + ,71965 + ,35 + ,77272 + ,59 + ,49289 + ,19 + ,135131 + ,66 + ,108446 + ,60 + ,89746 + ,36 + ,44296 + ,25 + ,77648 + ,47 + ,181528 + ,54 + ,134019 + ,53 + ,124064 + ,40 + ,92630 + ,40 + ,121848 + ,39 + ,52915 + ,14 + ,81872 + ,45 + ,58981 + ,36 + ,53515 + ,28 + ,60812 + ,44 + ,56375 + ,30 + ,65490 + ,22 + ,80949 + ,17 + ,76302 + ,31 + ,104011 + ,55 + ,98104 + ,54 + ,67989 + ,21 + ,30989 + ,14 + ,135458 + ,81 + ,73504 + ,35 + ,63123 + ,43 + ,61254 + ,46 + ,74914 + ,30 + ,31774 + ,23 + ,81437 + ,38 + ,87186 + ,54 + ,50090 + ,20 + ,65745 + ,53 + ,56653 + ,45 + ,158399 + ,39 + ,46455 + ,20 + ,73624 + ,24 + ,38395 + ,31 + ,91899 + ,35 + ,139526 + ,151 + ,52164 + ,52 + ,51567 + ,30 + ,70551 + ,31 + ,84856 + ,29 + ,102538 + ,57 + ,86678 + ,40 + ,85709 + ,44 + ,34662 + ,25 + ,150580 + ,77 + ,99611 + ,35 + ,19349 + ,11 + ,99373 + ,63 + ,86230 + ,44 + ,30837 + ,19 + ,31706 + ,13 + ,89806 + ,42 + ,62088 + ,38 + ,40151 + ,29 + ,27634 + ,20 + ,76990 + ,27 + ,37460 + ,20 + ,54157 + ,19 + ,49862 + ,37 + ,84337 + ,26 + ,64175 + ,42 + ,59382 + ,49 + ,119308 + ,30 + ,76702 + ,49 + ,103425 + ,67 + ,70344 + ,28 + ,43410 + ,19 + ,104838 + ,49 + ,62215 + ,27 + ,69304 + ,30 + ,53117 + ,22 + ,19764 + ,12 + ,86680 + ,31 + ,84105 + ,20 + ,77945 + ,20 + ,89113 + ,39 + ,91005 + ,29 + ,40248 + ,16 + ,64187 + ,27 + ,50857 + ,21 + ,56613 + ,19 + ,62792 + ,35 + ,72535 + ,14) + ,dim=c(2 + ,289) + ,dimnames=list(c('A' + ,'B') + ,1:289)) > y <- array(NA,dim=c(2,289),dimnames=list(c('A','B'),1:289)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = 'TRUE' > par2 = '1' > par1 = '2' > ylab = 'Y Variable Name' > xlab = 'X Variable Name' > main = 'Title Goes Here' > par3 <- 'TRUE' > par2 <- '1' > par1 <- '2' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: aston2 > #To cite this work: Ian E. Holliday, 2012, Simple Linear Regression (v1.0.5) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/Ian.Holliday/rwasp_Simple%20Regression%20Y%20~%20X.wasp/ > #Source of accompanying publication: > # > cat1 <- as.numeric(par1) > cat2<- as.numeric(par2) > intercept<-as.logical(par3) > x <- t(x) > xdf<-data.frame(t(y)) > (V1<-dimnames(y)[[1]][cat1]) [1] "B" > (V2<-dimnames(y)[[1]][cat2]) [1] "A" > xdf <- data.frame(xdf[[cat1]], xdf[[cat2]]) > names(xdf)<-c('Y', 'X') > if(intercept == FALSE) (lmxdf<-lm(Y~ X - 1, data = xdf) ) else (lmxdf<-lm(Y~ X, data = xdf) ) Call: lm(formula = Y ~ X, data = xdf) Coefficients: (Intercept) X 1.420e+01 2.945e-04 > sumlmxdf<-summary(lmxdf) > (aov.xdf<-aov(lmxdf) ) Call: aov(formula = lmxdf) Terms: X Residuals Sum of Squares 169356.4 161027.9 Deg. of Freedom 1 287 Residual standard error: 23.68697 Estimated effects may be unbalanced > (anova.xdf<-anova(lmxdf) ) Analysis of Variance Table Response: Y Df Sum Sq Mean Sq F value Pr(>F) X 1 169356 169356 301.84 < 2.2e-16 *** Residuals 287 161028 561 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/rcomp/createtable") > > a<-table.start() > nc <- ncol(sumlmxdf$'coefficients') > nr <- nrow(sumlmxdf$'coefficients') > a<-table.row.start(a) > a<-table.element(a,'Linear Regression Model', nc+1,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, lmxdf$call['formula'],nc+1) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'coefficients:',1,TRUE) > a<-table.element(a, ' ',nc,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, ' ',1,TRUE) > for(i in 1 : nc){ + a<-table.element(a, dimnames(sumlmxdf$'coefficients')[[2]][i],1,TRUE) + }#end header > a<-table.row.end(a) > for(i in 1: nr){ + a<-table.element(a,dimnames(sumlmxdf$'coefficients')[[1]][i] ,1,TRUE) + for(j in 1 : nc){ + a<-table.element(a, round(sumlmxdf$coefficients[i, j], digits=3), 1 ,FALSE) + } + a<-table.row.end(a) + } > a<-table.row.start(a) > a<-table.element(a, '- - - ',1,TRUE) > a<-table.element(a, ' ',nc,FALSE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Residual Std. Err. ',1,TRUE) > a<-table.element(a, paste(round(sumlmxdf$'sigma', digits=3), ' on ', sumlmxdf$'df'[2], 'df') ,nc, FALSE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Multiple R-sq. ',1,TRUE) > a<-table.element(a, round(sumlmxdf$'r.squared', digits=3) ,nc, FALSE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Adjusted R-sq. ',1,TRUE) > a<-table.element(a, round(sumlmxdf$'adj.r.squared', digits=3) ,nc, FALSE) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/fisher/rcomp/tmp/1n9s11355691575.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'ANOVA Statistics', 5+1,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, ' ',1,TRUE) > a<-table.element(a, 'Df',1,TRUE) > a<-table.element(a, 'Sum Sq',1,TRUE) > a<-table.element(a, 'Mean Sq',1,TRUE) > a<-table.element(a, 'F value',1,TRUE) > a<-table.element(a, 'Pr(>F)',1,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, V2,1,TRUE) > a<-table.element(a, anova.xdf$Df[1]) > a<-table.element(a, round(anova.xdf$'Sum Sq'[1], digits=3)) > a<-table.element(a, round(anova.xdf$'Mean Sq'[1], digits=3)) > a<-table.element(a, round(anova.xdf$'F value'[1], digits=3)) > a<-table.element(a, round(anova.xdf$'Pr(>F)'[1], digits=3)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Residuals',1,TRUE) > a<-table.element(a, anova.xdf$Df[2]) > a<-table.element(a, round(anova.xdf$'Sum Sq'[2], digits=3)) > a<-table.element(a, round(anova.xdf$'Mean Sq'[2], digits=3)) > a<-table.element(a, ' ') > a<-table.element(a, ' ') > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/fisher/rcomp/tmp/2dwvs1355691575.tab") > postscript(file="/var/fisher/rcomp/tmp/32inj1355691575.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(Y~ X, data=xdf, xlab=V2, ylab=V1, main='Regression Solution') > if(intercept == TRUE) abline(coef(lmxdf), col='red') > if(intercept == FALSE) abline(0.0, coef(lmxdf), col='red') > dev.off() null device 1 > library(car) Loading required package: MASS Loading required package: nnet > postscript(file="/var/fisher/rcomp/tmp/4ziu81355691575.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qq.plot(resid(lmxdf), main='QQplot of Residuals of Fit') Warning message: 'qq.plot' is deprecated. Use 'qqPlot' instead. See help("Deprecated") and help("car-deprecated"). > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/5v58y1355691575.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(xdf$X, resid(lmxdf), main='Scatterplot of Residuals of Model Fit') > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/6uuiv1355691575.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot.lm(lmxdf, which=4) > dev.off() null device 1 > > try(system("convert tmp/32inj1355691575.ps tmp/32inj1355691575.png",intern=TRUE)) character(0) > try(system("convert tmp/4ziu81355691575.ps tmp/4ziu81355691575.png",intern=TRUE)) character(0) > try(system("convert tmp/5v58y1355691575.ps tmp/5v58y1355691575.png",intern=TRUE)) character(0) > try(system("convert tmp/6uuiv1355691575.ps tmp/6uuiv1355691575.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.697 0.709 3.407