ANOVA Carré Pkshape

10
10/02/10 11:52 T-test and Analysis of Variance (ANOVA) Page 1 sur 10 http://www.masil.org/method/anova.html Regression Panel Data Model Categorical Data ( Event Count Data ( pdf ) Statistics ( K300) T-tests & ANOVA ( pdf ) Factor Analysis (SEM) HLM (Multilevel Model) Software SAS ( vendor ) Stata ( vendor ) M-Plus ( vendor ) R ( R-project ) Resources Data Achives Journals Home (masil.org) Korean (Hangeul) Knowledge Base | KB2 SSCI Journal List K-E Dic This page illustrates how to compare group means using T-test, various ANOVA (analysis of variance) including the repeated measure ANOVA, ANCOVA (analysis of covariance), and MANOVA (multivariate analysis of variance). INTRODUCTION The t-test and ANOVA examine whether group means differ from one another. The t-test compares two groups, while ANOVA can do more than two groups. The t-test ANOVA have three assumptions: independence assumption (the elements of one sample are not related to those of the other sample), normality assumption (samples are randomly drawn from the normally distributed populstions with unknown population means; otherwise the means are no longer best measures of central tendency, thus test will not be valid), and equal variance assumption (the population variances of the two groups are equal) ANCOVA (analysis of covariance) includes covariates, interval independent variables, in the right- hand side to control their impacts. MANOVA (multivariate analysis of variance) has more than one left-hand side variable. Analysis LHS (interval) RHS (categorical) Notes T-test Single Single (binary) One-way Single Single Two-way Single Two (multiple) ANCOVA Single Multiple Covariates MANOVA Multiple Multiple The following diagram summarizes the t-tes and one-way ANOVA. KB Korea Hangeul Help Sitemap Calc Link T-test & ANOVA Intro ( PDF) | Data Structure | ANOVA | T-test | One-way ANOVA | Two-way ANOVA Factorial | Latin Square | Split-Plot | Repeated | ANCOVA | MANOVA | References

description

ANOVA Carré Pkshape

Transcript of ANOVA Carré Pkshape

  • 10/02/10 11:52T-test and Analysis of Variance (ANOVA)

    Page 1 sur 10http://www.masil.org/method/anova.html

    Regression Panel Data Model (pdf) Categorical Data (pdf) Event Count Data (pdf)Statistics (K300) T-tests & ANOVA (pdf) Factor Analysis (SEM) HLM (Multilevel Model)Software SAS (vendor) Stata (vendor) M-Plus (vendor) R (R-project)Resources Data Achives Journals

    Home (masil.org) Korean (Hangeul) Knowledge Base | KB2 SSCI Journal List K-E Dic

    This page illustrates how to compare group means using T-test, various ANOVA (analysis ofvariance) including the repeated measure ANOVA, ANCOVA (analysis of covariance), and MANOVA(multivariate analysis of variance).

    INTRODUCTION

    The t-test and ANOVA examine whether group means differ from one another. The t-testcompares two groups, while ANOVA can do more than two groups.The t-test ANOVA have three assumptions: independence assumption (the elements of one sampleare not related to those of the other sample), normality assumption (samples are randomly drawnfrom the normally distributed populstions with unknown population means; otherwise the meansare no longer best measures of central tendency, thus test will not be valid), and equal varianceassumption (the population variances of the two groups are equal)ANCOVA (analysis of covariance) includes covariates, interval independent variables, in the right-hand side to control their impacts. MANOVA (multivariate analysis of variance) has more thanone left-hand side variable.

    Analysis LHS (interval) RHS (categorical) NotesT-test Single Single (binary)One-way Single SingleTwo-way Single Two (multiple)ANCOVA Single Multiple CovariatesMANOVA Multiple Multiple

    The following diagram summarizes the t-tes and one-way ANOVA.

    KB Korea Hangeul Help Sitemap CalcLinkT-test & ANOVA

    Intro (PDF) | Data Structure | ANOVA | T-test | One-way ANOVA | Two-wayANOVA Factorial | Latin Square | Split-Plot | Repeated | ANCOVA | MANOVA | References

    http://www.masil.org/method/method.html#Regressionhttp://www.masil.org/method/method.html#Panelhttp://www.masil.org/documents/panel.pdfhttp://www.masil.org/method/method.html#CDVMhttp://www.masil.org/documents/cdvm.pdfhttp://www.masil.org/method/method.html#CDVMhttp://www.masil.org/documents/count.pdfhttp://www.masil.org/method/method.html#Statisticshttp://www.masil.org/method/statistics.htmlhttp://www.masil.org/method/anova.htmlhttp://www.masil.org/documents/ttest.pdfhttp://www.masil.org/method/mplus.htmlhttp://www.masil.org/method/anova.htmlhttp://www.masil.org/sas/sas.htmlhttp://www.sas.com/http://www.masil.org/method/stata.htmlhttp://www.stata.com/http://www.masil.org/method/mplus.htmlhttp://www.statmodel.com/http://www.masil.org/method/R.htmlhttp://www.r-project.org/http://www.masil.org/method/anova.html#Resourceshttp://www.masil.org/method/archives.htmlhttp://www.masil.org/method/method.html#Journalshttp://cafe.daum.net/kucchttp://www.korea.ac.kr/~kutkd/http://kupa.korea.ac.kr/http://www.masil.org/http://hangeul.or.kr/2.htmhttp://www.masil.org/appls/kb_list.phphttp://www.masil.org/appls/kb2.phphttp://www.masil.org/appls/ssci_list.phphttp://www.korea.edu/http://www.masil.org/appls/kb_list.phphttp://www.masil.org/site/corea.htmlhttp://www.mct.go.kr/hangeul/http://www.masil.org/site/help.htmlhttp://www.masil.org/site/sitemap.htmlhttp://www.masil.org/site/calculator.htmlhttp://www.masil.org/site/links.htmlhttp://www.indiana.edu/~statmath/stat/all/ttest/http://www.masil.org/documents/ttest.pdfhttp://www.masil.org/method/anova.html#Datahttp://www.masil.org/method/anova.html#Onehttp://www.masil.org/method/anova.html#T-testhttp://www.masil.org/method/anova.html#Onehttp://www.masil.org/method/anova.html#Twohttp://www.masil.org/method/anova.html#Factorialhttp://www.masil.org/method/anova.html#Latinhttp://www.masil.org/method/anova.html#Splithttp://www.masil.org/method/anova.html#Repeatedhttp://www.masil.org/method/anova.html#Ancovahttp://www.masil.org/method/anova.html#Manovahttp://www.masil.org/method/anova.html#References

  • 10/02/10 11:52T-test and Analysis of Variance (ANOVA)

    Page 2 sur 10http://www.masil.org/method/anova.html

    SAS has the UNIVARIATE, MEANS, and TTEST procedures for t-test, while SAS ANOVA,GLM, and MIXED procedures conduct ANOVA.The ANOVA procedure is able to handle balanced data only, but the GLM and MIXED procedurescan deal with both balanced and unbalanced data. The t-test and one-way ANOVA do not matterwhether data are balanced or not.STATA has the .ttest, and the .ttesti commands for t-test, and the .anova, and .manova commandsconduct ANOVA. Note STATA .glm command is not used for ANOVA.

    DATA STRUCTURE

    It is useful to read multiple observations in a data line. Note that @@ is a line holder in SAS.

    LIBNAME js 'c:\data\sas';

    DATA js.data1;INPUT group block $ response @@;DATALINES;1 A 34.5 1 B 54.5 1 B 25.8 3 C 54.82 B 54.8 3 A 15.8 2 C 14.5 2 A 15.1...RUN;

    /* Data read ******************1 1 A 34.52 1 B 54.53 1 B 25.8...*******************************/

    The DO statement allows to read more complicated data. You may list the particular numbers in the DO

    http://www.masil.org/method/anova.html#Top

  • 10/02/10 11:52T-test and Analysis of Variance (ANOVA)

    Page 3 sur 10http://www.masil.org/method/anova.html

    statement rather than set a range of values (e.g., DO treatment=1 TO 2;). The @ may not be omitted.This tip is very useful especially when you type in data for the randomized complete block design (RCB)and the Latin square design (LSD).

    DATA js.data2;DO block=1 TO 3; DO treatment=1,5; INPUT response @; OUTPUT; END;END; DATALINES;4.91 4.63 4.76 5.04 5.38 6.215.60 5.08 4.91 4.63 4.76 5.04...RUN;

    /* Data read *********************1 1 1 4.912 1 5 4.633 2 1 4.764 2 5 5.045 3 1 5.38...**********************************/

    If data are arranged in the long format, you need to rearranged into the wide format.

    DATA js.wide1; SET js.long; IF period=1; RENAME response=response1;

    PROC SORT DATA=js.wide1; BY id;RUN;

    ...

    DATA js.wide; MERGE js.long1 js.long2 ...; BY id;RUN;

    STATA has the .pkshape command to transform a data set in the latin square form into the corresponingdata set for analysis.

    . list, noobs+---------------+|id row c1 c2 c3||---------------||100 1 74 97 54 ||101 2 54 84 25 ||102 3 15 57 64 |+---------------+

  • 10/02/10 11:52T-test and Analysis of Variance (ANOVA)

    Page 4 sur 10http://www.masil.org/method/anova.html

    . pkshape id r c1-c3, order(abc cab bca) outcome(y) sequence(row) treat(treat) period(col)

    T-TEST

    One Sample T-Test

    The MU0 option specifies a value of the null hypothesis. The ALPHA option specifies the significancelevel. The T option in the MEANS procedure runs the t-test.

    PROC UNIVARIATE MU0=0 ALPHA=.01; VAR response;RUN;

    . ttest response=0, level(99)

    PROC UNIVARIATE MU0=10 VARDEF=DF NORMAL ALPHA=.05; VAR response;RUN;

    . ttest response=10

    PROC MEANS T PROBT; VAR response;RUN;

    . ttest response=0

    PROC MEANS MEAN STD STDERR T VARDEF=DF PROBT CLM ALPHA=.01; VAR response;RUN;

    Paired T-Test

    PROC TTEST; PAIRED pre*post;RUN;

    . ttest pre=post,level(95)

    Note that STATA .ttest command does not have the "unpaired" option. SAS PAIRED statement is ableto compare multiple pairs.

    PROC TTEST; PAIRED (a b)*(c d);RUN;

    Two Independent Samples T-Test

    The TTEST procedure reports two T statistics: one under the equal variance assumptio and the other forunequal variance. Users have to check the equal variance test (F test) first. If not rejected, read the Tstatistic and its p-value of pooled analysis. If rejected, read the T statistic and its p-value of Satterthwaiteor Cochran/Cox approximation.

    http://www.masil.org/method/anova.html#Tophttp://www.masil.org/method/anova.html#Top

  • 10/02/10 11:52T-test and Analysis of Variance (ANOVA)

    Page 5 sur 10http://www.masil.org/method/anova.html

    PROC TTEST COCHRAN; CLASS male; VAR response;RUN;

    . ttest response, by(male)

    . ttest response, by(male) unequal

    STATA is able to conduct the t-test for two independnet samples even When data are arranged in twovariables without a group varialbe. The unpaired option indicates that the two variables are independent,and the welch option asks STATA produces Welch approximation of degree of freedom. Note STATAdoes not give us Cochran/Cox approximation.

    . ttest response1=response2, unpaired level(99)

    . ttest response1=response2, unpaired unequal welch

    T-Test on Aggregate Data

    The FREQ statement in the TTEST procedure can handle aggregate data

    PROC TTEST H0=5 ALPHA=.01; CLASS smoke; VAR lung; FREQ count;RUN;

    STATA .ttesti command enables you to conduct t-test using aggregated descriptive statistics. Thenumbers listed are the number of observation, mean, and standard deviation of first sample and ofsecond sample.

    . ttesti 30 4.5 0.54 // One sample T-test

    . ttesti 30 4.5 0.54 30 5.0 1.44 // Two sample T-test

    ONE-WAY ANOVA

    This experimental design is often called completely randomized design (CRD). SAS has the ANOVA,GLM (Generalized Linear Model), MIXED Procedures for one-way ANOVA. Their usages are identical.

    PROC ANOVA; CLASS treatment; MODEL response=treatment;RUN;

    STATA has the .anova and .oneway command for one-way ANOVA.

    . anova response treatment

    . oneway response treatment, tabulate

    You may add the MEANS statement in both ANOVA and GLM procedures to compute means of groupsand perform multiple comparison tests such as DUNCAN, TUKEY, DUNNETT, and BON.

    PROC GLM; CLASS treatment;

    http://www.masil.org/method/anova.html#Top

  • 10/02/10 11:52T-test and Analysis of Variance (ANOVA)

    Page 6 sur 10http://www.masil.org/method/anova.html

    MODEL response=treatment; MEANS treatment /T DUNCAN; RUN;

    TWO-WAY ANOVA

    Randomized Complete Block (RCB): Treatments are assigned at random within blocks of adjacentsubjects, each treatment once per block. The number of blocks is the number of replications. Anytreatment can be adjacent to any other treatment, but not to the same treatment within the block.

    Again, the ANOVA, GLM, and MIXED conduct the two-way ANOVA with the identical usage.

    PROC GLM; CLASS treat1 treat2; MODEL response=treat1 treat2;RUN;

    In the case of the randomized complete block design, you may have one observation in each cell. So,including an interaction term is meaningless, producing awkward results. But it is noteworthy that thesum of squares due to error (SSE) is equivalent to the sum of squares of interaction (SSI).

    You may compare group means using the MEANS or the LSMEANS (least squares means) statement.The LSMEANS statement is not available in the ANOVA procedure.

    PROC ANOVA; CLASS treatment block; MODEL response=treatment block; MEANS treatment block /TUKEY;RUN;

    PROC GLM; CLASS treatment block; MODEL response=treatment block; LSMEANS treatment block /ADJUST=TUKEY;RUN;

    If there is subsamples, you need to use nested scheme as follows.

    PROC GLM; CLASS treatment sub; MODEL response=treatment treatment(sub);RUN;

    . ttest response treatment / sub | treatment /

    FACTORIAL DESIGN

    If there are subsamples (more than one observation in each cell) in a two-way ANOVA, you mayconsider the interaction effects. This is the two-way factorial design on CRD.

    Block1 block2 block3Treat1 54, 67, 87 57, 67 31, 54, 87, 95

    http://www.masil.org/method/anova.html#Tophttp://www.masil.org/method/anova.html#Top

  • 10/02/10 11:52T-test and Analysis of Variance (ANOVA)

    Page 7 sur 10http://www.masil.org/method/anova.html

    Treat2 35, 67 54, 87, 15, 75, 55 68, 17, 16, 68Treat3 98, 45, 12, 57, 87 31, 14, 54 24, 87

    The interaction is expressed by asterisk (*). The | indicates all possible combinations. Thus, the followingprocedures return the same result.

    PROC ANOVA; CLASS treatment block; MODEL response=treatment | block;RUN;

    PROC GLM; CLASS treatment block; MODEL response=treatment block treatment*block;RUN;

    You may compare group means using the MEANS or the LSMEANS (least squares means) statement.The LSMEANS statement is not available in the ANOVA procedure.

    PROC ANOVA; CLASS treatment block; MODEL response=treatment | block; MEANS treatment block treatment*block/TUKEY;RUN;

    PROC GLM; CLASS treatment block; MODEL response=treatment | block; LSMEANS treatment | block /ADJUST=TUKEY;RUN;

    Two-Way Factorial Design on RCB

    PROC GLM; CLASS treat1 treat2 block; MODEL response=treat1 treat2 block treat1*treat2;RUN;

    . anova response treatment block treatment*block

    Three-Way Factorial Design on RCB

    PROC GLM; CLASS treat1 treat2 treat3 block; MODEL response=treat1 treat2 block treat1*treat2 treat1*treat3 treat2*treat3 treat1*treat2*treat3;RUN;

    SPLIT-PLOT DESIGN

    Split-Plot Design on CRD

    PROC GLM; CLASS treat repeat sub;

    http://www.masil.org/method/anova.html#Top

  • 10/02/10 11:52T-test and Analysis of Variance (ANOVA)

    Page 8 sur 10http://www.masil.org/method/anova.html

    MODEL response=treat sub treat(repeat) treat*sub;RUN;

    Split-Plot Design on RCB

    PROC GLM; CLASS treat block sub; MODEL response=treat block sub treat*block treat*sub;RUN;

    LATIN SQUARE DESIGN

    The latin square design (LSD) has the equal number of rows, columns and treatments. Treatments areassigned at random within rows and columns, with each treatment once per row and once per column.Each cell of the squared table has only one observation. This LSD is useful to control variation in tworow and column.

    PROC GLM; CLASS row column treatment; MODEL response=row column treatment;RUN;

    .anova response row column treat

    The degree of freedom of main effects (block, group, and treatment) is r, the number of row or column.The degree of freedom of SSE is (r-1)(r-2). Finally, the degree of freedom of SST is N-1 = r*r-1.

    REPEATED MEASURE ANOVA

    The REPEATED statement in SAS and the repeated() option are used to indicate repeated measureanalysis.

    PROC GLM; CLASS treat block; MODEL resp1 resp2 resp3=treat block; REPEATED response;RUN;

    PROC GLM; CLASS treat block; MODEL output1 - output5 = treat block; REPEATED id 5 (0 1 2 3 4) / POLYNOMIAL SUMMARY PRINTE;RUN;

    . anova response treat time, repeated(time)

    RANDOM EFFECT MODELS

    The followings are examples of random effects models using MIXED and GLM.

    PROC MIXED;

    http://www.masil.org/method/anova.html#Tophttp://www.masil.org/method/anova.html#Top

  • 10/02/10 11:52T-test and Analysis of Variance (ANOVA)

    Page 9 sur 10http://www.masil.org/method/anova.html

    CLASS treat block; MODEL response = treatk /SOLUTION; RANDOM block /SOLUTION;RUN;

    PROC MIXED COVTEST METHOD=TYPE3; CLASS subject type; /* type is a characteristic of subject */ MODEL response = type /SOLUTION; RANDOM subject(type) /SOLUTION; LSMEANS type /DIFF;RUN;

    PROC GLM COVTEST; CLASS subject type; /* type is a characteristic of subject */ MODEL response = type subject(type); RANDOM subject(type) /TEST;RUN;

    PROC MIXED COVTEST; CLASS town block plant treat ; MODEL response = treat /SOLUTION; RANDOM area plant area*plant block(area) /SOLUTION;RUN;

    ANCOVA

    ANCOVA controls variation in an experiment by measuring an independent factor on each experimentalsubject.

    PROC GLM; CLASS treat; MODEL response=covariate treat /SOLUTION; LSMEANS treat /STDERR;RUN;

    . anova response treat covariate, continuous(covariate)

    MANOVA

    The MANOVA statement indicates that this model is the multivariate analysis of variance.

    PROC GLM; CLASS treat1 treat2; MODEL response1-response3= treat1-treat5/NOUNI; MANOVA H=treat;RUN;

    . manova response1-response3 = treat1-treat5

    REFERENCES

    http://www.masil.org/method/anova.html#Tophttp://www.masil.org/method/anova.html#Top

  • 10/02/10 11:52T-test and Analysis of Variance (ANOVA)

    Page 10 sur 10http://www.masil.org/method/anova.html

    Littell, Ramon C., Walter W. Stroup, and Rudolf J. Freund. 2002. SAS for Linear Models, 4th ed.Cary, NC: SAS Institute.Littell, Ramon C., George A. Milliken, Walter W. Stroup, and Russell D. Wolfinge. 2006. SASSystem for Mixed Models. 2nd ed. Cary, NC: SAS Institute.Stata Press. 2003. Stata Base Reference Manual Release 8. College Station, TX: Stata Press.http://www.tfrec.wsu.edu/ANOVA/

    Indiana University | Korea University | PA Department | IGS Korea | ASPA | KAPA | KAPShttp://www.masil.org/method/anova.html. Last modified on 02/07/2010Copyright 1999-2010, Jeeshim and KUCC625

    http://www.tfrec.wsu.edu/ANOVA/http://www.iub.edu/http://www.korea.ac.kr/http://kupa.korea.ac.kr/http://www.korea.ac.kr/~igskoreahttp://www.aspanet.org/http://www.kapa21.or.kr/http://www.kaps.or.kr/http://www.masil.org/site/help.html#Conditions