ANOVA Example in R




 

Here is some background on this research.  It involves the study of the impact of fallacious arguments on attitudes.  The dependent variable is attitude toward the topic.  The study now has two independent variables.  The first independent variable is a true experimental variable: the use or non-use of the non sequitur fallacy in a persuasive message.  The second independent variable is a moderator variable: sex of the respondent.  This second independent variable is a moderator variable and, of course, it is not experimentally manipulated. Thus, each independent variable has two levels.  The experimental variable dealing with the use of the non sequitur fallacy is identified as "falexper" (1= with the fallacy presented to subjects; 2=without the fallacy presented to subjects).  The remaining (moderator) independent variable is "sex" and is identified with 1 equal to males and 2 equal to females. 

 

 

The data is in SPSS format and named as ATTITUD1.SAV and stored in C:\datasets.

 

In R, type in the following commands:

 

>library(foreign)

>atti<-read.spss("c:\\datasets\\attitud1.sav", use.value.labels=TRUE, to.data.frame=TRUE, max.value.labels=Inf)

  (to import the dataset into R)

  If only one factor, execute the followings:

> res<-aov(ATTITUDE ~ FALEXPER, atti)
> summary(res)
                   Df    Sum Sq    Mean Sq    F value    Pr(>F) 
FALEXPER 1    80.79       80.79         3.3019     0.0752 .
Residuals      50  1223.44    24.47 

  If work on two factors, execute the followings:

> res1<-aov(ATTITUDE ~ FALEXPER + SEX + FALEXPER *SEX, atti)

> summary(res1)

                         Df     Sum Sq    Mean Sq    F value    Pr(>F) 

FALEXPER      1      80.79       80.79         3.1845    0.08066 

SEX                  1       5.02        5.02           0.1979    0.65841 

FALEXPER:SEX  1    0.62        0.62           0.0243    0.87674 

Residuals    48 1217.80   25.37   

 

> res2<-aov(ATTITUDE ~ SEX + FALEXPER + SEX* FALEXPER, atti)

> summary(res2)

                            Df      Sum Sq     Mean Sq     F value      Pr(>F) 

SEX                     1        1.73         1.73             0.0682      0.79511 

FALEXPER         1         84.09       84.09           3.3143      0.07492 

SEX:FALEXPER  1         0.62         0.62             0.0243      0.87674 

Residuals              48      1217.80    25.37  

As we see, the order of entering the factors does make a difference.

(Alex Liu - May 7, 2004)

 

Copyright @ 2001-2005  The RM Institute