I was trying to perform a robust anova using m-estimator, using the WSR2 package. Essentially, my data has 4 columns, the "case number" column, an age group column, a sex column, and the measurement column (in this case length), and I was interested in seeing if there is an interaction between sex and age group. Because my data violates a bunch of assumptions, I wanted to explore the robust anova options. Within the robust anova method one of them is using m-estimator, and based on the document explaining the package, the function for this method is: pbad2way (dependent_variable ~ independent_variable_1 * independent_variable_2, data = data, est = "mom". So in my case, my input script would be:
pad2way (Length_ar ~ age_group * Sex, data = length_ar, est = "mom")
However after inputing the script it returns an error message: Aggregation requires fun.aggregate: length used as default. The resulted p values are all the same with all the independent variables and interaction, which is clearly not correct. I was not sure where the problem comes from.
I have not done anything to the data except for changing the independent variables from characters to factors.
If I perform a posthoc test, using the function: mcp2a (dependent_variable ~ independent_variable_1 * independent_variable_2, data = data, est = "mom"), the output numbers seem to be more realistic, but because I don't know what caused the error in the actual statistical test, I'm not sure if I could trust the posthoc results.
I don't have enough reputation to post an image...so here is the line-by-line copy:
'data.frame': 162 obs. of 4 variables:
$ BMU_number: chr "032_4" "444_1" "444_2" "030_1" ...
$ Sex : Factor w/ 2 levels "F","M": 2 2 2 2 2 2 2 2 2 2 ...
$ age_group : Factor w/ 2 levels "above_50","below_50": 2 2 2 2 2 2 2 2 2 2 ...
$ Length_ar : num 2292 1794 709 1881 1969 ...
> pbad2way (Length_ar ~ age_group * Sex, data = length_ar, est = "mom") ## stats test function
Aggregation requires fun.aggregate: length used as default ##this is the message I get
Call:
pbad2way(formula = Length_ar ~ age_group * Sex, data = length_ar,
est = "mom")
p.value
age_group 0.7763 ## all three p values are the same...
Sex 0.7763
age_group:Sex 0.7763
> mcp2a(Length_ar ~ age_group * Sex, data = length_ar, est = "mom") ## posthoc test function
Call:
mcp2a(formula = Length_ar ~ age_group * Sex, data = length_ar,
est = "mom")
psihat ci.lower ci.upper p-value
age_group1 -675.8041 -1127.32346 -351.0643 0.00000
Sex1 -146.3062 -584.00781 259.8879 0.18698
age_group1:Sex1 468.5136 1.14471 786.8859 0.02504
I am very very new to R, no coding experience, and do not know much about stats either...but thanks in advance for any help/suggestions!
I encountered this problem from the beginning. When I googled the error message the description looks like a formatting issue, so I cleaned up the data but the problem persisted. I have not found anything online where people encounter the same issue using the same package and function as I did. There are also more arguments that can be included in the function, such as nboot, pro.dis. I don't really understand what these mean and would do in the stats calculation, but I did try including them as well as showcased in the package description document, but I still encounter the same error message.