// Numbas version: finer_feedback_settings {"name": "Perform an independent two sample t-test", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Perform an independent two sample t-test", "tags": [], "metadata": {"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"}, "statement": "

The quadriceps angle, or Q angle, is the angle formed by the encounter of two lines, one that starts at the anterior iliac spine (AIS) and goes to the center of the patella, and another that goes from the tibial tuberosity to the center of the patella. The following table shows the Q-angles, in degrees, for a random sample of 10 males and 10 females.

\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
Females$\\var{r1[0]}$$\\var{r1[1]}$$\\var{r1[2]}$$\\var{r1[3]}$$\\var{r1[4]}$$\\var{r1[5]}$$\\var{r1[6]}$$\\var{r1[7]}$$\\var{r1[8]}$$\\var{r1[9]}$
Males$\\var{r2[0]}$$\\var{r2[1]}$$\\var{r2[2]}$$\\var{r2[3]}$$\\var{r2[4]}$$\\var{r2[5]}$$\\var{r2[6]}$$\\var{r2[7]}$$\\var{r2[8]}$$\\var{r2[9]}$
\n

Carry out a two-sample $t$-test to test if there is evidence of a difference in the average Q-angle between males and females.

\n

Let $\\mu_1$ be the mean Q angle for females.

\n

Let $\\mu_2$ be the mean Q angle for males.

\n

Null hypothesis: $H_0$: $\\mu_1 = \\mu_2$

\n

Alternative hypothesis: $H_1$: $\\mu_1 \\ne \\mu_2$

", "advice": "

We test the null hypothesis

\n

$H_0:\\; \\mu_1=\\mu_2$ (there is no significant difference in the Q-angles of males and females)

\n

against the alternative hypothesis

\n

 $H_1:\\; \\mu_1 \\neq \\mu_2$ (there is a significant difference in the Q-angles of males and females).

\n

We find that the mean Q-angle of the females is $\\overline{x}_1=\\var{m1}$ with standard deviation $s_1=\\var{sd1}$ and the mean Q-angle of the males is $\\overline{x}_2=\\var{m2}$ with standard deviation $s_2=\\var{sd2}$.

\n

We also have that $n_1=n_2=10$ and so we can calculate the pooled standard deviation $s$:

\n

\\[s=\\sqrt\\frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}= \\sqrt\\frac{\\var{n1-1}\\times \\var{sd1}^2+\\var{n2-1}\\times \\var{sd2}^2}{\\var{n1+n2-2}}=\\var{s}.\\] 

\n

We can now calculate the test statistic:

\n

\\[\\begin{eqnarray*}T&=& \\frac{\\lvert \\;\\overline{x}_1-\\overline{x}_2\\;\\rvert}{s\\;\\sqrt{\\frac{1}{n_1}+\\frac{1}{n_2}}}\\\\&=&\\frac{\\lvert\\var{m1}-\\var{m2}\\rvert}{\\var{s}\\sqrt{\\frac{1}{\\var{n1}}+\\frac{1}{\\var{n2}}}}\\\\&=&\\var{tvalue}\\end{eqnarray*}\\].

\n

Remeber that we want the absolute value of this result - that is, we always take it to be positive.

\n

We then look up $n_1+n_2-2=18$ degrees of freedom in the tables and see where our test statistic lies.

\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}\\]

\n

We see that the test statistic {msg[t]} and the table tells us that the $p$ value {pmsg[t]}.

\n

Hence we conclude that we {cmsg[t]} the null hypothesis. There is {cmsg1[t]} evidence of a difference between the average Q-angle in females and males.

\n

 

", "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "extensions": ["stats"], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"s": {"name": "s", "group": "Ungrouped variables", "definition": "precround(sqrt(((n1-1)*sd1^2+(n2-1)*sd2^2)/(n1+n2-2)),3)", "description": "", "templateType": "anything", "can_override": false}, "v": {"name": "v", "group": "Ungrouped variables", "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]))))", "description": "", "templateType": "anything", "can_override": false}, "r2": {"name": "r2", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu2,sig2)),10)", "description": "", "templateType": "anything", "can_override": false}, "m2": {"name": "m2", "group": "Ungrouped variables", "definition": "mean(r2)", "description": "", "templateType": "anything", "can_override": false}, "n2": {"name": "n2", "group": "Ungrouped variables", "definition": "10", "description": "", "templateType": "anything", "can_override": false}, "m1": {"name": "m1", "group": "Ungrouped variables", "definition": "mean(r1)", "description": "", "templateType": "anything", "can_override": false}, "cmsg1": {"name": "cmsg1", "group": "Ungrouped variables", "definition": "['very strong','strong','some','only weak','no']", "description": "", "templateType": "anything", "can_override": false}, "sd2": {"name": "sd2", "group": "Ungrouped variables", "definition": "precround(pstdev(r2),3)", "description": "", "templateType": "anything", "can_override": false}, "mu2": {"name": "mu2", "group": "Ungrouped variables", "definition": "random(11..12#0.01)", "description": "", "templateType": "anything", "can_override": false}, "sig2": {"name": "sig2", "group": "Ungrouped variables", "definition": "random(2.5..3.5#0.01)", "description": "", "templateType": "anything", "can_override": false}, "mu1": {"name": "mu1", "group": "Ungrouped variables", "definition": "random(15..16#0.01)", "description": "", "templateType": "anything", "can_override": false}, "r1": {"name": "r1", "group": "Ungrouped variables", "definition": "repeat(round(normalsample(mu1,sig1)),10)", "description": "", "templateType": "anything", "can_override": false}, "sd1": {"name": "sd1", "group": "Ungrouped variables", "definition": "precround(pstdev(r1),3)", "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}, "atvalue": {"name": "atvalue", "group": "Ungrouped variables", "definition": "abs(tvalue)", "description": "", "templateType": "anything", "can_override": false}, "t999": {"name": "t999", "group": "Ungrouped variables", "definition": "3.922", "description": "", "templateType": "anything", "can_override": false}, "sig1": {"name": "sig1", "group": "Ungrouped variables", "definition": "random(4..5#0.01)", "description": "", "templateType": "anything", "can_override": false}, "t90": {"name": "t90", "group": "Ungrouped variables", "definition": "1.734", "description": "", "templateType": "anything", "can_override": false}, "cmsg": {"name": "cmsg", "group": "Ungrouped variables", "definition": "['do reject','do reject','do reject','do not reject','do not reject']", "description": "", "templateType": "anything", "can_override": false}, "n1": {"name": "n1", "group": "Ungrouped variables", "definition": "10", "description": "", "templateType": "anything", "can_override": false}, "t99": {"name": "t99", "group": "Ungrouped variables", "definition": "2.878", "description": "", "templateType": "anything", "can_override": false}, "tvalue": {"name": "tvalue", "group": "Ungrouped variables", "definition": "(precround(m1,3)-precround(m2,3))*sqrt(n1*n2)/(precround(s,3)*sqrt(n1+n2))", "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}, "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}, "tol": {"name": "tol", "group": "Ungrouped variables", "definition": "0.001", "description": "", "templateType": "anything", "can_override": false}, "pvalue": {"name": "pvalue", "group": "Ungrouped variables", "definition": "ttest(atvalue,19,2)", "description": "", "templateType": "anything", "can_override": false}, "t95": {"name": "t95", "group": "Ungrouped variables", "definition": "2.101", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["sd1", "sd2", "m1", "tol", "m2", "msg", "cmsg1", "t999", "atvalue", "sig1", "tvalue", "sig2", "t99", "t95", "t90", "cmsg", "mu1", "r1", "r2", "mu2", "pmsg", "s", "t", "v", "n1", "n2", "pvalue"], "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": false, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Find the mean and standard deviations of the Q-angles for the males and females:

\n

Sample mean Q-angle for males = [[2]] 

\n

Sample standard deviation of Q-angles for males = [[3]] 

\n

Sample mean Q-angle for females = [[0]] 

\n

Sample standard deviation of Q-angles for females = [[1]] 

", "gaps": [{"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": "{m1}", "maxValue": "{m1}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "precisionType": "dp", "precision": "3", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": 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": "{sd1}", "maxValue": "{sd1}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "precisionType": "dp", "precision": "3", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": 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": "{m2}", "maxValue": "{m2}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "precisionType": "dp", "precision": "3", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": 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": "{sd2}", "maxValue": "{sd2}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "precisionType": "dp", "precision": "3", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"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": "

Use your rounded values above to find the test statistic $T$

\n

$T = $ [[0]]

", "stepsPenalty": 0, "steps": [{"type": "information", "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": "

The 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{\\lvert\\overline{x}_1-\\overline{x}_2\\rvert}{s\\times\\sqrt{\\frac{1}{n_1}+\\frac{1}{n_2}}},\\]

\n

where $\\overline{x}_1,\\;\\overline{x}_2$ are the sample means and the pooled standard deviation $s$ is given by the formula 

\n

\\[s=\\sqrt\\frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2},\\]

\n

where $s_1,\\;s_2$ are the sample standard deviations.

"}], "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": "3", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "{abs(tvalue)-tol}", "maxValue": "{abs(tvalue)+tol}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "precisionType": "dp", "precision": "3", "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"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": "

Using the test statistic you have found, choose the range for the $p$-value by looking at the values below:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$10\\%$$5\\%$$1\\%$$0.1\\%$
$1.33$$1.73$$2.55$$3.61$
\n

[[0]]

", "gaps": [{"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, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "radiogroup", "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"}], "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": "

Given the $p$-value range you have found, what is the strength of evidence against the null hypothesis that there is no difference in the average Q-angle for males and females?

", "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": 0, "showCellAnswerState": true, "choices": ["

Very Strong Evidence

", "

Strong Evidence

", "

Evidence

", "

Weak Evidence

", "

No Evidence

"], "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": "

Hence, what is your decision based on the above analysis?

", "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": 0, "showCellAnswerState": true, "choices": ["

We reject the null hypothesis at the $0.1\\%$ level

", "

We reject the null hypothesis at the $1\\%$ level.

", "

We reject the null hypothesis at the $5\\%$ level.

", "

We do not reject the null hypothesis but consider further investigation.

", "

We do not reject the null hypothesis.

"], "matrix": "v"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "type": "question", "contributors": [{"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Vicky Hall", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/659/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}, {"name": "Lauren Frances Desoysa", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2490/"}, {"name": "Tom Lowe", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/9601/"}, {"name": "Pete Philipson", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/13881/"}]}]}], "contributors": [{"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Vicky Hall", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/659/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}, {"name": "Lauren Frances Desoysa", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2490/"}, {"name": "Tom Lowe", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/9601/"}, {"name": "Pete Philipson", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/13881/"}]}