// Numbas version: exam_results_page_options {"name": "Simon's copy of Paired t-test after treatment.", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"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]}.
", "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"], "preamble": {"js": "", "css": ""}, "variables": {"r1": {"definition": "repeat(min(round(normalsample(mu1,sig1)),25),15)", "name": "r1", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "sig2": {"definition": "random(2..3#0.2)", "name": "sig2", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "meandiff": {"definition": "precround(mean(d),3)", "name": "meandiff", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "t": {"definition": "switch(v[0]=1,0,v[1]=1,1,v[2]=1,2,v[3]=1,3,4)", "name": "t", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "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", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "objects": {"definition": "'individuals'", "name": "objects", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "attempt": {"definition": "'hand'", "name": "attempt", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "object": {"definition": "'Individual'", "name": "object", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "mu2": {"definition": "mu1+random(2..4#0.1)", "name": "mu2", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "t99": {"definition": "2.977", "name": "t99", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "d": {"definition": "list(vector(r2)-vector(r1))", "name": "d", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "tvalue": {"definition": "precround(abs(tscore(0,d)),3)", "name": "tvalue", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "t999": {"definition": "4.14", "name": "t999", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "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\" ]", "name": "cmsg", "group": "Ungrouped variables", "description": "", "templateType": "list of strings"}, "pvalue": {"definition": "precround(ttest(0,d,2),3)", "name": "pvalue", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "stdiff": {"definition": "precround(pstdev(d),3)", "name": "stdiff", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "sig1": {"definition": "random(2..3#0.2)", "name": "sig1", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "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]))))", "name": "v", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "r2": {"definition": "repeat(min(round(normalsample(mu2,sig2)),25),15)", "name": "r2", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "thismany": {"definition": "15", "name": "thismany", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "t95": {"definition": "2.145", "name": "t95", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "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", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "mu1": {"definition": "random(10..14#0.5)", "name": "mu1", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "t90": {"definition": "1.761", "name": "t90", "group": "Ungrouped variables", "description": "", "templateType": "anything"}}, "question_groups": [{"questions": [], "pickQuestions": 0, "name": "", "pickingStrategy": "all-ordered"}], "functions": {"pstdev": {"type": "number", "definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "language": "jme", "parameters": [["l", "list"]]}}, "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"}, "parts": [{"showCorrectAnswer": true, "gaps": [{"correctAnswerFraction": false, "minValue": "{meandiff}", "maxValue": "{meandiff}", "scripts": {}, "showCorrectAnswer": true, "type": "numberentry", "showPrecisionHint": false, "allowFractions": false, "marks": 0.5}, {"correctAnswerFraction": false, "minValue": "{stdiff}", "maxValue": "{stdiff}", "scripts": {}, "showCorrectAnswer": true, "type": "numberentry", "showPrecisionHint": false, "allowFractions": false, "marks": 0.5}, {"correctAnswerFraction": false, "minValue": "{tvalue}", "maxValue": "{tvalue}", "scripts": {}, "showCorrectAnswer": true, "type": "numberentry", "showPrecisionHint": false, "allowFractions": false, "marks": 1}], "scripts": {}, "type": "gapfill", "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}, {"minMarks": 0, "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, "type": "1_n_2", "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:
", "marks": 0, "distractors": ["", "", "", "", ""], "scripts": {}, "shuffleChoices": false, "maxMarks": 0, "matrix": "v"}, {"minMarks": 0, "choices": ["None", "Slight", "Moderate", "Strong", "Very strong"], "displayType": "radiogroup", "showCorrectAnswer": true, "type": "1_n_2", "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?
", "marks": 0, "distractors": ["", "", "", "", ""], "scripts": {}, "shuffleChoices": false, "maxMarks": 0, "matrix": "v"}], "type": "question", "variable_groups": [], "showQuestionGroupNames": false, "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.
", "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"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "variablesTest": {"maxRuns": 100, "condition": ""}, "name": "Simon's copy of Paired t-test after treatment.", "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/"}, {"name": "Simon Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3148/"}]}]}], "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/"}, {"name": "Simon Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3148/"}]}