1
$\begingroup$

I've datas as folllow:

 DF=structure(list(exp_code = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 
20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 
33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 1L, 2L, 3L, 4L, 5L, 6L, 
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 
20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 
33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 1L, 2L, 3L, 4L, 5L, 6L, 
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 
20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 
33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 1L, 2L, 3L, 4L, 5L, 6L, 
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 
20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 
33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 1L, 2L, 3L, 4L, 5L, 6L, 
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 
20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 
33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L), .Label = c("IV (4)", 
"VI (6)", "CH (9)", "LE (9)", "VI (11)", "JU (14)", "AB (15)", 
"LE (16)", "AT (17)", "SA (17)", "OR (18)", "EP (20)", "PO (22)", 
"SA (23)", "RU (25)", "SA (26)", "BR (28)", "GR (28)", "CH (29)", 
"MA (30)", "PE (30)", "CH (32)", "MA (32)", "BO (33)", "LA (33)", 
"LO (35)", "AR (36)", "LA (36)", "MA (37)", "EG (38)", "CH (39)", 
"BR (43)", "ET (43)", "BR (44)", "BI (47)", "SA (50)", "VE (50)", 
"ET (51)", "SE (52)", "DO (58)"), class = "factor", scores = structure(c(15, 
36, 17, 47, 33, 28, 43, 44, 29, 32, 39, 9, 58, 38, 20, 43, 51, 
28, 4, 14, 33, 36, 16, 9, 35, 30, 32, 37, 18, 30, 22, 25, 17, 
23, 26, 50, 52, 50, 11, 6), .Dim = 40L, .Dimnames = list(c("AB (15)", 
"AR (36)", "AT (17)", "BI (47)", "BO (33)", "BR (28)", "BR (43)", 
"BR (44)", "CH (29)", "CH (32)", "CH (39)", "CH (9)", "DO (58)", 
"EG (38)", "EP (20)", "ET (43)", "ET (51)", "GR (28)", "IV (4)", 
"JU (14)", "LA (33)", "LA (36)", "LE (16)", "LE (9)", "LO (35)", 
"MA (30)", "MA (32)", "MA (37)", "OR (18)", "PE (30)", "PO (22)", 
"RU (25)", "SA (17)", "SA (23)", "SA (26)", "SA (50)", "SE (52)", 
"VE (50)", "VI (11)", "VI (6)")))), category_result = structure(c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 
5L, 5L, 5L, 5L, 5L, 5L, 5L), .Label = c("1", "2", "3", "4", "5"
), class = "factor"), value = c(5.5, 25, 17.5, 7.5, 6.5, 15.5, 
1, 1.33333333333333, 8, 7.33333333333333, 4.5, 10, 1, 19.1666666666667, 
1, 6, 13, 0, 0, 5, 1, 0.5, 0.333333333333333, 7, 1, 0, 0, 0.5, 
1.5, 0.5, 0.5, 0.5, 1.5, 2.5, 1.5, 0, 1, 5.5, 0.5, 1.5, 0, 0, 
4.5, 0.5, 0, 2, 1, 0.333333333333333, 0.5, 2.33333333333333, 
0.5, 0, 0, 8.66666666666667, 0, 3, 5, 1, 0, 1, 0, 1.5, 1.33333333333333, 
1, 0, 0.5, 2, 1, 0, 0, 0, 0, 0, 1.5, 0, 0.5, 0, 0, 0.5, 0, 24.5, 
15, 24, 6, 10.5, 18.5, 10, 4.33333333333333, 2.5, 18.3333333333333, 
13, 11, 1, 15.1666666666667, 3, 18, 17, 2, 3, 16, 0, 4, 1.33333333333333, 
4, 3, 2.5, 7, 4.5, 1.5, 0.5, 0.5, 0.5, 3.5, 13, 0.5, 5.5, 0, 
3.5, 2, 4.5, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 
1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 
1, 0, 1, 1, 2, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 2, 
0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 
0)), row.names = c(NA, -200L), .Names = c("exp_code", "category_result", 
"value"), class = "data.frame")

For each experiment code exp_code I obtain for each one or few categories of result category_result with different quantities defined by value.

I want to compare the variance of category_result between experiment by using the value of the 5 categories. So I thinked about ANOVA. But Here, the problem is that there is three factors : variation of value of each category_result between exp code ?

EDIT 1: Trial on two-way anova, i googled it so I refer to this Link :

DF <- as.data.frame(DF)
int <- aov(DF$value ~ DF$exp_code + DF$category_result)
summary(int)

Do you think that this is an efficient way, I should reject the H0 according the p-value, but I want to be sure this is the good way to do it :

               Df Sum Sq Mean Sq F value   Pr(>F)    
DF$exp_code         39   1432    36.7   2.754 5.15e-06 ***
DF$category_result   4   1565   391.3  29.360  < 2e-16 ***
Residuals          156   2079    13.3

EDIT 2 : Datas plot. Not the same number of exp_code : for example IV (4) is repeated 31 times. These experiments can produce few category_result at the same time, so I've weighting them, i.e., if two categories : each one 0.5, 0.5 but the total would be an integer.

enter image description here

EDIT 3 : Finally, use ez package in order to mesure variability of category_result between exp_code, so here as I understood it is a rAnova. I want just confirmation that i'm doing it in the right way and that I understood your precious tips correctly.

ezANOVA(data=DF, dv=.(value), wid=.(exp_code), within=.(category_result), detailed=TRUE, type=3)

Thanks a lot!

$\endgroup$

2 Answers 2

3
$\begingroup$

This looks like a repeated-measures design, if I understood you correctly. Now if you want to compare value between category_result within each exp_code, you might want to use repeated-measures ANOVA. There are different ways to do it in R, the simplest one would be to use ezANOVA from ez package. If you need to know the effect of exp_code as well, then simple aov will do fine. I also don't know if you want to analyze the interaction of exp_code and category_result.

$\endgroup$
3
  • $\begingroup$ The issue is that i do not have the same experiment nb for each type of 'exp_code', so values is not comparable and I cannot use percentage because it can bias result (i.e. I can have 100% for cat 1 if I have only one experiment in this exp_code, so it is falsly amplified). Please look on edit 2. The idea is to see if there is some experiment that produce more a specific 'category_result' than other, taking into account that i do not have the same nb of 'exp_code'. Therefore, I'm aiming mesuring variability of categories between 'exp_code' . In Edit 3 I used ezanova. $\endgroup$
    – ranell
    Commented Oct 5, 2016 at 20:57
  • $\begingroup$ the code with ezANOVA looks right. Note that it is aggregating the values of your DV(value) over the levels of exp_code and category_result. In that way, it ignores the variability in number of categories between exp_codes. You might also want to take a look at mixed models (lme4) where you can avoid aggregating. $\endgroup$ Commented Oct 6, 2016 at 9:50
  • $\begingroup$ Ok will try lme4, thanks a lot. I have additional question in terms of methodology and i'm sorry because I'm confused: Now if I want to study the variance of 'category_result' within 'exp_code', why do not mesuring covariance that exist between 'category_result' in each 'exp_code'? Thks a lot. $\endgroup$
    – ranell
    Commented Oct 6, 2016 at 19:27
1
$\begingroup$

You need a two-way anova ( for two factors) or multi-factor Anova (for multiple factors). Not quite sure if there is a specific package available in R for this but you can get this with using lm() function in R as well.

update: Looks all ok and yes they are both significant. As @Andrey Chetverikov mentioned below,. Just make sure whether your research design is repeated-measure or these experiments are independent... and accordingly use either repeated ANOVA or two way ANOVA. Other point is if you want to consider the interaction between these two factors and also perform an ad hoc test to see where the group differences are .

$\endgroup$
1
  • $\begingroup$ see update above $\endgroup$
    – RomRom
    Commented Oct 5, 2016 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.