(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 9.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 157, 7] NotebookDataLength[ 13609, 483] NotebookOptionsPosition[ 11669, 408] NotebookOutlinePosition[ 12022, 424] CellTagsIndexPosition[ 11979, 421] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["ANOVA", "Title"], Cell[CellGroupData[{ Cell["Author", "Subsection"], Cell["\<\ Eric W. Weisstein March 22, 2002\ \>", "Text"], Cell[TextData[{ "This notebook downloaded from ", ButtonBox["http://mathworld.wolfram.com/notebooks/Statistics/ANOVA.nb", BaseStyle->"Hyperlink", ButtonData:>{ URL["http://mathworld.wolfram.com/notebooks/Statistics/ANOVA.nb"], None}], "." }], "Text"], Cell[TextData[{ "For more information, see Eric's ", StyleBox["MathWorld", FontSlant->"Italic"], " entry ", ButtonBox["http://mathworld.wolfram.com/ANOVA.html", BaseStyle->"Hyperlink", ButtonData:>{ URL["http://mathworld.wolfram.com/ANOVA.html"], None}], "." }], "Text"], Cell["\<\ \[Copyright]2005 Wolfram Research, Inc. except for portions noted otherwise\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Initialization", "Subsection"], Cell[BoxData[ RowBox[{"<<", "Statistics`ANOVA`"}]], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Comments", "Subsection"], Cell["Finish the hand computation.", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Example", "Section"], Cell[BoxData[ RowBox[{ RowBox[{"onewaydata", "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "7.0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "5.3"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "5.9"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "6.6"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "4.9"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "4.4"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "6.8"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "7.7"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "8.3"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "6.6"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "8.1"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "10.4"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "8.0"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "6.8"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "9.2"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "5.7"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "3.9"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "6.2"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "5.5"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "6.2"}], "}"}]}], "}"}]}], ";"}]], "Input"], Cell[CellGroupData[{ Cell[TextData[{ "Computed by ", StyleBox["Mathematica", FontSlant->"Italic"] }], "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"ANOVA", "[", "onewaydata", "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"ANOVA", "\[Rule]", InterpretationBox[GridBox[{ {"\<\"\"\>", "\<\"DF\"\>", "\<\"SumOfSq\"\>", "\<\"MeanSq\"\>", \ "\<\"FRatio\"\>", "\<\"PValue\"\>"}, {"\<\"Model\"\>", "3", "26.29349999999999`", "8.764499999999996`", "6.127949659150494`", "0.005616104919811349`"}, {"\<\"Error\"\>", "16", "22.884000000000004`", "1.4302500000000002`", "\<\"\"\>", "\<\"\"\>"}, {"\<\"Total\"\>", "19", "49.177499999999995`", "\<\"\"\>", "\<\"\"\>", "\<\"\"\>"} }, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[2.0999999999999996`]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}}], TableForm[{{ 3, 26.29349999999999, 8.764499999999996, 6.127949659150494, 0.005616104919811349}, { 16, 22.884000000000004`, 1.4302500000000002`}, { 19, 49.177499999999995`}}, TableHeadings -> {{"Model", "Error", "Total"}, { "DF", "SumOfSq", "MeanSq", "FRatio", "PValue"}}]]}], ",", RowBox[{"CellMeans", "\[Rule]", InterpretationBox[GridBox[{ {"\<\"All\"\>", GridBox[{ {"6.675000000000002`"} }, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.1]}, Offset[0.2]}, "RowsIndexed" -> {}}]}, { RowBox[{"\<\"Model\"\>", "[", "1", "]"}], GridBox[{ {"5.940000000000001`"} }, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.1]}, Offset[0.2]}, "RowsIndexed" -> {}}]}, { RowBox[{"\<\"Model\"\>", "[", "2", "]"}], GridBox[{ {"6.76`"} }, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.1]}, Offset[0.2]}, "RowsIndexed" -> {}}]}, { RowBox[{"\<\"Model\"\>", "[", "3", "]"}], GridBox[{ {"8.5`"} }, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.1]}, Offset[0.2]}, "RowsIndexed" -> {}}]}, { RowBox[{"\<\"Model\"\>", "[", "4", "]"}], GridBox[{ {"5.5`"} }, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.1]}, Offset[0.2]}, "RowsIndexed" -> {}}]} }, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[2.0999999999999996`]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}}], TableForm[{{"All", {6.675000000000002}}, { "Model"[1], {5.940000000000001}}, { "Model"[2], {6.76}}, { "Model"[3], {8.5}}, { "Model"[4], {5.5}}}]]}]}], "}"}]], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Computed by Hand", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"levels", "=", RowBox[{"Union", "[", RowBox[{"First", "/@", "onewaydata"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3", ",", "4"}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"Function", "[", RowBox[{"l", ",", RowBox[{"Count", "[", RowBox[{"onewaydata", ",", RowBox[{"_", "?", RowBox[{"(", RowBox[{ RowBox[{ RowBox[{"First", "[", "#", "]"}], "\[Equal]", "l"}], "&"}], ")"}]}]}], "]"}]}], "]"}], "/@", "levels"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{"5", ",", "5", ",", "5", ",", "5"}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"t", "=", RowBox[{"Transpose", "[", "onewaydata", "]"}]}], ";"}], "\n", RowBox[{"leveleddata", "=", RowBox[{ RowBox[{ RowBox[{ RowBox[{"t", "[", RowBox[{"[", "2", "]"}], "]"}], "[", RowBox[{"[", RowBox[{"Flatten", "[", RowBox[{"Position", "[", RowBox[{ RowBox[{"t", "[", RowBox[{"[", "1", "]"}], "]"}], ",", "#"}], "]"}], "]"}], "]"}], "]"}], "&"}], "/@", "levels"}]}]}], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"7.`", ",", "5.3`", ",", "5.9`", ",", "6.6`", ",", "4.9`"}], "}"}], ",", RowBox[{"{", RowBox[{"4.4`", ",", "6.8`", ",", "7.7`", ",", "8.3`", ",", "6.6`"}], "}"}], ",", RowBox[{"{", RowBox[{"8.1`", ",", "10.4`", ",", "8.`", ",", "6.8`", ",", "9.2`"}], "}"}], ",", RowBox[{"{", RowBox[{"5.7`", ",", "3.9`", ",", "6.2`", ",", "5.5`", ",", "6.2`"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"mean", "=", RowBox[{"Mean", "[", RowBox[{"Flatten", "[", "leveleddata", "]"}], "]"}]}], ",", RowBox[{"Mean", "/@", "leveleddata"}]}], "}"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"General", "::", "\<\"spell1\"\>"}], ":", " ", "\<\"Possible spelling error: new symbol name \\\"\\!\\(mean\\)\\\" is \ similar to existing symbol \\\"\\!\\(Mean\\)\\\".\"\>"}]], "Message"], Cell[BoxData[ RowBox[{"{", RowBox[{"6.675000000000002`", ",", RowBox[{"{", RowBox[{"5.94`", ",", "6.76`", ",", "8.5`", ",", "5.5`"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Mean", "[", RowBox[{"Mean", "/@", "leveleddata"}], "]"}]], "Input"], Cell[BoxData["6.675`"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Plus", "@@", RowBox[{"Flatten", "[", RowBox[{"(", RowBox[{ RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"#", "-", "mean"}], ")"}], "^", "2"}], "&"}], "/@", "leveleddata"}], ")"}], "]"}]}]], "Input"], Cell[BoxData["49.177499999999995`"], "Output"] }, Open ]], Cell[BoxData[{ RowBox[{ RowBox[{"k", "=", RowBox[{"Length", "[", "levels", "]"}]}], ";"}], "\n", RowBox[{ RowBox[{"n", "=", "5"}], ";"}]}], "Input"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"k", "-", "1"}], ",", RowBox[{"k", RowBox[{"(", RowBox[{"n", "-", "1"}], ")"}]}], ",", RowBox[{ RowBox[{"k", " ", "n"}], "-", "1"}]}], "}"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{"3", ",", "16", ",", "19"}], "}"}]], "Output"] }, Open ]] }, Open ]] }, Open ]] }, Open ]] }, WindowSize->{740, 867}, WindowMargins->{{12, Automatic}, {Automatic, 24}}, FrontEndVersion->"9.0 for Mac OS X x86 (32-bit, 64-bit Kernel) (March 5, \ 2013)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[579, 22, 22, 0, 92, "Title"], Cell[CellGroupData[{ Cell[626, 26, 28, 0, 44, "Subsection"], Cell[657, 28, 56, 3, 49, "Text"], Cell[716, 33, 266, 8, 30, "Text"], Cell[985, 43, 285, 10, 30, "Text"], Cell[1273, 55, 99, 2, 30, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[1409, 62, 36, 0, 44, "Subsection"], Cell[1448, 64, 61, 1, 28, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[1546, 70, 30, 0, 44, "Subsection"], Cell[1579, 72, 44, 0, 30, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[1660, 77, 26, 0, 80, "Section"], Cell[1689, 79, 1406, 44, 63, "Input"], Cell[CellGroupData[{ Cell[3120, 127, 98, 4, 44, "Subsection"], Cell[CellGroupData[{ Cell[3243, 135, 67, 1, 28, "Input"], Cell[3313, 138, 4776, 117, 183, "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[8138, 261, 38, 0, 44, "Subsection"], Cell[CellGroupData[{ Cell[8201, 265, 124, 3, 28, "Input"], Cell[8328, 270, 93, 2, 28, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[8458, 277, 348, 11, 28, "Input"], Cell[8809, 290, 93, 2, 28, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[8939, 297, 499, 16, 46, "Input"], Cell[9441, 315, 488, 14, 46, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[9966, 334, 217, 6, 28, "Input"], Cell[10186, 342, 226, 4, 35, "Message"], Cell[10415, 348, 176, 5, 28, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[10628, 358, 94, 2, 28, "Input"], Cell[10725, 362, 33, 0, 28, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[10795, 367, 261, 9, 28, "Input"], Cell[11059, 378, 46, 0, 28, "Output"] }, Open ]], Cell[11120, 381, 159, 5, 46, "Input"], Cell[CellGroupData[{ Cell[11304, 390, 225, 8, 28, "Input"], Cell[11532, 400, 85, 2, 28, "Output"] }, Open ]] }, Open ]] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)