statistics - ANOVA - comparing 3 groups in R -


i attempting analyze data set research project have ran lot of issues, , have not been able find directly related answer online. have worked other statistical programs new r. have had hardest time figuring out how shape data set best answer questions.

in research participants asked answer questions pictures presented, these pictures of faces exhibiting 3 emotions (happy, angry, sad) - want compare answers given each question in regards pictures. meaning want see if there differences between these 3 groups.

i have used 1 way anova in past doing - in minitab put images 3 factors (1,2,3) , scores given question in column next it. specific picture , score particular question lined horizontally.

  image pleasing 1     1        3 2     1        2 3     1        1 4     1        1 5     1        1 6     1        2 

this how have set in r - when try run anova cannot because image still class of integer , not factor. therefor gives me this:

> paov <- aov(image ~ pleasing) > summary(paov)              df sum sq mean sq f value pr(>f) pleasing      1    0.7  0.6546   0.978  0.323 residuals   813  544.3  0.6696                26 observations deleted due missingness 

and post-hoc tukey's test meaningless. in minitab able show me mean score pleasing related each image , tell me how different. how can make image factor in r? , how can compare these 3 groups in there scores of pleasing?

given description of data, here's way perform analysis of variance , tukey test. first, not-so-random data (which give "interesting" results):

set.seed(40) dat <- data.frame(image = factor(rep(1:3, each=10)),                    pleasing = c(sample(1:2, 10, replace=t),                                sample(c(1,3), 10, replace=t),                                sample(2:3, 10, replace=t))) head(dat) #   image pleasing # 1     1        2 # 2     1        2 # 3     1        2 # 4     1        1 # 5     1        1 # 6     1        1 

the aov quite simple. note have use data if variables in dataframe (using attach isn't recommended):

dat.aov <- aov(pleasing ~ image, data=dat) summary(dat.aov) #             df sum sq mean sq f value  pr(>f)    # image        2    7.2   3.600   6.568 0.00474 ** # residuals   27   14.8   0.548                    # --- # signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

now tukey, there different ways in r. use package multcomp because provides more information results:

library(multcomp)  tukey <- cld(glht(dat.aov, linfct = mcp(image = "tukey")), decreasing = true)  tukey$mcletters$letters #  1    2    3  # "b" "ab"  "a"  

the syntax looks rather complicated because in multcomp use general linear hypothesis function (glht), in perform multiple comparison (mcp) , extract compact letter display of tukey results (cld).

you can plot tukey results, although boxplots don't nice kind of data:

enter image description here

as final note, it's important mention use kind of analysis continuous data (experimental lab measures), , i'm not sure it's correct categorical data (1-3 expression choice).


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -