0
$\begingroup$

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]
$\endgroup$
  • 1
    $\begingroup$ 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. $\endgroup$ – JimB Dec 14 '19 at 2:51
1
$\begingroup$

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}]

ANOVA table

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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