# ::Free Statistics and Forecasting Software::

v1.1.23-r7
Secure website (SSL) | Donate to wessa.net

### :: Two-Way ANOVA - Free Statistics Software (Calculator) ::

All rights reserved. The non-commercial (academic) use of this software is free of charge. The only thing that is asked in return is to cite this software when results are used in publications.

This free online software (calculator) computes the Two-Way ANOVA, Levene's Test for Equality of Variances, and Tukey's HSD (Honestly Significant Difference) Test. This R module is used in Workshop 9 of the PY2224 statistics course at Aston University, UK.

Enter (or paste) a matrix (table) containing all data (time) series. Every column represents a different variable and must be delimited by a space or Tab. Every row represents a period in time (or category) and must be delimited by hard returns. The easiest way to enter data is to copy and paste a block of spreadsheet cells. Please, do not use commas or spaces to seperate groups of digits!

 Send output to: Browser Blue - Charts White Browser Black/White CSV MS Excel MS Word Data X (click to load default data) 0.28 'A' 'M' 0.95 'A' 'M' 0.96 'A' 'M' 0.97 'A' 'M' 0.40 'A' 'M' 0.18 'A' 'M' 0.12 'A' 'M' 0.62 'A' 'M' 1.81 'A' 'F' 1.51 'A' 'F' 1.41 'A' 'F' 1.39 'A' 'F' 1.20 'A' 'F' 1.55 'A' 'F' 1.48 'A' 'F' 1.25 'A' 'F' 0.95 'B' 'M' 1.33 'B' 'M' 0.92 'B' 'M' 0.85 'B' 'M' 1.06 'B' 'M' 0.69 'B' 'M' 0.70 'B' 'M' 0.79 'B' 'M' 2.93 'B' 'F' 3.24 'B' 'F' 3.42 'B' 'F' 2.79 'B' 'F' 2.54 'B' 'F' 3.28 'B' 'F' 2.80 'B' 'F' 3.40 'B' 'F' Names of X columns: R A B Response : Variable 1 Factor : Variable 2 Factor : Variable 3 Include Intercept Term ? FALSE TRUE Chart options Width: Height: Title: Label y-axis: Label x-axis:

 Source code of R module cat1 <- as.numeric(par1) # cat2<- as.numeric(par2) # cat3 <- as.numeric(par3) intercept<-as.logical(par4) x <- t(x) x1<-as.numeric(x[,cat1]) f1<-as.character(x[,cat2]) f2 <- as.character(x[,cat3]) xdf<-data.frame(x1,f1, f2) (V1<-dimnames(y)[[1]][cat1]) (V2<-dimnames(y)[[1]][cat2]) (V3 <-dimnames(y)[[1]][cat3]) names(xdf)<-c('Response', 'Treatment_A', 'Treatment_B') if(intercept == FALSE) (lmxdf<-lm(Response ~ Treatment_A * Treatment_B- 1, data = xdf) ) else (lmxdf<-lm(Response ~ Treatment_A * Treatment_B, data = xdf) ) (aov.xdf<-aov(lmxdf) ) (anova.xdf<-anova(lmxdf) ) load(file='createtable') a<-table.start() a<-table.row.start(a) a<-table.element(a,'ANOVA Model', length(lmxdf\$coefficients)+1,TRUE) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a, lmxdf\$call["formula"],length(lmxdf\$coefficients)+1,TRUE) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a, "means",,TRUE) for(i in 1:length(lmxdf\$coefficients)){ a<-table.element(a, round(lmxdf\$coefficients[i], digits=3),,FALSE) } a<-table.row.end(a) a<-table.end(a) table.save(a,file='mytable.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, " ",,TRUE) a<-table.element(a, "Df",,FALSE) a<-table.element(a, "Sum Sq",,FALSE) a<-table.element(a, "Mean Sq",,FALSE) a<-table.element(a, "F value",,FALSE) a<-table.element(a, "Pr(>F)",,FALSE) a<-table.row.end(a) for(i in 1 : length(rownames(anova.xdf))-1){ a<-table.row.start(a) a<-table.element(a,rownames(anova.xdf)[i] ,,TRUE) a<-table.element(a, anova.xdf\$Df[1],,FALSE) a<-table.element(a, round(anova.xdf\$"Sum Sq"[i], digits=3),,FALSE) a<-table.element(a, round(anova.xdf\$"Mean Sq"[i], digits=3),,FALSE) a<-table.element(a, round(anova.xdf\$"F value"[i], digits=3),,FALSE) a<-table.element(a, round(anova.xdf\$"Pr(>F)"[i], digits=3),,FALSE) a<-table.row.end(a) } a<-table.row.start(a) a<-table.element(a, "Residuals",,TRUE) a<-table.element(a, anova.xdf\$"Df"[i+1],,FALSE) a<-table.element(a, round(anova.xdf\$"Sum Sq"[i+1], digits=3),,FALSE) a<-table.element(a, round(anova.xdf\$"Mean Sq"[i+1], digits=3),,FALSE) a<-table.element(a, " ",,FALSE) a<-table.element(a, " ",,FALSE) a<-table.row.end(a) a<-table.end(a) table.save(a,file='mytable1.tab') bitmap(file='anovaplot.png') boxplot(Response ~ Treatment_A + Treatment_B, data=xdf, xlab=V2, ylab=V1, main='Boxplots of ANOVA Groups') dev.off() bitmap(file='designplot.png') xdf2 <- xdf # to preserve xdf make copy for function names(xdf2) <- c(V1, V2, V3) plot.design(xdf2, main='Design Plot of Group Means') dev.off() bitmap(file='interactionplot.png') interaction.plot(xdf\$Treatment_A, xdf\$Treatment_B, xdf\$Response, xlab=V2, ylab=V1, trace.label=V3, main='Possible Interactions Between Anova Groups') dev.off() if(intercept==TRUE){ thsd<-TukeyHSD(aov.xdf) names(thsd) <- c(V2, V3, paste(V2, ":", V3, sep="")) bitmap(file='TukeyHSDPlot.png') layout(matrix(c(1,2,3,3), 2,2)) plot(thsd, las=1) dev.off() } if(intercept==TRUE){ ntables<-length(names(thsd)) a<-table.start() a<-table.row.start(a) a<-table.element(a,'Tukey Honest Significant Difference Comparisons', 5,TRUE) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a, ' ', 1, TRUE) for(i in 1:4){ a<-table.element(a,colnames(thsd[[1]])[i], 1, TRUE) } a<-table.row.end(a) for(nt in 1:ntables){ for(i in 1:length(rownames(thsd[[nt]]))){ a<-table.row.start(a) a<-table.element(a,rownames(thsd[[nt]])[i], 1, TRUE) for(j in 1:4){ a<-table.element(a,round(thsd[[nt]][i,j], digits=3), 1, FALSE) } a<-table.row.end(a) } } # end nt a<-table.end(a) table.save(a,file='hsdtable.tab') }#end if hsd tables if(intercept==FALSE){ a<-table.start() a<-table.row.start(a) a<-table.element(a,'TukeyHSD Message', 1,TRUE) a<-table.row.end(a) a<-table.start() a<-table.row.start(a) a<-table.element(a,'Must Include Intercept to use Tukey Test ', 1, FALSE) a<-table.row.end(a) a<-table.end(a) table.save(a,file='mytable2.tab') } library(car) lt.lmxdf<-levene.test(lmxdf) a<-table.start() a<-table.row.start(a) a<-table.element(a,'Levenes Test for Homogeneity of Variance', 4,TRUE) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,' ', 1, TRUE) for (i in 1:3){ a<-table.element(a,names(lt.lmxdf)[i], 1, FALSE) } a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,'Group', 1, TRUE) for (i in 1:3){ a<-table.element(a,round(lt.lmxdf[[i]][1], digits=3), 1, FALSE) } a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,' ', 1, TRUE) a<-table.element(a,lt.lmxdf[[1]][2], 1, FALSE) a<-table.element(a,' ', 1, FALSE) a<-table.element(a,' ', 1, FALSE) a<-table.row.end(a) a<-table.end(a) table.save(a,file='mytable3.tab')
 Top | Output | Charts | References | History | Feedback

 Cite this software as: Ian E. Holliday, 2012, Two-Way ANOVA (v1.0.3) in Free Statistics Software (v1.1.23-r7), Office for Research Development and Education, URL http://www.wessa.net/Ian.Holliday/rwasp_Two%20Factor%20ANOVA.wasp/ The R code is based on : NIST/SEMATECH e-Handbook of Statistical Methods: Levene Test for Equality of Variances, URL http://www.itl.nist.gov/div898/handbook/eda/section3/eda35a.htm NIST/SEMATECH e-Handbook of Statistical Methods: Tukey method, URL http://www.itl.nist.gov/div898/handbook/prc/section4/prc471.htm
 Top | Output | Charts | References | History | Feedback
 Top | Output | Charts | References | History | Feedback
 To cite Wessa.net in publications use:Wessa, P. (2013), Free Statistics Software, Office for Research Development and Education, version 1.1.23-r7, URL http://www.wessa.net/ © All rights reserved. Academic license for non-commercial use only. The free use of the scientific content, services, and applications in this website is granted for non commercial use only. In any case, the source (url) should always be clearly displayed. Under no circumstances are you allowed to reproduce, copy or redistribute the design, layout, or any content of this website (for commercial use) including any materials contained herein without the express written permission. Information provided on this web site is provided "AS IS" without warranty of any kind, either express or implied, including, without limitation, warranties of merchantability, fitness for a particular purpose, and noninfringement. We use reasonable efforts to include accurate and timely information and periodically update the information, and software without notice. We make no warranties or representations as to the accuracy or completeness of such information (or software), and it assumes no liability or responsibility for errors or omissions in the content of this web site, or any software bugs in online applications. Your use of this web site is AT YOUR OWN RISK. Under no circumstances and under no legal theory shall we be liable to you or any other person for any direct, indirect, special, incidental, exemplary, or consequential damages arising from your access to, or use of, this web site. Software Version : 1.1.23-r7Algorithms & Software : Patrick Wessa, PhDServer : www.wessa.net