# What to input for Nested ANOVA on Mathematica (SS-Subgroup B)

Does anyone know how to run a nested ANOVA on Mathematica, given a dataset? For example: PCB Level 1, Sample 1: {1,2,3}; PCB Level 1, Sample 2: {4,3,2}; PCB Level 2, Sample 1: {1,5,7}; and PCB Level 2, Sample 2: {5,3,7}. I'm not sure what to input for SS-Subgroup B.

It keeps saying "Thread: Objects of unequal length in"

<<Hypothesis Testing
Concentrations={{{43, 44, 47}, {56, 54, 33}}, {{11, 33, 23}, {33, 26, 36}}};
Data=Concentrations;
a=Length[Data];
b = Length[Data[[1]]];
n = Length[Data[[1, 1]]];
va = a - 1;
vb = a (b - 1);
vw = a*b (n - 1);
vt = a*b*n - 1;
Ameans = N[Map[Mean[Flatten[#]] &, Data]];
Bmeans = N[Map[Mean[#] &, Flatten[Data, 1]]];
GrandMean = N[Mean[Flatten[Data]]];
SSb = n*Total[(Bmeans-Ameans)^2]
Thread::tdlen: Objects of unequal length in {44.6667,47.6667,22.3333,31.6667}+{-46.1667,-27.} cannot be combined.
3 Total[({-46.1667, -27.} + {44.6667, 47.6667, 22.3333, 31.6667})^2]

• If "It keeps saying", is your Mathematica code talking, please show your code. If you are asking if Mathematica has a specific function for mixed models, it doesn't. But one can put together code to do so. – JimB Dec 14 '19 at 2:51

I don't know if I've parsed your data appropriately but the following should give you some suggestions. (If you have the desired analysis in SAS or R or SPSS, then you can check to see that the same results are found.)

data = {{1, 1, 1},
{1, 1, 2},
{1, 1, 3},
{1, 2, 4},
{1, 2, 3},
{1, 2, 2},
{2, 1, 1},
{2, 1, 5},
{2, 1, 7},
{2, 2, 5},
{2, 2, 3},
{2, 2, 7}};
Needs["ANOVA"]
ANOVA[data, {PCB, PCB  Sample}, {PCB, Sample}]


The F-ratio won't be correct for the "Sample within PCB" term (labeled "PCB Sample") but you'll have the necessary information to construct the appropriate F-test.

• Sorry, if this is just to complete a homework assignment, I think enough hints have been given. – JimB Dec 14 '19 at 14:35