// Numbas version: finer_feedback_settings {"name": "A comparison of the means of two groups (1).", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"functions": {"pstdev": {"definition": "sqrt(abs(l)/(abs(l)-1))*stdev(l)", "type": "number", "parameters": [["l", "list"]], "language": "jme"}}, "ungrouped_variables": ["attempt", "d", "meandiff", "mu1", "mu2", "object", "objects", "r1", "r2", "sig1", "sig2", "stdiff", "t95", "thismany", "tcalc", "tupper", "tlower", "mdupper", "mdlower", "stdupper", "stdlower", "outcome", "sed"], "name": "A comparison of the means of two groups (1).", "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"], "advice": "

First, recognise that this is a paired t-test: two observations on the same individuals.

\n

So calculate the differences (before $-$ after) between those two observations:

\n

{d}

\n

Note: If you have a graphical calculator, you can enter the before and after observations into two lists (say L1 and L2), then in the heading (title/label) row for L3 type \"=L1 $-$ L2\" to get the calculator to work out the differences.

\n

Then calculate the mean difference:

\n

{meandiff}

\n

Then the standard deviation (sd) of the differences:

\n

{stdiff}

\n

Note: You should use your calculator to get both the mean and standard deviation.

\n

The standard error (se) is calculated as:

\n

\\[ se = \\frac{ sd }{ \\sqrt{ n }} \\]

\n

\n

It is:

\n

{sed}

\n

Finally, calculate the test statisitic, t-calc, as the mean difference divided by the standard error:

\n

\\[ t-calc = \\frac{ mean difference }{ se} \\]

\n

t-calc = {tcalc}

\n

There are 6 subjects, so 5 degrees of freedom, and the test is two-tailed, so the t-table = 2.571.

\n

If t-calc is greater than 2.571, the null is rejected. As this is a two-tailed test, the sign of t-calc (positive or negative) is ignored.

", "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "parts": [{"prompt": "

Find the mean and standard deviations of the difference between the before and after responses

\n

Calculate differences for after response– before response.

\n

Mean of difference = [[0]] (input  to 2 decimal places )

\n

Standard deviation of difference = [[1]] (input to 2 decimal places)

\n

Now find the paired t-test statistic  using the values you have just calculated =[[2]] (input 2 decimal places)

\n

Is the null hypothesis rejected? [[3]] Enter 0 for \"No\" and 1 for \"Yes\".

", "marks": 0, "gaps": [{"precisionType": "dp", "precisionMessage": "You have not given your answer to the correct precision.", "allowFractions": false, "scripts": {}, "precision": "2", "maxValue": "{mdupper}", "minValue": "{mdlower}", "strictPrecision": true, "correctAnswerFraction": false, "showCorrectAnswer": true, "precisionPartialCredit": "50", "marks": "1", "type": "numberentry", "showPrecisionHint": false}, {"precisionType": "dp", "precisionMessage": "You have not given your answer to the correct precision.", "allowFractions": false, "scripts": {}, "precision": "2", "maxValue": "{stdupper}", "minValue": "{stdlower}", "strictPrecision": true, "correctAnswerFraction": false, "showCorrectAnswer": true, "precisionPartialCredit": "50", "marks": "1", "type": "numberentry", "showPrecisionHint": false}, {"precisionType": "dp", "precisionMessage": "You have not given your answer to the correct precision.", "allowFractions": false, "scripts": {}, "precision": "2", "maxValue": "{tupper}", "minValue": "{tlower}", "strictPrecision": true, "correctAnswerFraction": false, "showCorrectAnswer": true, "precisionPartialCredit": 0, "marks": 1, "type": "numberentry", "showPrecisionHint": false}, {"integerPartialCredit": 0, "integerAnswer": true, "allowFractions": false, "scripts": {}, "maxValue": "{outcome}", "minValue": "{outcome}", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 1, "type": "numberentry", "showPrecisionHint": false}], "showCorrectAnswer": true, "scripts": {}, "type": "gapfill"}], "statement": "

Suppose that 6 individuals, diagnosed with a particular condition, take part in an experiment that grades their happiness on a scale from 1 to 25 (a higher score is better). They take the test before treatment and then again after treatment with a specific drug. The data is in the table below:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
{object}ABCDEF
Before$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$
After$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$
\n

Is there a difference between the average responses before to after?

\n

In other words, test the following null hypothesis:

\n

H0: mean happiness before = mean happiness after.

", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "preamble": {"css": "", "js": ""}, "variables": {"tlower": {"definition": "tcalc-0.025", "templateType": "anything", "group": "Ungrouped variables", "name": "tlower", "description": ""}, "sed": {"definition": "precround(stdiff/sqrt(thismany),3)", "templateType": "anything", "group": "Ungrouped variables", "name": "sed", "description": ""}, "t95": {"definition": "2.571", "templateType": "anything", "group": "Ungrouped variables", "name": "t95", "description": ""}, "mdupper": {"definition": "meandiff+0.025", "templateType": "anything", "group": "Ungrouped variables", "name": "mdupper", "description": ""}, "stdupper": {"definition": "stdiff+0.025", "templateType": "anything", "group": "Ungrouped variables", "name": "stdupper", "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": ""}, "tcalc": {"definition": "precround(meandiff/(stdiff/sqrt(thismany)),3)", "templateType": "anything", "group": "Ungrouped variables", "name": "tcalc", "description": ""}, "sig1": {"definition": "random(2..3#0.2)", "templateType": "anything", "group": "Ungrouped variables", "name": "sig1", "description": ""}, "thismany": {"definition": "6", "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": ""}, "mdlower": {"definition": "meandiff-0.025", "templateType": "anything", "group": "Ungrouped variables", "name": "mdlower", "description": ""}, "attempt": {"definition": "'hand'", "templateType": "anything", "group": "Ungrouped variables", "name": "attempt", "description": ""}, "stdlower": {"definition": "stdiff-0.025", "templateType": "anything", "group": "Ungrouped variables", "name": "stdlower", "description": ""}, "d": {"definition": "list(vector(r1)-vector(r2))", "templateType": "anything", "group": "Ungrouped variables", "name": "d", "description": ""}, "mu1": {"definition": "random(10..14#0.5)", "templateType": "anything", "group": "Ungrouped variables", "name": "mu1", "description": ""}, "r1": {"definition": "repeat(min(round(normalsample(mu1,sig1)),25),6)", "templateType": "anything", "group": "Ungrouped variables", "name": "r1", "description": ""}, "r2": {"definition": "repeat(min(round(normalsample(mu2,sig2)),25),6)", "templateType": "anything", "group": "Ungrouped variables", "name": "r2", "description": ""}, "mu2": {"definition": "mu1+random(4..6#0.1)", "templateType": "anything", "group": "Ungrouped variables", "name": "mu2", "description": ""}, "objects": {"definition": "'individuals'", "templateType": "anything", "group": "Ungrouped variables", "name": "objects", "description": ""}, "tupper": {"definition": "tcalc+0.025", "templateType": "anything", "group": "Ungrouped variables", "name": "tupper", "description": ""}, "outcome": {"definition": "if((abs(tcalc)>t95),1,0)", "templateType": "anything", "group": "Ungrouped variables", "name": "outcome", "description": ""}}, "metadata": {"notes": "", "description": "

A comparison of the mean of two groups.

", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}], "contributors": [{"name": "Keith McGuinness", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/523/"}], "resources": []}]}], "contributors": [{"name": "Keith McGuinness", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/523/"}]}