// Numbas version: finer_feedback_settings {"name": "Two factor ANOVA", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variables": {"f2t": {"templateType": "anything", "name": "f2t", "description": "", "definition": "[sum(f2L1),sum(f2L2)]", "group": "Ungrouped variables"}, "f1tsqovern": {"templateType": "anything", "name": "f1tsqovern", "description": "", "definition": "[f1t[0]^2/20,f1t[1]^2/20]", "group": "Ungrouped variables"}, "r4": {"templateType": "anything", "name": "r4", "description": "", "definition": "repeat(round(normalsample(mu4,sig1)),num_samples)", "group": "Sample data"}, "n": {"templateType": "anything", "name": "n", "description": "
The total number of measurements across all the samples
", "definition": "4*num_samples", "group": "Statistics"}, "r3": {"templateType": "anything", "name": "r3", "description": "", "definition": "repeat(round(normalsample(mu3,sig1)),num_samples)", "group": "Sample data"}, "f2btss": {"templateType": "anything", "name": "f2btss", "description": "Between treatments sum of squares ($\\mathit{BTSS}$) of Factor 1
", "definition": "precround(f2stovern-g^2/40,2)", "group": "Statistics"}, "r1": {"templateType": "anything", "name": "r1", "description": "", "definition": "repeat(round(normalsample(mu1,sig1)),num_samples)", "group": "Sample data"}, "mean1": {"templateType": "anything", "name": "mean1", "description": "Sample mean of sample 1
", "definition": "precround(mean(r1),2)", "group": "Statistics"}, "mean3": {"templateType": "anything", "name": "mean3", "description": "Sample mean of sample 3
", "definition": "precround(mean(r3),2)", "group": "Statistics"}, "f2l1": {"templateType": "anything", "name": "f2l1", "description": "", "definition": "r1+r3", "group": "Ungrouped variables"}, "tol": {"templateType": "anything", "name": "tol", "description": "", "definition": "0.001", "group": "Ungrouped variables"}, "mu4": {"templateType": "anything", "name": "mu4", "description": "Population mean of sample 4
", "definition": "mu3-mu4_diff", "group": "Ungrouped variables"}, "f1l1": {"templateType": "anything", "name": "f1l1", "description": "", "definition": "r1+r2", "group": "Ungrouped variables"}, "ivr": {"templateType": "anything", "name": "ivr", "description": "", "definition": "precround(interactionss/mrs,2)", "group": "Statistics"}, "mu1": {"templateType": "randrange", "name": "mu1", "description": "The population mean of sample 1
", "definition": "random(20..25#0.5)", "group": "Editable variables"}, "t": {"templateType": "anything", "name": "t", "description": "", "definition": "[sum(r1),sum(r2),sum(r3),sum(r4)]", "group": "Ungrouped variables"}, "mu3": {"templateType": "randrange", "name": "mu3", "description": "The population mean of sample 3
", "definition": "random(22..26#0.5)", "group": "Editable variables"}, "ssq": {"templateType": "anything", "name": "ssq", "description": "", "definition": "[sum(map(x^2,x,r1)),sum(map(x^2,x,r2)),sum(map(x^2,x,r3)),sum(map(x^2,x,r4))]", "group": "Ungrouped variables"}, "tss": {"templateType": "anything", "name": "tss", "description": "", "definition": "precround(ss-G^2/N,2)", "group": "Ungrouped variables"}, "tsqovern": {"templateType": "anything", "name": "tsqovern", "description": "$t^2/n$
", "definition": "map(x/num_samples,x,t)", "group": "Ungrouped variables"}, "f2l2": {"templateType": "anything", "name": "f2l2", "description": "", "definition": "r2+r4", "group": "Ungrouped variables"}, "f1ssq": {"templateType": "anything", "name": "f1ssq", "description": "", "definition": "[sum(map(x^2,x,f1L1)),sum(map(x^2,x,f1L2))]", "group": "Ungrouped variables"}, "sig2": {"templateType": "randrange", "name": "sig2", "description": "Standard deviation in sample 2.
", "definition": "random(1..3#0.2)", "group": "Editable variables"}, "btss": {"templateType": "anything", "name": "btss", "description": "", "definition": "precround(stovern-G^2/N,2)", "group": "Ungrouped variables"}, "f1rss": {"templateType": "anything", "name": "f1rss", "description": "", "definition": "precround(f1ss-f1stovern,2)", "group": "Ungrouped variables"}, "w0": {"templateType": "anything", "name": "w0", "description": "", "definition": "switch(vvr[0]>=12.88,[1,0,0,0,0],vvr[0]>=7.41,[0,1,0,0,0],vvr[0]>=4.12,[0,0,1,0,0],vvr[0]>=2.86,[0,0,0,1,0],[0,0,0,0,1])", "group": "Ungrouped variables"}, "stovern": {"templateType": "anything", "name": "stovern", "description": "", "definition": "sum(tsqovern)", "group": "Ungrouped variables"}, "f2stovern": {"templateType": "anything", "name": "f2stovern", "description": "", "definition": "sum([f2t[0]^2/20,f2t[1]^2/20])", "group": "Ungrouped variables"}, "f2ssq": {"templateType": "anything", "name": "f2ssq", "description": "", "definition": "[sum(map(x^2,x,f2L1)),sum(map(x^2,x,f2L2))]", "group": "Ungrouped variables"}, "r2": {"templateType": "anything", "name": "r2", "description": "", "definition": "repeat(round(normalsample(mu2,sig2)),num_samples)", "group": "Sample data"}, "num_samples": {"templateType": "number", "name": "num_samples", "description": "The number of measurements in each sample.
", "definition": "10", "group": "Editable variables"}, "f1l2": {"templateType": "anything", "name": "f1l2", "description": "", "definition": "r3+r4", "group": "Ungrouped variables"}, "factor1_name": {"templateType": "string", "name": "factor1_name", "description": "The name of Factor 1
", "definition": "\"personality\"", "group": "Editable variables"}, "g": {"templateType": "anything", "name": "g", "description": "", "definition": "sum(t)", "group": "Ungrouped variables"}, "f2vr": {"templateType": "anything", "name": "f2vr", "description": "Variance ratio ($\\mathit{VR}$) of Factor 1
", "definition": "precround(f2btss/mrs,2)", "group": "Statistics"}, "f1stovern": {"templateType": "anything", "name": "f1stovern", "description": "", "definition": "sum(f1tsqovern)", "group": "Ungrouped variables"}, "factor2_levels": {"templateType": "list of strings", "name": "factor2_levels", "description": "The names of the levels of Factor 2
", "definition": "[ \"baseline\", \"stress\" ]", "group": "Editable variables"}, "mean2": {"templateType": "anything", "name": "mean2", "description": "Sample mean of sample 2
", "definition": "precround(mean(r2),2)", "group": "Statistics"}, "vvr": {"templateType": "anything", "name": "vvr", "description": "", "definition": "[f1vr,f2vr,ivr]", "group": "Ungrouped variables"}, "f1t": {"templateType": "anything", "name": "f1t", "description": "", "definition": "[sum(f1L1),sum(f1L2)]", "group": "Ungrouped variables"}, "mu2_diff": {"templateType": "randrange", "name": "mu2_diff", "description": "Difference between the population means of samples 1 and 2 (mu1
and mu2
)
The name of the value being measured.
", "definition": "\"GSR\"", "group": "Editable variables"}, "w1": {"templateType": "anything", "name": "w1", "description": "", "definition": "switch(vvr[1]>=12.88,[1,0,0,0,0],vvr[1]>=7.41,[0,1,0,0,0],vvr[1]>=4.12,[0,0,1,0,0],vvr[1]>=2.86,[0,0,0,1,0],[0,0,0,0,1])", "group": "Ungrouped variables"}, "f1btss": {"templateType": "anything", "name": "f1btss", "description": "Between treatments sum of square ($\\mathit{BTSS}$) of Factor 1
", "definition": "precround(f1stovern-g^2/40,2)", "group": "Statistics"}, "w2": {"templateType": "anything", "name": "w2", "description": "", "definition": "switch(vvr[2]>=12.88,[1,0,0,0,0],vvr[2]>=7.41,[0,1,0,0,0],vvr[2]>=4.12,[0,0,1,0,0],vvr[2]>=2.86,[0,0,0,1,0],[0,0,0,0,1])", "group": "Ungrouped variables"}, "mu4_diff": {"templateType": "randrange", "name": "mu4_diff", "description": "Difference between the population means of samples 3 and 4 (mu3
and mu4
)
Variance ratio ($\\mathit{VR}$) of Factor 1
", "definition": "precround(f1btss/mrs,2)", "group": "Statistics"}, "mean4": {"templateType": "anything", "name": "mean4", "description": "Sample mean of sample 4
", "definition": "precround(mean(r4),2)", "group": "Statistics"}, "rss": {"templateType": "anything", "name": "rss", "description": "", "definition": "precround(ss-stovern,2)", "group": "Statistics"}, "factor1_levels": {"templateType": "list of strings", "name": "factor1_levels", "description": "Names of the levels of Factor 1
", "definition": "[ \"normal\", \"antisocial\" ]", "group": "Editable variables"}, "sig1": {"templateType": "randrange", "name": "sig1", "description": "Standard deviation in samples 1, 3 and 4.
", "definition": "random(2..3#0.2)", "group": "Editable variables"}, "mu2": {"templateType": "anything", "name": "mu2", "description": "The population mean of sample 2
", "definition": "mu1-mu2_diff", "group": "Ungrouped variables"}, "interactionss": {"templateType": "anything", "name": "interactionss", "description": "", "definition": "btss-f1btss-f2btss", "group": "Ungrouped variables"}, "f2ss": {"templateType": "anything", "name": "f2ss", "description": "", "definition": "sum(f2ssq)", "group": "Ungrouped variables"}, "mrs": {"templateType": "anything", "name": "mrs", "description": "", "definition": "precround(RSS/36,2)", "group": "Statistics"}, "ss": {"templateType": "anything", "name": "ss", "description": "", "definition": "sum(ssq)", "group": "Ungrouped variables"}, "factor2_name": {"templateType": "string", "name": "factor2_name", "description": "The name of Factor 2
", "definition": "\"stimulus\"", "group": "Editable variables"}, "w": {"templateType": "anything", "name": "w", "description": "", "definition": "[w0,w1,w2]", "group": "Ungrouped variables"}}, "statement": "Individuals who are identified as having an antisocial personality disorder may also have reduced physiological responses to anxiety-producing stimuli.
\nOne way of measuring this response is with ”galvanic skin response” (GSR), a measurable reduction in the electrical resistance on the skin. (This is the basis of how a lie detector works.)
\nThe following data represent the results of an experiment to compare the responses of normal and antisocial individuals in regular (baseline) and stress-provoking situations (low score reflects a more anxious individual).
\n{capitalise(factor1_name)}{capitalise(factor2_name)}
\n{capitalise(factor1_levels[0])} | {capitalise(factor2_levels[0])} | \n$\\var{r1[0]}$ | \n$\\var{r1[1]}$ | \n$\\var{r1[2]}$ | \n$\\var{r1[3]}$ | \n$\\var{r1[4]}$ | \n$\\var{r1[5]}$ | \n$\\var{r1[6]}$ | \n$\\var{r1[7]}$ | \n$\\var{r1[8]}$ | \n$\\var{r1[9]}$ | \n
---|---|---|---|---|---|---|---|---|---|---|---|
{capitalise(factor2_levels[1])} | \n$\\var{r2[0]}$ | \n$\\var{r2[1]}$ | \n$\\var{r2[2]}$ | \n$\\var{r2[3]}$ | \n$\\var{r2[4]}$ | \n$\\var{r2[5]}$ | \n$\\var{r2[6]}$ | \n$\\var{r2[7]}$ | \n$\\var{r2[8]}$ | \n$\\var{r2[9]}$ | \n|
{capitalise(factor1_levels[1])} | {capitalise(factor2_levels[0])} | \n$\\var{r3[0]}$ | \n$\\var{r3[1]}$ | \n$\\var{r3[2]}$ | \n$\\var{r3[3]}$ | \n$\\var{r3[4]}$ | \n$\\var{r3[5]}$ | \n$\\var{r3[6]}$ | \n$\\var{r3[7]}$ | \n$\\var{r3[8]}$ | \n$\\var{r3[9]}$ | \n
{capitalise(factor2_levels[1])} | \n$\\var{r4[0]}$ | \n$\\var{r4[1]}$ | \n$\\var{r4[2]}$ | \n$\\var{r4[3]}$ | \n$\\var{r4[4]}$ | \n$\\var{r4[5]}$ | \n$\\var{r4[6]}$ | \n$\\var{r4[7]}$ | \n$\\var{r4[8]}$ | \n$\\var{r4[9]}$ | \n
Carry out a two factor ANOVA on the data to test the following null hypotheses:
\nNow complete the following two factor ANOVA table from this data. Input the $\\mathit{SS}$, $\\mathit{MS}$ and $\\mathit{VR}$ data to 2 decimal places.
\nSource | df | SS | MS | VR |
---|---|---|---|---|
{capitalise(factor1_name)} | \n[[0]] | \n[[1]] | \n[[2]] | \n[[3]] | \n
{capitalise(factor2_name)} | \n[[4]] | \n[[5]] | \n[[6]] | \n[[7]] | \n
Interaction | \n[[8]] | \n[[9]] | \n[[10]] | \n[[11]] | \n
Residual | \n[[12]] | \n[[13]] | \n[[14]] | \n- | \n
Total | \n[[15]] | \n[[16]] | \n- | \n- | \n
Also input the mean values of the factors at their various levels:
\n\n | $\\overline{x_i}$ |
---|---|
{capitalise(factor1_levels[0])}, {factor2_levels[0]} | \n[[17]] | \n
{capitalise(factor1_levels[0])}, {factor2_levels[1]} | \n[[18]] | \n
{capitalise(factor1_levels[1])}, {factor2_levels[0]} | \n[[19]] | \n
{capitalise(factor1_levels[1])}, {factor2_levels[1]} | \n[[20]] | \n
Using the following $p$-values for the $F_{1,36}$ statistic find the appropriate significance levels for the factors as given by their $\\mathit{VR}$ value and then comment on the null hypotheses for each factor and the interaction.
\n$10\\%$ | \n$5\\%$ | \n$1\\%$ | \n$0.1\\%$ | \n
$2.86$ | \n$4.12$ | \n$7.41$ | \n$12.88$ | \n
[[0]]
", "gaps": [{"marks": 0, "minMarks": 0, "answers": ["Very strong rejection, $p \\le 0.001$.", "Strong rejection, $0.001\\lt p \\le 0.01$.", "Rejection, $0.01\\lt p \\le 0.05$.", "Accept, but investigate, $0.05\\lt p \\le 0.1$.", "Accept, $p \\gt 0.1$."], "maxAnswers": 0, "matrix": "w", "maxMarks": 0, "displayType": "radiogroup", "variableReplacementStrategy": "originalfirst", "choices": ["{measurement_name}: no dependence upon {factor1_name}.", "{measurement_name}: no dependence upon {factor2_name}.", "No interaction between the factors."], "minAnswers": 0, "showCorrectAnswer": true, "scripts": {}, "type": "m_n_x", "shuffleAnswers": false, "layout": {"expression": ""}, "shuffleChoices": false, "variableReplacements": []}], "variableReplacementStrategy": "originalfirst", "variableReplacements": []}], "functions": {"pstdev": {"language": "jme", "type": "number", "parameters": [["l", "list"]], "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)"}, "dec": {"language": "jme", "type": "string", "parameters": [["vr", "number"]], "definition": "switch(\n vr>=12.88, \n'Very strongly reject the null hypothesis ($p\\\\le 0.001$)',\n vr>=7.41,\n'Strongly reject the null hypothesis ($0.001 \\\\lt p \\\\le 0.01$)',\n vr>=4.12, \n'Reject the null hypothesis ($0.01 \\\\lt p \\\\le 0.05$)',\n vr>=2.86,\n'Accept the null hypothesis ($0.05 \\\\lt p \\\\le 0.1$)',\n 'Accept the null hypothesis ($p\\\\gt 0.1$)'\n) "}}, "rulesets": {"std": ["all", "fractionNumbers", "!noLeadingMinus", "!collectNumbers"]}, "variable_groups": [{"variables": ["measurement_name", "factor1_name", "factor1_levels", "factor2_name", "factor2_levels", "mu1", "mu2_diff", "mu3", "mu4_diff", "sig1", "sig2", "num_samples"], "name": "Editable variables"}, {"variables": ["r1", "r2", "r3", "r4"], "name": "Sample data"}, {"variables": ["n", "f1btss", "f1vr", "f2btss", "f2vr", "ivr", "rss", "mrs", "mean1", "mean2", "mean3", "mean4"], "name": "Statistics"}], "preamble": {"css": "td, th {\n empty-cells:hide;\n}", "js": ""}, "tags": ["ANOVA", "average", "chain rule", "degrees of freedom", "F-test", "factors", "Factors", "levels", "mean", "p values", "statistics", "template", "two factor ANOVA", "variance"], "question_groups": [{"name": "", "pickQuestions": 0, "questions": [], "pickingStrategy": "all-ordered"}], "variablesTest": {"maxRuns": 100, "condition": ""}, "ungrouped_variables": ["w1", "w2", "w0", "f1l2", "f1l1", "f1ssq", "tol", "btss", "tss", "f1t", "w", "f2ssq", "f2t", "ssq", "vvr", "f1ss", "interactionss", "tsqovern", "mu4", "g", "mu2", "ss", "f1tsqovern", "f1rss", "f2l1", "f2l2", "stovern", "t", "f1stovern", "f2ss", "f2stovern"], "advice": "We have two factors: {factor1_name} and {factor2_name}.
\n{capitalise(factor1_name)} has two levels: {factor1_levels[0]} and {factor1_levels[1]}.
\n{capitalise(factor2_name)} has two levels: {factor2_levels[0]} and {factor2_levels[1]}.
\nFirst regard the different treatment combinations as a set of independent samples and analyse as for a one-way analysis with unrelated measurements. From this analysis, we obtain the Total Sum of Squares, the Between Treatments Sum of Squares ($\\mathit{BTSS}$) and Residual Sum of Squares ($\\mathit{RSS}$). Note that the degrees of freedom for this step are $\\var{n-4} = \\var{n}-4$ as there are $4$ treatments.
\nYou should obtain
\n$\\overline{x_i}$ | $T_i$ | $\\sum x^2$ | $n_i$ | |
---|---|---|---|---|
{capitalise(factor1_levels[0])}, {factor2_levels[0]} | \n$\\var{mean1}$ | \n$\\var{t[0]}$ | \n$\\var{ssq[0]}$ | \n$\\var{num_samples}$ | \n
{capitalise(factor1_levels[0])}, {factor2_levels[1]} | \n$\\var{mean2}$ | \n$\\var{t[1]}$ | \n$\\var{ssq[1]}$ | \n$\\var{num_samples}$ | \n
{capitalise(factor1_levels[1])}, {factor2_levels[0]} | \n$\\var{mean3}$ | \n$\\var{t[2]}$ | \n$\\var{ssq[2]}$ | \n$\\var{num_samples}$ | \n
{capitalise(factor1_levels[1])}, {factor2_levels[1]} | \n$\\var{mean4}$ | \n$\\var{t[3]}$ | \n$\\var{ssq[3]}$ | \n$\\var{num_samples}$ | \n
\n | \n | $G = \\var{g}$ | \nSum of Squares = $\\var{ss}$ | \n$N=\\var{n}$ | \n
From this we obtain:
\n\\[ \\mathit{BTSS} = \\sum \\frac{T_i^2}{\\var{num_samples}} - \\frac{G^2}{\\var{n}} = \\frac{\\var{t[0]}^2}{\\var{num_samples}}+\\frac{\\var{t[1]}^2}{\\var{num_samples}}+\\frac{\\var{t[2]}^2}{\\var{num_samples}}+\\frac{\\var{t[3]}^2}{\\var{num_samples}}-\\frac{\\var{g}^2}{\\var{n}}=\\var{btss}\\]
\n\\[\\mathit{TSS} = \\sum \\sum x^2- \\frac{G^2}{\\var{n}}=\\var{ss}- \\frac{\\var{g}^2}{\\var{n}}=\\var{tss} \\]
\nboth to 2 decimal places.
\n\\[\\mathit{RSS} = \\mathit{TSS} - \\mathit{BTSS} = \\var{tss} - \\var{btss} = \\var{rss} \\]
\nNow ignore the {factor2_name} factor and calculate totals $T_i$ for each level of {factor1_name}. From these totals calculate a variance estimate for {factor1_name} using the same method as before. The degrees of freedom will be one fewer than the number of levels of {factor2_name} and is therefore $1$.
\n\n{capitalise(factor1_levels[0])} ({factor2_levels[0]} and {factor2_levels[1]}) | \n$\\var{r1[0]}$ | \n$\\var{r1[1]}$ | \n$\\var{r1[2]}$ | \n$\\var{r1[3]}$ | \n$\\var{r1[4]}$ | \n$\\var{r1[5]}$ | \n$\\var{r1[6]}$ | \n$\\var{r1[7]}$ | \n$\\var{r1[8]}$ | \n$\\var{r1[9]}$ | \n$\\var{r2[0]}$ | \n$\\var{r2[1]}$ | \n$\\var{r2[2]}$ | \n$\\var{r2[3]}$ | \n$\\var{r2[4]}$ | \n$\\var{r2[5]}$ | \n$\\var{r2[6]}$ | \n$\\var{r2[7]}$ | \n$\\var{r2[8]}$ | \n$\\var{r2[9]}$ | \n
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{capitalise(factor1_levels[1])} ({factor2_levels[0]} and {factor2_levels[1]}) | \n$\\var{r3[0]}$ | \n$\\var{r3[1]}$ | \n$\\var{r3[2]}$ | \n$\\var{r3[3]}$ | \n$\\var{r3[4]}$ | \n$\\var{r3[5]}$ | \n$\\var{r3[6]}$ | \n$\\var{r3[7]}$ | \n$\\var{r3[8]}$ | \n$\\var{r3[9]}$ | \n$\\var{r3[0]}$ | \n$\\var{r4[1]}$ | \n$\\var{r4[2]}$ | \n$\\var{r4[3]}$ | \n$\\var{r4[4]}$ | \n$\\var{r4[5]}$ | \n$\\var{r4[6]}$ | \n$\\var{r4[7]}$ | \n$\\var{r4[8]}$ | \n$\\var{r4[9]}$ | \n
You should produce the following data from this table:
\n$T_i$ | $\\sum x^2$ | $n_i$ (number of observations) | |
---|---|---|---|
{capitalise(factor1_levels[0])} ({factor2_levels[0]} and {factor2_levels[1]}) | \n$\\var{f1t[0]}$ | \n$\\var{f1ssq[0]}$ | \n$\\var{2*num_samples}$ | \n
{capitalise(factor1_levels[1])} ({factor2_levels[0]} and {factor2_levels[1]}) | \n$\\var{f1t[1]}$ | \n$\\var{f1ssq[1]}$ | \n$\\var{2*num_samples}$ | \n
\n | $G = \\var{g}$ | \nSum of Squares = $\\var{f1ss}$ | \n$N = \\var{n}$ | \n
So we can calculate:
\n\\[\\text{Variance estimate for }\\var{factor1_name} = \\sum \\frac{T_i^2}{\\var{2*num_samples}}- \\frac{G^2}{\\var{n}}=\\frac{\\var{f1t[0]}^2}{\\var{2*num_samples}}+\\frac{\\var{f1t[1]}^2}{\\var{2*num_samples}}-\\frac{\\var{g}^2}{\\var{n}}=\\var{f1btss}\\]
\nRepeat step 2 with the factors switched, i.e. use the totals $T_i$ for the {factor2_name} factor levels, ignoring {factor1_name}. This gives a Between Treatments Sum of Squares. Again, the degrees of freedom will be one fewer than the number of levels of {factor1_name}, i.e. $2 - 1 = 1$.
\n{capitalise(factor2_levels[0])} ({factor1_levels[0]} and {factor1_levels[1]}) | \n$\\var{r1[0]}$ | \n$\\var{r1[1]}$ | \n$\\var{r1[2]}$ | \n$\\var{r1[3]}$ | \n$\\var{r1[4]}$ | \n$\\var{r1[5]}$ | \n$\\var{r1[6]}$ | \n$\\var{r1[7]}$ | \n$\\var{r1[8]}$ | \n$\\var{r1[9]}$ | \n$\\var{r2[0]}$ | \n$\\var{r3[1]}$ | \n$\\var{r3[2]}$ | \n$\\var{r3[3]}$ | \n$\\var{r3[4]}$ | \n$\\var{r3[5]}$ | \n$\\var{r3[6]}$ | \n$\\var{r3[7]}$ | \n$\\var{r3[8]}$ | \n$\\var{r3[9]}$ | \n
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{capitalise(factor2_levels[1])} ({factor1_levels[0]} and {factor1_levels[1]}) | \n$\\var{r2[0]}$ | \n$\\var{r2[1]}$ | \n$\\var{r2[2]}$ | \n$\\var{r2[3]}$ | \n$\\var{r2[4]}$ | \n$\\var{r2[5]}$ | \n$\\var{r2[6]}$ | \n$\\var{r2[7]}$ | \n$\\var{r2[8]}$ | \n$\\var{r2[9]}$ | \n$\\var{r4[0]}$ | \n$\\var{r4[1]}$ | \n$\\var{r4[2]}$ | \n$\\var{r4[3]}$ | \n$\\var{r4[4]}$ | \n$\\var{r4[5]}$ | \n$\\var{r4[6]}$ | \n$\\var{r4[7]}$ | \n$\\var{r4[8]}$ | \n$\\var{r4[9]}$ | \n
You should obtain the following data from this table:
\n$T_i$ | $\\sum x^2$ | $n_i$ (number of observations) | |
---|---|---|---|
{capitalise(factor2_levels[0])} ({factor1_levels[0]} and {factor1_levels[1]}) | \n$\\var{f2t[0]}$ | \n$\\var{f2ssq[0]}$ | \n$\\var{2*num_samples}$ | \n
{capitalise(factor2_levels[1])} ({factor1_levels[0]} and {factor1_levels[1]}) | \n$\\var{f2t[1]}$ | \n$\\var{f2ssq[1]}$ | \n$\\var{2*num_samples}$ | \n
\n | $G = \\var{g}$ | \nSum of Squares = $\\var{f2ss}$ | \n$N = \\var{n}$ | \n
So we can calculate:
\n\\[ \\text{Variance estimate for }\\var{factor2_name} = \\sum \\frac{T_i^2}{\\var{2*num_samples}}- \\frac{G^2}{\\var{n}}=\\frac{\\var{f2t[0]}^2}{\\var{2*num_samples}}+\\frac{\\var{f2t[1]}^2}{\\var{2*num_samples}}-\\frac{\\var{g}^2}{\\var{n}}=\\var{f2btss}\\]
\nNow determine a Sum of Squares for Interaction by subtracting the sums of squares obtained for {factor1_name} (Step 2) and {factor2_name} (step 3) from the overall Between Treatments Sum of squares obtained in Step 1. The degrees of freedom is also obtained by subtraction and is 1.
\nThis gives:
\n\\[\\text{Variance estimate for the interaction}= \\var{btss}-\\var{f1btss}-\\var{f2btss} = \\var{interactionss}\\]
\nWe now have all the terms required to construct the ANOVA table and hence test the null hypothesis relating to each factor and to the interaction. Note that the $\\mathit{VR}$ values are obtained by dividing the $\\mathit{RMS}$ value into the $\\mathit{MS}$ values for the factors and the interaction.
\nSource | df | SS | MS | VR | Decision |
---|---|---|---|---|---|
{capitalise(factor1_name)} | \n$1$ | \n$\\var{f1btss}$ | \n$\\var{f1btss}$ | \n$\\var{f1vr}$ | \n{dec(f1vr)} that {measurement_name} is independent of {factor1_name}. | \n
{capitalise(factor2_name)} | \n$1$ | \n$\\var{f2btss}$ | \n$\\var{f2btss}$ | \n$\\var{f2vr}$ | \n{dec(f2vr)} that {measurement_name} is independent of {factor2_name}. | \n
Interaction | \n$1$ | \n$\\var{interactionss}$ | \n$\\var{interactionss}$ | \n$\\var{ivr}$ | \n{dec(ivr)} that {factor1_name} and {factor2_name} are independent in terms of {measurement_name}. | \n
Residual | \n$\\var{n-4}$ | \n$\\var{rss}$ | \n$\\var{mrs}$ | \n- | \n\n |
Total | \n$\\var{n-1}$ | \n$\\var{precround(f1btss+f2btss+interactionss+rss,2)}$ | \n- | \n- | \n\n |
Template question. The student is asked to perform a two factor ANOVA to test the null hypotheses that the measurement does not depend on each of the factors, and that there is no interaction between the factors.
", "notes": "Change the distributions of the samples, and the names of the factors and measurement variable, by changing things in the \"editable variables\" group.
\nYou should also change the text in the statement and part prompts to suit your application.
\nIf you want to change the number of samples, you must add or remove columns from the tables listing the data.
"}, "showQuestionGroupNames": false, "type": "question", "contributors": [{"name": "YJ Kim", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/719/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}]}]}], "contributors": [{"name": "YJ Kim", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/719/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}]}