// Numbas version: finer_feedback_settings {"name": "Maths Support: Hypothesis testing with the Student t-distribution", "navigation": {"onleave": {"action": "none", "message": ""}, "reverse": true, "allowregen": true, "preventleave": false, "browse": true, "showfrontpage": false, "showresultspage": "never"}, "duration": 0.0, "metadata": {"notes": "", "description": "", "licence": "Creative Commons Attribution 4.0 International"}, "timing": {"timeout": {"action": "none", "message": ""}, "timedwarning": {"action": "none", "message": ""}}, "shufflequestions": false, "questions": [], "percentpass": 75.0, "allQuestions": true, "pickQuestions": 0, "type": "exam", "feedback": {"showtotalmark": true, "advicethreshold": 0.0, "showanswerstate": true, "showactualmark": true, "allowrevealanswer": true, "enterreviewmodeimmediately": false, "showexpectedanswerswhen": "never", "showpartfeedbackmessageswhen": "always", "showactualmarkwhen": "always", "showtotalmarkwhen": "always", "showanswerstatewhen": "always", "showadvicewhen": "never"}, "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": [{"name": "Independent two sample t-test.", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}], "functions": {"pstdev": {"definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "type": "number", "language": "jme", "parameters": [["l", "list"]]}}, "tags": ["average", "data analysis", "differences", "elementary statistics", "hypothesis testing", "mean", "standard deviation", "statistics", "stats", "t-test", "two sample t-test", "variance"], "advice": "\n
We test the following hypothesis,
\n$H_0:\\; \\mu_1=\\mu_2$ versus $H_1:\\; \\mu_1 \\neq \\mu_2$
\nWe find that the mean score of Group 1 is $\\overline{x}_1=\\var{m1}$ with standard deviation $s_1=\\var{sd1}$ and the mean score of Group 2 is $\\overline{x}_2=\\var{m2}$ with standard deviation $s_2=\\var{sd2}$.
\nAll calculated to 3 decimal places.
\nUsing the formula for the two-sample t-statistic as shown above with $n_1=n_2=10$:
\nThe estimate of the pooled variance is calculated to be:
\n\\[s^2=\\frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}= \\frac{\\var{n1-1}\\times \\var{sd1}^2+\\var{n2-1}\\times \\var{sd2}^2}{\\var{n1+n2-2}}=\\var{s^2}.\\]
\nHence $s= \\sqrt{\\var{s^2}}=\\var{s}$ to 3 decimal places.
\nWe find that the t-statistic has value:
\n\\[\\begin{eqnarray*}T&=& \\frac{(\\overline{x}_1-\\overline{x}_2)-(\\mu_1-\\mu_2)}{s\\sqrt{\\frac{1}{n_1}+\\frac{1}{n_2}}}\\\\&=&\\frac{(\\var{m1}-\\var{m2})-(0)}{\\var{s}\\sqrt{\\frac{1}{\\var{n1}}+\\frac{1}{\\var{n2}}}}\\\\&=&\\var{tvalue}\\end{eqnarray*}\\] to 3 decimal places.
\nOur test statistic is $|T|=\\var{abs(tvalue)}$.
\nGiven that we have $n_1+n_2-2=18$ degrees of freedom, we look up this value on the T-distribution table for $t_{18}$
\n\\[\\begin{array}{r|rrrrr}&0.20&0.10&0.05&0.01&0.001\\\\\\hline18&1.330&1.734&2.101&2.878&3.922\\end{array}\\]
\nWe see that the t-statistic {msg[t]} and the table tells us that the $p$ value {pmsg[t]}.
\nHence we conclude that we {cmsg[t]} the null hypothesis. There is {cmsg1[t]} evidence of a difference between the average scores of the two groups.
\n\n ", "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "parts": [{"stepspenalty": 0.0, "prompt": "\n
Find the mean and standard deviations of the scores of the two groups:
\nMean scores of Group 1= [[0]] (input to 3 decimal places)
\nStandard deviation of scores for Group 1 = [[1]] (input to 3 decimal places)
\nMean scores of Group 2= [[2]] (input to 3 decimal places)
\nStandard deviation of scores for Group 2 = [[3]] (input to 3 decimal places)
\nNow find the two sample t-test statistic $T$ using the values you have just calculated to 3 decimal places and input $|T|$ here: [[4]] (3 decimal places)
\n ", "gaps": [{"minvalue": "{m1}", "type": "numberentry", "maxvalue": "{m1}", "marks": 0.5, "showPrecisionHint": false}, {"minvalue": "{sd1}", "type": "numberentry", "maxvalue": "{sd1}", "marks": 0.5, "showPrecisionHint": false}, {"minvalue": "{m2}", "type": "numberentry", "maxvalue": "{m2}", "marks": 0.5, "showPrecisionHint": false}, {"minvalue": "{sd2}", "type": "numberentry", "maxvalue": "{sd2}", "marks": 0.5, "showPrecisionHint": false}, {"minvalue": "{abs(tvalue)-tol}", "type": "numberentry", "maxvalue": "{abs(tvalue)+tol}", "marks": 1.0, "showPrecisionHint": false}], "steps": [{"prompt": "\nThe two-sample t-statistic for two independent sets of data where one set has $n_1$ datapoints and the other set $n_2$ datapoints is calculated as follows:
\n\\[T=\\frac{(\\overline{x}_1-\\overline{x}_2)-(\\mu_1-\\mu_2)}{s\\times\\sqrt{\\frac{1}{n_1}+\\frac{1}{n_2}}}\\;\\;\\;\\]
\nwhere $\\overline{x}_1,\\;\\overline{x}_2$ are the sample means and
\n\\[s^2=\\frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}\\]
\nwhere $s_1,\\;s_2$ are the sample standard deviations.
\nUse the values you calculated to 3 decimal places in order to find $T$.
\n ", "type": "information", "marks": 0.0}], "marks": 0.0, "type": "gapfill"}, {"maxanswers": 0.0, "displaycolumns": 0.0, "prompt": "\nGive the value $|T|$ of the t-statistic you have found, choose the range for the $p$ value by looking up the t tables:
\n\n ", "matrix": "v", "shufflechoices": false, "minanswers": 0.0, "choices": ["
$p$ less than $0.1\\%$
", "$p$ lies between $0.1\\%$ and $1%$
", "$p$ lies between $1 \\%$ and $5\\%$
", "$p$ lies between $5 \\%$ and $10\\%$
", "$p$ is greater than $10\\%$
"], "displaytype": "radiogroup", "maxmarks": 0.0, "distractors": ["", "", "", "", ""], "marks": 0.0, "type": "1_n_2", "minmarks": 0.0}, {"maxanswers": 0.0, "displaycolumns": 0.0, "prompt": "Given the $p$-value and the range you have found, what is the strength of evidence against the null hypothesis that there is no difference in the average times for the left and right hands?
", "matrix": "v", "shufflechoices": false, "minanswers": 0.0, "choices": ["Very Strong", "Strong", "Moderate", "Slight", "None"], "displaytype": "radiogroup", "maxmarks": 0.0, "distractors": ["", "", "", "", ""], "marks": 0.0, "type": "1_n_2", "minmarks": 0.0}], "statement": "\nAn educational psychologist claimed that the order in which questions were asked affected the student’s ability to answer them correctly and hence their total score. In order to test this, $20$ students were randomly divided into two groups of $10$. The first group were given questions in increasing order of difficulty and the second group in decreasing order of difficulty. The ordered test scores obtained were:
\nGroup 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
---|---|---|---|---|---|---|---|---|---|---|
Group 2 | \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
Carry out by hand a two-sample t-test to test if there is evidence of a difference in the average test scores for the two sets of students.
\n ", "variable_groups": [], "progress": "ready", "type": "question", "variables": {"sd1": {"definition": "precround(pstdev(r1),3)", "name": "sd1"}, "sd2": {"definition": "precround(pstdev(r2),3)", "name": "sd2"}, "m1": {"definition": "mean(r1)", "name": "m1"}, "tol": {"definition": 0.001, "name": "tol"}, "m2": {"definition": "mean(r2)", "name": "m2"}, "msg": {"definition": "['is greater than $\\\\var{t999}$','lies between $\\\\var{t99}$ and $\\\\var{t999}$','lies between $\\\\var{t95}$ and $\\\\var{t99}$','lies between $\\\\var{t90}$ and $\\\\var{t95}$','is less than $\\\\var{t90}$']", "name": "msg"}, "cmsg1": {"definition": "['very strong','strong','slight','no','no']", "name": "cmsg1"}, "t999": {"definition": 3.922, "name": "t999"}, "atvalue": {"definition": "abs(tvalue)", "name": "atvalue"}, "sig1": {"definition": "random(8..10#0.2)", "name": "sig1"}, "tvalue": {"definition": "precround((m1-m2)*sqrt(n1*n2)/(s*sqrt(n1+n2)),3)", "name": "tvalue"}, "sig2": {"definition": "random(8..10#0.2)", "name": "sig2"}, "t99": {"definition": 2.878, "name": "t99"}, "t95": {"definition": 2.101, "name": "t95"}, "t90": {"definition": 1.734, "name": "t90"}, "cmsg": {"definition": "['do reject','do reject','do not reject','do not reject','do not reject']", "name": "cmsg"}, "mu1": {"definition": "random(55..75#0.5)", "name": "mu1"}, "r1": {"definition": "repeat(round(normalsample(mu1,sig1)),10)", "name": "r1"}, "r2": {"definition": "repeat(round(normalsample(mu2,sig2)),10)", "name": "r2"}, "mu2": {"definition": "random(65..75#0.5)", "name": "mu2"}, "pmsg": {"definition": "[' is less than $0.001$',' lies between $0.001$ and $0.01$',' lies between $0.01$ and $0.05$',' lies between $0.05$ and $0.10$',' is greater than $0.10$']", "name": "pmsg"}, "s": {"definition": "precround(sqrt(((n1-1)*sd1^2+(n2-1)*sd2^2)/(n1+n2-2)),3)", "name": "s"}, "t": {"definition": "switch(v[0]=1,0,v[1]=1,1,v[2]=1,2,v[3]=1,3,4)", "name": "t"}, "v": {"definition": "if(atvalue>=t999,[1,0,0,0,0],if(atvalue>=t99,[0,1,0,0,0],if(atvalue>=t95,[0,0,1,0,0],if(atvalue>=t90,[0,0,0,1,0],[0,0,0,0,1]))))", "name": "v"}, "n1": {"definition": 10.0, "name": "n1"}, "n2": {"definition": 10.0, "name": "n2"}, "pvalue": {"definition": "ttest(atvalue,19,2)", "name": "pvalue"}}, "metadata": {"notes": "\n \t\t \t\t \t\t11/07/2012:
\n \t\t \t\t \t\t
Added tags.
Calculation not yet tested.
\n \t\t \t\t \t\t23/07/2012:
\n \t\t \t\t \t\tAdded description.
\n \t\t \t\t \t\tChecked calculation.
\n \t\t \t\t \t\tChanged display slightly in Advice.
\n \t\t \t\t \t\t3/08/2012:
\n \t\t \t\t \t\tAdded tags.
\n \t\t \t\t \t\tQuestion appears to be working correctly.
\n \t\t \t\t \n \t\t \n \t\t", "description": "Two sample t-test to see if there is a difference between scores on questions between two groups when the questions are asked in a different order.
", "licence": "Creative Commons Attribution 4.0 International"}, "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}, {"name": "Paired sample t-test.", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}], "tags": ["average", "data analysis", "differences", "elementary statistics", "hypothesis testing", "mean", "mean of differences", "paired t-test", "standard deviation", "standard deviation of differences", "statistics", "stats", "t-test", "variance"], "metadata": {"description": "Paired t-test to see if there is a difference between times take in a task.
", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "\nThe following data was obtained from $12$ individuals. The observations consist of the time taken to complete a dexterity task using their left and right hands.
\n{object} | A | B | C | D | E | F | G | H | I | J | K | L |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Right | \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{r1[10]}$ | \n$\\var{r1[11]}$ | \n
Left | \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{r2[10]}$ | \n$\\var{r2[11]}$ | \n
Carry out by hand a paired t-test to test whether there is evidence of a difference in the average times for the left and right hands.
\n ", "advice": "\nThe table of differences is given by:
\n{object} | A | B | C | D | E | F | G | H | I | J | K | L |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Right | \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{r1[10]}$ | \n$\\var{r1[11]}$ | \n
Left | \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{r2[10]}$ | \n$\\var{r2[11]}$ | \n
Differences | \n$\\var{d[0]}$ | \n$\\var{d[1]}$ | \n$\\var{d[2]}$ | \n$\\var{d[3]}$ | \n$\\var{d[4]}$ | \n$\\var{d[5]}$ | \n$\\var{d[6]}$ | \n$\\var{d[7]}$ | \n$\\var{d[8]}$ | \n$\\var{d[9]}$ | \n$\\var{d[10]}$ | \n$\\var{d[11]}$ | \n
We test the following hypothesis:
\n$H_0:\\;\\mu_d=0$ versus $H_1:\\;\\mu_d\\neq 0$
\n$n=\\var{n}$ and the mean of the differences is $\\overline{d}=\\var{meandiff}$.
\nThe variance $V$ of the differences is calculated to be $\\var{pstdev(d)^2}$
Hence we have the standard deviation $s_d= \\sqrt{V}=\\var{stdiff}$ to 3 decimal places.
The paired t-statistic is given by:
\n\\[\\begin{eqnarray*} T&=&\\frac{\\overline{d}-\\mu_d}{\\frac{s_d}{\\sqrt{n}}}\\\\&=&\\frac{\\var{meandiff}-0}{\\frac{\\var{stdiff}}{\\sqrt{\\var{n}}}}\\\\&=&\\var{tvalue}\\end{eqnarray*}\\]
\n(Using the null hypothesis that the means are the same i.e. $\\mu_d=0$.)
\nHence our test statistic $|T|=\\var{tvalue}$.
\nLooking up this value on the T-distribution table for $t_{11}$
\n\\[\\begin{array}{r|rrrrr}&0.20&0.10&0.05&0.01&0.001\\\\\\hline11&1.363&1.796&2.201&3.106&4.437\\end{array}\\]
\nWe see that the t-statistic {msg[t]} and the table tells us that the $p$ value {pmsg[t]}.
\nHence we conclude that we {cmsg[t]} the null hypothesis. There is {cmsg1[t]} evidence of a difference between the average scores of the two groups.
\n\n ", "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {"pmsg": {"name": "pmsg", "group": "Ungrouped variables", "definition": "[' is less than $0.001$',' lies between $0.001$ and $0.01$',' lies between $0.01$ and $0.05$',' lies between $0.05$ and $0.10$',' is greater than $0.10$']", "description": "", "templateType": "anything", "can_override": false}, "msg": {"name": "msg", "group": "Ungrouped variables", "definition": "['is greater than $\\\\var{t999}$','lies between $\\\\var{t99}$ and $\\\\var{t999}$','lies between $\\\\var{t95}$ and $\\\\var{t99}$','lies between $\\\\var{t90}$ and $\\\\var{t95}$','is less than $\\\\var{t90}$']", "description": "", "templateType": "anything", "can_override": false}, "cmsg1": {"name": "cmsg1", "group": "Ungrouped variables", "definition": "['very strong','strong','slight','no','no']", "description": "", "templateType": "anything", "can_override": false}, "t999": {"name": "t999", "group": "Ungrouped variables", "definition": "4.437", "description": "", "templateType": "anything", "can_override": false}, "meandiff": {"name": "meandiff", "group": "Ungrouped variables", "definition": "precround(mean(d),3)", "description": "", "templateType": "anything", "can_override": false}, "object": {"name": "object", "group": "Ungrouped variables", "definition": "'Individual'", "description": "", "templateType": "anything", "can_override": false}, "sig1": {"name": "sig1", "group": "Ungrouped variables", "definition": "random(2..3#0.2)", "description": "", "templateType": "anything", "can_override": false}, "tvalue": {"name": "tvalue", "group": "Ungrouped variables", "definition": "precround(abs(meandiff*sqrt(n)/stdiff),3)", "description": "", "templateType": "anything", "can_override": false}, "stdiff": {"name": "stdiff", "group": "Ungrouped variables", "definition": "precround(pstdev(d),3)", "description": "", "templateType": "anything", "can_override": false}, "sig2": {"name": "sig2", "group": "Ungrouped variables", "definition": "random(2..4#0.2)", "description": "", "templateType": "anything", "can_override": false}, "t99": {"name": "t99", "group": "Ungrouped variables", "definition": "3.106", "description": "", "templateType": "anything", "can_override": false}, "t95": {"name": "t95", "group": "Ungrouped variables", "definition": "2.201", "description": "", "templateType": "anything", "can_override": false}, "t90": {"name": "t90", "group": "Ungrouped variables", "definition": "1.796", "description": "", "templateType": "anything", "can_override": false}, "cmsg": {"name": "cmsg", "group": "Ungrouped variables", "definition": "['do reject','do reject','do not reject','do not reject','do not reject']", "description": "", "templateType": "anything", "can_override": false}, "d": {"name": "d", "group": "Ungrouped variables", "definition": "list(vector(r2)-vector(r1))", "description": "", "templateType": "anything", "can_override": false}, "mu1": {"name": "mu1", "group": "Ungrouped variables", "definition": "random(18..25#0.5)", "description": "", "templateType": "anything", "can_override": false}, "r1": {"name": "r1", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),12)", "description": "", "templateType": "anything", "can_override": false}, "r2": {"name": "r2", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),12)", "description": "", "templateType": "anything", "can_override": false}, "mu2": {"name": "mu2", "group": "Ungrouped variables", "definition": "mu1+random(2..4#0.1)", "description": "", "templateType": "anything", "can_override": false}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "12", "description": "", "templateType": "anything", "can_override": false}, "t": {"name": "t", "group": "Ungrouped variables", "definition": "switch(v[0]=1,0,v[1]=1,1,v[2]=1,2,v[3]=1,3,4)", "description": "", "templateType": "anything", "can_override": false}, "v": {"name": "v", "group": "Ungrouped variables", "definition": "if(tvalue>=t999,[1,0,0,0,0],if(tvalue>=t99,[0,1,0,0,0],if(tvalue>=t95,[0,0,1,0,0],if(tvalue>=t90,[0,0,0,1,0],[0,0,0,0,1]))))", "description": "", "templateType": "anything", "can_override": false}, "pvalue": {"name": "pvalue", "group": "Ungrouped variables", "definition": "precround(ttest(0,d,2),3)", "description": "", "templateType": "anything", "can_override": false}, "attempt": {"name": "attempt", "group": "Ungrouped variables", "definition": "", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["pmsg", "msg", "cmsg1", "t999", "meandiff", "object", "sig1", "tvalue", "stdiff", "sig2", "t99", "t95", "t90", "cmsg", "d", "mu1", "r1", "r2", "mu2", "n", "t", "v", "pvalue", "attempt"], "variable_groups": [], "functions": {"pstdev": {"parameters": [["l", "list"]], "type": "number", "language": "jme", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)"}}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "\n
Find the mean and standard deviations of the difference between left and right {attempt}s.
\nCalculate differences for left {attempt} times – right {attempt} times. Make sure you take the differences this way round.
\nMean of difference = [[0]] (input to 3 decimal places )
\nStandard deviation of difference = [[1]] (input to 3 decimal places)
\nNow find the t-test statistic $T$ using the values you have just calculated and input the absolute value $|T|$ here: [[2]] (3 decimal places).
\n\n ", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 0.5, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{meandiff}", "maxValue": "{meandiff}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 0.5, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{stdiff}", "maxValue": "{stdiff}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{tvalue}", "maxValue": "{tvalue}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"type": "1_n_2", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "
Give the value of the t-statistic you have found, choose the range for the $p$ value by looking up the t-statistic tables:
", "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayColumns": 0, "showCellAnswerState": true, "choices": ["$p$ less than $0.1 \\%$
", "$p$ lies between $0.1\\%$ and $1 \\%$
", "$p$ lies between $1 \\%$ and $5\\%$
", "$p$ lies between $5 \\%$ and $10\\%$
", "$p$ is greater than $10\\%$
"], "matrix": "v"}, {"type": "1_n_2", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Given the $p$-value and the range you have found, what is the strength of evidence against the null hypothesis that there is no difference in the average times for the left and right hands?
", "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayColumns": 0, "showCellAnswerState": true, "choices": ["Very strong", "Strong", "Moderate", "Slight", "None"], "matrix": "v"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Paired t-test after treatment.", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "functions": {"pstdev": {"definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "type": "number", "language": "jme", "parameters": [["l", "list"]]}}, "ungrouped_variables": ["attempt", "cmsg", "d", "meandiff", "msg", "mu1", "mu2", "object", "objects", "pmsg", "pvalue", "r1", "r2", "sig1", "sig2", "stdiff", "t", "t90", "t95", "t99", "t999", "thismany", "tvalue", "v"], "tags": ["average", "data analysis", "differences", "elementary statistics", "hypothesis testing", "mean", "mean of differences", "paired t-test", "standard deviation", "standard deviation of differences", "statistics", "stats", "t-test", "variance"], "preamble": {"css": "", "js": ""}, "advice": "The table of differences is given by:
\n{object} | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Before | \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{r1[10]}$ | \n$\\var{r1[11]}$ | \n$\\var{r1[12]}$ | \n$\\var{r1[13]}$ | \n$\\var{r1[14]}$ | \n
After | \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{r2[10]}$ | \n$\\var{r2[11]}$ | \n$\\var{r2[12]}$ | \n$\\var{r2[13]}$ | \n$\\var{r2[14]}$ | \n
Differences | \n$\\var{d[0]}$ | \n$\\var{d[1]}$ | \n$\\var{d[2]}$ | \n$\\var{d[3]}$ | \n$\\var{d[4]}$ | \n$\\var{d[5]}$ | \n$\\var{d[6]}$ | \n$\\var{d[7]}$ | \n$\\var{d[8]}$ | \n$\\var{d[9]}$ | \n$\\var{d[10]}$ | \n$\\var{d[11]}$ | \n$\\var{d[12]}$ | \n$\\var{d[13]}$ | \n$\\var{d[14]}$ | \n
The mean of the differences is $\\overline{x_d}=\\var{meandiff}$.
\nThe variance $V$ of the differences is
\\[\\begin{eqnarray*} V&=&\\frac{1}{14}\\left(\\simplify[]{{d[0]^2}+{d[1]^2}+{d[2]^2}+{d[3]^2}+{d[4]^2}+{d[5]^2}+{d[6]^2}+{d[7]^2}+{d[8]^2}+{d[9]^2}+{d[10]^2}+{d[11]^2}+{d[12]^2}+{d[13]^2}+{d[14]^2}}-15\\times \\var{meandiff}^2\\right)\\\\ &=&\\var{variance(d)} \\end{eqnarray*} \\]
Hence we have the standard deviation $s_d= \\sqrt{V}=\\var{stdiff}$ to 3 decimal places.
The paired t-statistic is given by:
\n\\[t_d=\\frac{\\overline{x_d}-\\mu_d}{\\frac{s_d}{\\sqrt{n}}}\\]
\nIn this example $n=15$ and the null hypothesis is that the means are the same i.e. $\\mu_d=0$.
\nOn calculating we find $t_d=\\var{tvalue}$.
\nLooking up this value on the T-distribution table for $t_{14}$
\n\\[\\begin{array}{r|rrrrr}&0.20&0.10&0.05&0.01&0.001\\\\\\hline14&1.345&1.761&2.145&2.977&4.140\\end{array}\\]
\nWe see that the t-statistic {msg[t]} and the table tells us that the $p$ value {pmsg[t]}.
\nHence we conclude that {cmsg[t]}.
", "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "parts": [{"prompt": "\nFind the mean and standard deviations of the difference between the before and after responses
\nCalculate differences for after response– before response.
\nMean of difference = [[0]] (input to 3 decimal places )
\nStandard deviation of difference = [[1]] (input to 3 decimal places)
\nNow find the paired t-test statistic using the values you have just calculated =[[2]] (3 decimal places)
\n\n ", "marks": 0, "gaps": [{"allowFractions": false, "marks": 0.5, "maxValue": "{meandiff}", "minValue": "{meandiff}", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "marks": 0.5, "maxValue": "{stdiff}", "minValue": "{stdiff}", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "marks": 1, "maxValue": "{tvalue}", "minValue": "{tvalue}", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "type": "numberentry", "showPrecisionHint": false}], "showCorrectAnswer": true, "scripts": {}, "type": "gapfill"}, {"displayColumns": 0, "prompt": "
Give the value of the t-statistic you have found, choose the range for the $p$ value by looking up the t-statistic tables:
", "matrix": "v", "shuffleChoices": false, "maxMarks": 0, "distractors": ["", "", "", "", ""], "choices": ["$p$ is greater than $10\\%$
", "$p$ lies between $5 \\%$ and $10\\%$
", "$p$ lies between $1 \\%$ and $5\\%$
", "$p$ lies between $0.1 \\%$ and $1\\%$
", "$p$ is less than $0.1 \\%$
"], "displayType": "radiogroup", "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "1_n_2", "minMarks": 0}, {"displayColumns": 0, "prompt": "Given the $p$-value and the range you have found, what is the strength of evidence against the null hypothesis that there is a difference in the average responses of the two groups?
", "matrix": "v", "shuffleChoices": false, "maxMarks": 0, "distractors": ["", "", "", "", ""], "choices": ["None", "Slight", "Moderate", "Strong", "Very strong"], "displayType": "radiogroup", "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "1_n_2", "minMarks": 0}], "statement": "Suppose that 15 individuals, diagnosed with bipolar disorder take part in an experiment that grades their happiness on a scale from 1 to 25. They take the test before treatment and then again after a specific drug has been prescribed. The data is shown below:
\n{object} | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Before | \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{r1[10]}$ | \n$\\var{r1[11]}$ | \n$\\var{r1[12]}$ | \n$\\var{r1[13]}$ | \n$\\var{r1[14]}$ | \n
After | \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{r2[10]}$ | \n$\\var{r2[11]}$ | \n$\\var{r2[12]}$ | \n$\\var{r2[13]}$ | \n$\\var{r2[14]}$ | \n
Is there a difference between the average responses of the two groups?
\nIn order to answer this, complete the following questions.
", "type": "question", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"t95": {"definition": "2.145", "templateType": "anything", "group": "Ungrouped variables", "name": "t95", "description": ""}, "tvalue": {"definition": "precround(abs(tscore(0,d)),3)", "templateType": "anything", "group": "Ungrouped variables", "name": "tvalue", "description": ""}, "msg": {"definition": "['is greater than $\\\\var{t999}$','lies between $\\\\var{t99}$ and $\\\\var{t999}$','lies between $\\\\var{t95}$ and $\\\\var{t99}$','lies between $\\\\var{t90}$ and $\\\\var{t95}$','is less than $\\\\var{t90}$']", "templateType": "anything", "group": "Ungrouped variables", "name": "msg", "description": ""}, "t999": {"definition": "4.14", "templateType": "anything", "group": "Ungrouped variables", "name": "t999", "description": ""}, "meandiff": {"definition": "precround(mean(d),3)", "templateType": "anything", "group": "Ungrouped variables", "name": "meandiff", "description": ""}, "object": {"definition": "'Individual'", "templateType": "anything", "group": "Ungrouped variables", "name": "object", "description": ""}, "sig1": {"definition": "random(2..3#0.2)", "templateType": "anything", "group": "Ungrouped variables", "name": "sig1", "description": ""}, "thismany": {"definition": "15", "templateType": "anything", "group": "Ungrouped variables", "name": "thismany", "description": ""}, "stdiff": {"definition": "precround(pstdev(d),3)", "templateType": "anything", "group": "Ungrouped variables", "name": "stdiff", "description": ""}, "sig2": {"definition": "random(2..3#0.2)", "templateType": "anything", "group": "Ungrouped variables", "name": "sig2", "description": ""}, "t99": {"definition": "2.977", "templateType": "anything", "group": "Ungrouped variables", "name": "t99", "description": ""}, "attempt": {"definition": "'hand'", "templateType": "anything", "group": "Ungrouped variables", "name": "attempt", "description": ""}, "t90": {"definition": "1.761", "templateType": "anything", "group": "Ungrouped variables", "name": "t90", "description": ""}, "cmsg": {"definition": "[ \"there is very strong evidence against the null hypothesis\", \"there is strong evidence against the null hypothesis\", \"there is moderate evidence against the null hypothesis\", \"there is slight evidence against the null hypothesis\", \"there is no evidence against the null hypothesis\" ]", "templateType": "list of strings", "group": "Ungrouped variables", "name": "cmsg", "description": ""}, "r1": {"definition": "repeat(min(round(normalsample(mu1,sig1)),25),15)", "templateType": "anything", "group": "Ungrouped variables", "name": "r1", "description": ""}, "mu1": {"definition": "random(10..14#0.5)", "templateType": "anything", "group": "Ungrouped variables", "name": "mu1", "description": ""}, "d": {"definition": "list(vector(r2)-vector(r1))", "templateType": "anything", "group": "Ungrouped variables", "name": "d", "description": ""}, "r2": {"definition": "repeat(min(round(normalsample(mu2,sig2)),25),15)", "templateType": "anything", "group": "Ungrouped variables", "name": "r2", "description": ""}, "mu2": {"definition": "mu1+random(2..4#0.1)", "templateType": "anything", "group": "Ungrouped variables", "name": "mu2", "description": ""}, "pmsg": {"definition": "[' is less than $0.001$',' lies between $0.001$ and $0.01$',' lies between $0.01$ and $0.05$',' lies between $0.05$ and $0.10$',' is greater than $0.10$']", "templateType": "anything", "group": "Ungrouped variables", "name": "pmsg", "description": ""}, "objects": {"definition": "'individuals'", "templateType": "anything", "group": "Ungrouped variables", "name": "objects", "description": ""}, "t": {"definition": "switch(v[0]=1,0,v[1]=1,1,v[2]=1,2,v[3]=1,3,4)", "templateType": "anything", "group": "Ungrouped variables", "name": "t", "description": ""}, "v": {"definition": "if(tvalue>=t999,[1,0,0,0,0],if(tvalue>=t99,[0,1,0,0,0],if(tvalue>=t95,[0,0,1,0,0],if(tvalue>=t90,[0,0,0,1,0],[0,0,0,0,1]))))", "templateType": "anything", "group": "Ungrouped variables", "name": "v", "description": ""}, "pvalue": {"definition": "precround(ttest(0,d,2),3)", "templateType": "anything", "group": "Ungrouped variables", "name": "pvalue", "description": ""}}, "metadata": {"notes": "11/07/2012:
\n
Added tags.
Calculation not yet tested.
\n23/07/2012:
\nAdded description.
\nChecked calculation.
\nChanged display slightly in Advice.
\n3/08/2012:
\nAdded tags.
\nQuestion appears to be working correctly.
\n26/01/2013:
\nAdvice needs to be finished.
", "description": "Paired t-test to see if there is a difference between responses after treatment.
", "licence": "Creative Commons Attribution 4.0 International"}, "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "extensions": ["stats"], "custom_part_types": [], "resources": []}