// Numbas version: finer_feedback_settings {"name": "Adam's copy of Perform a paired sample t-test, ", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"statement": "
The 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.
", "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "variables": {"t": {"description": "", "group": "Ungrouped variables", "definition": "switch(v[0]=1,0,v[1]=1,1,v[2]=1,2,v[3]=1,3,4)", "name": "t", "templateType": "anything"}, "msg": {"description": "", "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}$']", "name": "msg", "templateType": "anything"}, "sig1": {"description": "", "group": "Ungrouped variables", "definition": "random(2..3#0.2)", "name": "sig1", "templateType": "anything"}, "t99": {"description": "", "group": "Ungrouped variables", "definition": "3.106", "name": "t99", "templateType": "anything"}, "n": {"description": "", "group": "Ungrouped variables", "definition": "12", "name": "n", "templateType": "anything"}, "r1": {"description": "", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),12)", "name": "r1", "templateType": "anything"}, "v": {"description": "", "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]))))", "name": "v", "templateType": "anything"}, "mu1": {"description": "", "group": "Ungrouped variables", "definition": "random(18..25#0.5)", "name": "mu1", "templateType": "anything"}, "pvalue": {"description": "", "group": "Ungrouped variables", "definition": "precround(ttest(0,d,2),3)", "name": "pvalue", "templateType": "anything"}, "object": {"description": "", "group": "Ungrouped variables", "definition": "'Individual'", "name": "object", "templateType": "anything"}, "tvalue": {"description": "", "group": "Ungrouped variables", "definition": "precround(abs(meandiff*sqrt(n)/stdiff),3)", "name": "tvalue", "templateType": "anything"}, "stdiff": {"description": "", "group": "Ungrouped variables", "definition": "precround(pstdev(d),3)", "name": "stdiff", "templateType": "anything"}, "cmsg": {"description": "", "group": "Ungrouped variables", "definition": "['do reject','do reject','do not reject','do not reject','do not reject']", "name": "cmsg", "templateType": "anything"}, "mu2": {"description": "", "group": "Ungrouped variables", "definition": "mu1+random(2..4#0.1)", "name": "mu2", "templateType": "anything"}, "t95": {"description": "", "group": "Ungrouped variables", "definition": "2.201", "name": "t95", "templateType": "anything"}, "pmsg": {"description": "", "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$']", "name": "pmsg", "templateType": "anything"}, "cmsg1": {"description": "", "group": "Ungrouped variables", "definition": "['very strong','strong','slight','no','no']", "name": "cmsg1", "templateType": "anything"}, "t999": {"description": "", "group": "Ungrouped variables", "definition": "4.437", "name": "t999", "templateType": "anything"}, "t90": {"description": "", "group": "Ungrouped variables", "definition": "1.796", "name": "t90", "templateType": "anything"}, "d": {"description": "", "group": "Ungrouped variables", "definition": "list(vector(r2)-vector(r1))", "name": "d", "templateType": "anything"}, "meandiff": {"description": "", "group": "Ungrouped variables", "definition": "precround(mean(d),3)", "name": "meandiff", "templateType": "anything"}, "r2": {"description": "", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),12)", "name": "r2", "templateType": "anything"}, "sig2": {"description": "", "group": "Ungrouped variables", "definition": "random(2..4#0.2)", "name": "sig2", "templateType": "anything"}}, "name": "Adam's copy of Perform a paired sample t-test, ", "type": "question", "parts": [{"prompt": "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", "gaps": [{"type": "numberentry", "maxValue": "{meandiff}", "minValue": "{meandiff}", "showPrecisionHint": false, "correctAnswerFraction": false, "scripts": {}, "marks": 0.5, "showCorrectAnswer": true, "allowFractions": false}, {"type": "numberentry", "maxValue": "{stdiff}", "minValue": "{stdiff}", "showPrecisionHint": false, "correctAnswerFraction": false, "scripts": {}, "marks": 0.5, "showCorrectAnswer": true, "allowFractions": false}, {"type": "numberentry", "maxValue": "{tvalue}", "minValue": "{tvalue}", "showPrecisionHint": false, "correctAnswerFraction": false, "scripts": {}, "marks": 1, "showCorrectAnswer": true, "allowFractions": false}], "marks": 0, "scripts": {}, "type": "gapfill", "showCorrectAnswer": true}, {"distractors": ["", "", "", "", ""], "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:
", "scripts": {}, "type": "1_n_2", "shuffleChoices": false, "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\\%$
"], "minMarks": 0, "matrix": "v", "displayType": "radiogroup", "displayColumns": 0, "marks": 0, "showCorrectAnswer": true, "maxMarks": 0}, {"distractors": ["", "", "", "", ""], "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?
", "scripts": {}, "type": "1_n_2", "shuffleChoices": false, "choices": ["Very Strong Evidence
", "Strong Evidence
", "Evidence
", "Weak Evidence
", "No Evidence
"], "minMarks": 0, "matrix": "v", "displayType": "radiogroup", "displayColumns": 0, "marks": 0, "showCorrectAnswer": true, "maxMarks": 0}], "advice": "The 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", "variablesTest": {"condition": "", "maxRuns": 100}, "preamble": {"css": "", "js": ""}, "variable_groups": [], "functions": {"pstdev": {"language": "jme", "type": "number", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "parameters": [["l", "list"]]}}, "tags": ["ACE2013", "average", "checked2015", "data analysis", "differences", "elementary statistics", "hypothesis testing", "mean", "mean ", "mean of differences", "paired t-test", "PSY2010", "standard deviation", "standard deviation of differences", "statistics", "stats", "t-test", "variance"], "metadata": {"notes": "\n \t\t \t\t
11/07/2012:
\n \t\t \t\t
Added tags.
Calculation not yet tested.
\n \t\t \t\t23/07/2012:
\n \t\t \t\tAdded description.
\n \t\t \t\tChecked calculation.
\n \t\t \t\tChanged display slightly in Advice.
\n \t\t \t\t3/08/2012:
\n \t\t \t\tAdded tags.
\n \t\t \t\tQuestion appears to be working correctly.
\n \t\t \n \t\t", "description": "Paired t-test to see if there is a difference between times take in a task.
", "licence": "Creative Commons Attribution 4.0 International"}, "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"], "showQuestionGroupNames": false, "contributors": [{"name": "Adam Vellender", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1844/"}]}]}], "contributors": [{"name": "Adam Vellender", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1844/"}]}