I want to run an ezANOVA
from the ez
package on multiple dependent variables in a loop and save the result into several variables. Each dependent variable is within a separate column of the same data frame.
all.dependent.variables <- c("dv1", "dv2")
for(dependent.variable in all.dependent.variables){
assign(paste(dependent.variable, ".aov.results", sep = ""),
ezANOVA(aov.data,
dv = dependent.variable,
wid = subject,
within = .(factor1, factor2),
return_aov = TRUE))
}
This is an example data frame:
aov.data <- structure(list(subject = structure(c(10L, 11L, 12L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L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, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L), .Label = c("1", "2",
"3", "4", "5", "6", "7", "8", "9", "10", "11", "12"), class = "factor"),
dv1 = c(650.2, 773.7, 686.4, 436.2, 625.3, 714.2, 892.6, 921.5,
711.2, 670.2, 725.8, 592.8, 672.7, 731.1, 707.2, 475.1, 645.4,
786.7, 949.5, 925.8, 715.5, 745.4, 750.8, 579.1, 683.3, 707.6,
693.7, 492.4, 698.8, 666.9, 914.4, 853.8, 724.4, 718.8, 872.9,
616.9, 706.4, 766.2, 676.2, 500, 753.8, 712.7, 1012.2, 947.8,
695.3, 735.6, 843.7, 596.1, 738.3, 705.2, 718.2, 534.1, 805.3,
814.1, 969.4, 1010.7, -999, 714.4, 815.4, 645.4, 835.4, 830.7,
776.7, 543.7, 757.2, 841.5, 1107.8, 915.8, -999, 707.4, 809.7,
671.1, 638.1, 726.7, 660.2, 455.7, 623.5, 716.1, 922.1, 804.5,
718.2, 674.6, 797.4, 572, 676.7, 726.6, 690.7, 498.8, 624.3,
764.1, 889.5, 823.4, 672.9, 701.8, 750.4, 557.2, 656.1, 701,
655.1, 472.7, 658.8, 660.6, 860.9, 811.3, 672.5, 681.7, 849.6,
571.2, 694, 777.5, 661.3, 488, 670.4, 725.3, 938.1, 862.7,
616.4, 732.2, 845.9, 582.4, 694.2, 694.6, 743.8, 480.5, 736.7,
740.9, 988.1, 827.5, 812.4, 725.5, 844.2, 628, 779.3, 770.3,
686.9, 494.3, 681.5, 850.5, 990.7, 810.1, 692.3, 779.7, 779.8,
590.4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
618.6, 713.9, 609.6, 468.6, 554.3, 580.8, 864.1, 843.3, 662.8,
645.5, 714.6, 555.5, 670.7, 759.3, 652.2, 468.1, 613.5, 712.3,
910.7, 782.4, 723.3, 742.8, 775.5, 553.2, 695.3, 726.2, 591.2,
479.2, 626.1, 643.3, 821.5, 753.9, 818.2, 655.8, 754.4, 592.9,
703.5, 792.5, 635, 485.3, 644.1, 667.9, 891.3, 780.9, 699.1,
725.1, 716, 587.2, 706.5, 754.6, 694.3, 485.5, 745.5, 649.3,
808.4, 780.5, 773.8, 676.3, 687.5, 685.3, 910.4, 821.5, 738.5,
525, 689.6, 758.4, 1021.5, 792, 789.3, 740.5, 722.8, 717.1,
653.3, 743.6, 620.3, 460.1, 575.3, 647.1, 849.3, 647, 691.2,
596.4, 714.6, 531.6, 678.7, 754.7, 600.4, 463.8, 560.8, 636.6,
844.3, 766.6, 725.3, 628.7, 784.4, 547.9, 630.3, 656.7, 705.3,
443.3, 607, 630.7, 861.5, 754.4, 770.8, 664.5, 728.3, 546.4,
741.5, 694, 620.4, 459.3, 587.9, 626.2, 893.8, 756.1, 731.8,
680.2, 836.4, 566.7, 619.4, 686.4, 704, 445.3, 652.7, 735.3,
839.4, 833.4, 763.7, 614.5, 794.4, 562.5, 713.2, 735.4, 655.4,
501.1, 635.6, 661.2, 880.6, 747.8, 807.8, 757.7, 772.4, 560.1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 662.7,
682.5, 590.1, 443.6, 623.2, 656.6, 852.6, 676.8, 646.6, 646,
677.6, 518, 664, 665.4, 609.8, 464.2, 696.5, 661, 894.7,
661.1, 659.6, 657.8, 713.4, 531.5, 739.5, 695.1, 656.5, 498.4,
648.1, 710, 897.8, 685, 671.3, 657, 767.5, 545.3, 808.6,
697.5, 667.2, 463.4, 695.3, 652.4, 857.2, 690.3, 766.1, 696.1,
690.5, 558.8, 746, 708.4, 690, 515.5, 788.8, 929.6, 802.1,
619.5, 510.8, 654.1, 811.8, 706.5, 977.8, 697.9, 700.9, 497.9,
700.9, 811.5, 969.3, 723, 886, 815.7, 757.5, 639.5, 688.4,
704, 617.8, 435.2, 628.8, 603.3, 865.3, 661.6, 645.9, 598.1,
646.8, 477.2, 646.8, 760.8, 634.3, 452.2, 600.1, 648.2, 923.8,
625.5, 676.9, 647.3, 688.6, 513.2, 591.9, 641.6, 632.6, 469.6,
606.4, 610.9, 835.1, 667.8, 599.7, 581.2, 704.4, 502.9, 746.9,
684.1, 689.3, 475.9, 692, 689, 824.9, 625.9, 696.4, 706.3,
715.3, 510.9, 650.9, 640.1, 663.5, 471.6, 682.3, 683.2, 831.9,
702, 685, 624.6, 698.2, 521.6, 759.8, 730.6, 661.1, 473.2,
644.4, 738.7, 932.5, 685.1, 816, 722.1, 783.3, 526.2, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), dv2 = c(2.941,
2.941, 5.882, 0, 0, 2.941, 8.824, 23.529, 35.294, 8.824,
17.647, 5.882, 2.941, 2.941, 2.941, 0, 0, 8.824, 8.824, 44.118,
29.412, 8.824, 2.941, 5.882, 5.882, 0, 5.882, 5.882, 0, 2.941,
23.529, 20.588, 17.647, 8.824, 8.824, 11.765, 2.941, 2.941,
8.824, 17.647, 0, 5.882, 26.471, 14.706, 47.059, 0, 17.647,
14.706, 23.529, 0, 23.529, 38.235, 17.647, 52.941, 61.765,
55.882, 94.118, 5.882, 41.176, 55.882, 17.647, 23.529, 35.294,
32.353, 20.588, 44.118, 55.882, 44.118, 85.294, 17.647, 41.176,
55.882, 0, 0, 0, 0, 0, 5.882, 5.882, 0, 29.412, 0, 0, 0,
0, 0, 0, 0, 0, 0, 5.882, 0, 32.353, 0, 5.882, 0, 0, 0, 0,
0, 0, 2.941, 5.882, 0, 20.588, 0, 0, 0, 2.941, 0, 0, 0, 0,
0, 11.765, 2.941, 35.294, 0, 0, 0, 2.941, 0, 5.882, 0, 0,
20.588, 29.412, 8.824, 55.882, 0, 2.941, 5.882, 0, 0, 5.882,
2.941, 2.941, 2.941, 14.706, 0, 52.941, 0, 11.765, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.941,
0, 0, 5.882, 5.882, 29.412, 32.353, 5.882, 5.882, 0, 2.941,
0, 5.882, 0, 0, 0, 11.765, 41.176, 23.529, 5.882, 5.882,
0, 17.647, 5.882, 17.647, 2.941, 2.941, 8.824, 26.471, 26.471,
44.118, 11.765, 11.765, 26.471, 2.941, 0, 5.882, 0, 0, 8.824,
17.647, 23.529, 44.118, 2.941, 5.882, 11.765, 20.588, 5.882,
17.647, 26.471, 17.647, 55.882, 47.059, 55.882, 61.765, 5.882,
32.353, 55.882, 41.176, 2.941, 38.235, 35.294, 0, 76.471,
50, 67.647, 76.471, 14.706, 55.882, 55.882, 5.882, 2.941,
0, 0, 0, 0, 2.941, 0, 35.294, 0, 2.941, 0, 5.882, 0, 0, 0,
0, 8.824, 8.824, 2.941, 20.588, 0, 0, 0, 5.882, 2.941, 0,
0, 0, 0, 2.941, 0, 35.294, 2.941, 0, 0, 0, 0, 2.941, 0, 0,
2.941, 0, 0, 38.235, 0, 2.941, 0, 8.824, 2.941, 0, 0, 0,
32.353, 26.471, 17.647, 41.176, 2.941, 0, 0, 2.941, 2.941,
5.882, 0, 0, 11.765, 8.824, 0, 55.882, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.941, 0, 5.882,
0, 0, 0, 5.882, 11.765, 26.471, 8.824, 2.941, 2.941, 2.941,
0, 8.824, 0, 0, 0, 11.765, 2.941, 11.765, 0, 8.824, 0, 8.824,
2.941, 11.765, 5.882, 2.941, 2.941, 26.471, 20.588, 26.471,
0, 2.941, 17.647, 11.765, 0, 2.941, 0, 2.941, 17.647, 20.588,
20.588, 26.471, 8.824, 5.882, 11.765, 35.294, 14.706, 32.353,
41.176, 5.882, 44.118, 52.941, 47.059, 73.529, 17.647, 50,
47.059, 35.294, 11.765, 32.353, 50, 8.824, 73.529, 76.471,
47.059, 82.353, 14.706, 47.059, 41.176, 0, 0, 0, 2.941, 0,
0, 14.706, 2.941, 8.824, 0, 0, 0, 8.824, 2.941, 0, 0, 0,
5.882, 0, 2.941, 2.941, 0, 5.882, 0, 8.824, 0, 2.941, 0,
0, 2.941, 2.941, 2.941, 11.765, 5.882, 0, 0, 2.941, 0, 2.941,
0, 0, 2.941, 2.941, 0, 17.647, 5.882, 2.941, 0, 5.882, 5.882,
11.765, 0, 0, 8.824, 32.353, 0, 44.118, 2.941, 5.882, 0,
2.941, 5.882, 11.765, 0, 0, 8.824, 17.647, 2.941, 50, 8.824,
5.882, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0), factor1 = 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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 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("level1", "level2", "level3"
), class = "factor")), .Names = c("subject", "dv1", "dv2",
"factor1", "factor2"), row.names = c(NA, 540L), class = "data.frame")
The problem with this approach is that R interprets the index dependent.variable
as the specifier for a column in the dataframe aov.data
and therefore returns the following error:
"dependent.variable" is not a variable in the data frame provided.
I've tried wrapping the index with eval()
or print()
but to no avail.
The independent variable is the cause. Its value is independent of other variables in your study. The dependent variable is the effect. Its value depends on changes in the independent variable.
Roughly speaking, independent variables represent function inputs, while dependent variables represent function outputs. The value of a dependent variable depends on what the input is. However, the independent variable does not depend on anything; it is just whatever you want to input!
Dependent variables are nothing but the variable which holds the phenomena which we are studying. Independent variables are the ones which through we are trying to explain the value or effect of the output variable (dependent variable) by creating a relationship between an independent and dependent variable.
A dependent variable is a variable whose value depends upon independent variable s. The dependent variable is what is being measured in an experiment or evaluated in a mathematical equation. The dependent variable is sometimes called "the outcome variable."
Yet another not good solution:
lapply(all.dependent.variables, function(i) {
eval(parse(text=
paste0('ezANOVA(data=aov.data,
dv=', i,',
wid=subject,
between=.(factor1, factor2),
return_aov = TRUE)')
))
})
OK, this is definitely not your fault ... ezANOVA
does some clever evaluation stuff internally which screws you up. Here's a horrible incantation that seems to work, but it might be best to (1) contact the package maintainer and see if they can find a way to fix the internals more elegantly; (2) consider whether you can get by with a more standard anova evaluator that doesn't do so much internal messing around ...
fitlist <- lapply(all.dependent.variables,
function(x) {
e1 <- expression(ezANOVA(aov.data,
dv = x,
wid = subject,
within = .(factor1, factor2),
return_aov = TRUE))
## now force evaluation of the "dv" component of the call
e1[[1]][["dv"]] <- eval(e1[[1]][["dv"]])
eval(e1)
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With