SlideShare a Scribd company logo
PSet5 Question 7
TA Kunyu (Quinn) He CAPP’20
2018.12.06
a = c(1.1650, 0.6268, 0.0751, 0.3516)
b = c(0.3035, 2.6861, 1.0591, 2.7971, 1.2641)
(a)
mu_a = mean(a)
mu_b = mean(b)
diff = mu_a - mu_b
diff
## [1] -1.067355
(b)
According to the pooled sample variance formula:
S_p = ((length(a)-1) * var(a) + (length(b)-1) * var(b)) / (length(a) + length(b) - 2)
S_p
## [1] 0.7636414
(c)
se = sqrt(S_p/length(a) + S_p/length(b))
se
## [1] 0.586207
(d)
Critical value at α = 0.05 and d.f. = 7:
qt(0.95, 7)
## [1] 1.894579
CI:
c(diff - qt(0.95, 7)*se, diff + qt(0.95, 7)*se)
## [1] -2.17797025 0.04326025
(e)
Here I test both positive and negative difference, since you might make your hypotheses in
different ways. But both ways come to the same result.
2 * pt(diff / se, df = 7)
## [1] 0.1114408
p-value is the probability, assuming that null hypothesis is correct, that we observe more extreme values than
our test statistic. In this case our test statistic is obtained by difference in the mean divided by standard
error as below:
diff / se
1
## [1] -1.820782
So here the test statistic is negative, pt function with df (degree of freedom) equals to 7 is giving back the
area under the pdf curve, left to -1.820782. This denotes the probability, assuming 0 difference, we observe
values lower than -1.820782.
We multiply this by 2 to get the p-value, as we are doing two-tailed hypothesis testing we need to take
probability of observing larger values than 1.820782 into consideration. Since pdf is symmetric, the probability
of observing larger values is the same.
2 * pt(-diff / se, df = 7, lower.tail = F)
## [1] 0.1114408
Since some of you go with positive difference. Here I tested it, assigning lower.tail=F, which gives me the
area under the pdf curve, right to the test statistic(1.820782). Multiply it by 2, we get the same p-value.
When it comes to finding the probability with t-table, if you’re testing a negative test-statistic, go to the t-table
with its absolute value, get the corresponding probability. Since t-table always give back upper-tail
probability, what you need to do is just multiply that by 2.
Always useful to have the pdf in mind:
curve(dt(x, 7), from = -4, to = 4, col = "orange",
xlab = "Quantile", ylab = "Density", lwd = 2)
−4 −2 0 2 4
0.00.10.20.30.4
Quantile
Density
(h)
2
S = 1
se = sqrt(S/length(a) + S/length(b))
se
## [1] 0.6708204
CI = c(diff - qnorm(0.95)*se, diff + qnorm(0.95)*se)
CI
## [1] -2.17075636 0.03604636
p-value:
2 * pnorm(diff / se)
## [1] 0.1115828
pdf of standard normal distribution:
curve(dnorm(x), from = -4, to = 4, col = "blue",
xlab = "Quantile", ylab = "Density", lwd = 2)
−4 −2 0 2 4
0.00.10.20.30.4
Quantile
Density
3

More Related Content

PPTX
Candidate elimination example
PPTX
Golden Section method
PPS
Higher Order Procedures (in Ruby)
PPTX
1 representation of_functions
PPTX
Numerical on dichotomous search
PDF
Day 1 examples new
PPTX
Mean, median, mode
Candidate elimination example
Golden Section method
Higher Order Procedures (in Ruby)
1 representation of_functions
Numerical on dichotomous search
Day 1 examples new
Mean, median, mode

What's hot (20)

PPT
Lar calc10 ch04_sec4
PDF
Rademacher Averages: Theory and Practice
PDF
Basic galois field arithmatics required for error control codes
PPT
Bisection method in maths 4
PPTX
Numerical on bisection method
PDF
Common symbols used in set theory
PPT
2 1 Bzca5e
PPT
UNIT .01
PDF
A NEW STUDY OF TRAPEZOIDAL, SIMPSON’S1/3 AND SIMPSON’S 3/8 RULES OF NUMERICAL...
PPT
Pat05 ppt 0201
PDF
C Language Lecture 20
PPTX
Bisection method
PPT
L 4 4
PPTX
Bisection method
PDF
Physics 0625 - Paper 5 version 3 - Mark scheme - May Jun 2014
PPTX
An Interactive Introduction To R (Programming Language For Statistics)
PPTX
Gauss Quadrature Formula
PDF
PERMUTATION LABELING OF JOINS OF KITE GRAPH
PPT
Multi dimensional arrays
PPTX
Lar calc10 ch04_sec4
Rademacher Averages: Theory and Practice
Basic galois field arithmatics required for error control codes
Bisection method in maths 4
Numerical on bisection method
Common symbols used in set theory
2 1 Bzca5e
UNIT .01
A NEW STUDY OF TRAPEZOIDAL, SIMPSON’S1/3 AND SIMPSON’S 3/8 RULES OF NUMERICAL...
Pat05 ppt 0201
C Language Lecture 20
Bisection method
L 4 4
Bisection method
Physics 0625 - Paper 5 version 3 - Mark scheme - May Jun 2014
An Interactive Introduction To R (Programming Language For Statistics)
Gauss Quadrature Formula
PERMUTATION LABELING OF JOINS OF KITE GRAPH
Multi dimensional arrays
Ad

Similar to P set5 question_7 (20)

PPTX
Data science - Handling Outliers
PDF
Ning_Mei.ASSIGN03
PPTX
Interpreting Logistic Regression.pptx
PPTX
Probability Assignment Help
PPTX
udjjjmmmmkxkkkskllklkakk,z,,,skkdmmxjd.pptx
PDF
CDT 22 slides.pdf
PPTX
statistics assignment help
PDF
Problem Solving by Computer Finite Element Method
PDF
Probability and stochastic processes 3rd edition Quiz Solutions
PDF
Statistical Inference Using Stochastic Gradient Descent
PDF
Statistical Inference Using Stochastic Gradient Descent
PDF
module4_dynamic programming_2022.pdf
PDF
NCE, GANs & VAEs (and maybe BAC)
PDF
Unbiased Bayes for Big Data
PPSX
Comparison GUM versus GUM+1
PPT
logistic regression.............................................................
PPT
logisticregressionJeffWitnerMarch2016.ppt
PDF
t-tests in R - Lab slides for UGA course FANR 6750
PDF
Adaptive
PPT
lecture 15
Data science - Handling Outliers
Ning_Mei.ASSIGN03
Interpreting Logistic Regression.pptx
Probability Assignment Help
udjjjmmmmkxkkkskllklkakk,z,,,skkdmmxjd.pptx
CDT 22 slides.pdf
statistics assignment help
Problem Solving by Computer Finite Element Method
Probability and stochastic processes 3rd edition Quiz Solutions
Statistical Inference Using Stochastic Gradient Descent
Statistical Inference Using Stochastic Gradient Descent
module4_dynamic programming_2022.pdf
NCE, GANs & VAEs (and maybe BAC)
Unbiased Bayes for Big Data
Comparison GUM versus GUM+1
logistic regression.............................................................
logisticregressionJeffWitnerMarch2016.ppt
t-tests in R - Lab slides for UGA course FANR 6750
Adaptive
lecture 15
Ad

Recently uploaded (20)

PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Classroom Observation Tools for Teachers
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
master seminar digital applications in india
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
Institutional Correction lecture only . . .
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Cell Structure & Organelles in detailed.
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Complications of Minimal Access Surgery at WLH
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
Microbial disease of the cardiovascular and lymphatic systems
Classroom Observation Tools for Teachers
Final Presentation General Medicine 03-08-2024.pptx
O7-L3 Supply Chain Operations - ICLT Program
master seminar digital applications in india
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Institutional Correction lecture only . . .
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
O5-L3 Freight Transport Ops (International) V1.pdf
01-Introduction-to-Information-Management.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
A systematic review of self-coping strategies used by university students to ...
Cell Structure & Organelles in detailed.
GDM (1) (1).pptx small presentation for students
human mycosis Human fungal infections are called human mycosis..pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Complications of Minimal Access Surgery at WLH
102 student loan defaulters named and shamed – Is someone you know on the list?

P set5 question_7

  • 1. PSet5 Question 7 TA Kunyu (Quinn) He CAPP’20 2018.12.06 a = c(1.1650, 0.6268, 0.0751, 0.3516) b = c(0.3035, 2.6861, 1.0591, 2.7971, 1.2641) (a) mu_a = mean(a) mu_b = mean(b) diff = mu_a - mu_b diff ## [1] -1.067355 (b) According to the pooled sample variance formula: S_p = ((length(a)-1) * var(a) + (length(b)-1) * var(b)) / (length(a) + length(b) - 2) S_p ## [1] 0.7636414 (c) se = sqrt(S_p/length(a) + S_p/length(b)) se ## [1] 0.586207 (d) Critical value at α = 0.05 and d.f. = 7: qt(0.95, 7) ## [1] 1.894579 CI: c(diff - qt(0.95, 7)*se, diff + qt(0.95, 7)*se) ## [1] -2.17797025 0.04326025 (e) Here I test both positive and negative difference, since you might make your hypotheses in different ways. But both ways come to the same result. 2 * pt(diff / se, df = 7) ## [1] 0.1114408 p-value is the probability, assuming that null hypothesis is correct, that we observe more extreme values than our test statistic. In this case our test statistic is obtained by difference in the mean divided by standard error as below: diff / se 1
  • 2. ## [1] -1.820782 So here the test statistic is negative, pt function with df (degree of freedom) equals to 7 is giving back the area under the pdf curve, left to -1.820782. This denotes the probability, assuming 0 difference, we observe values lower than -1.820782. We multiply this by 2 to get the p-value, as we are doing two-tailed hypothesis testing we need to take probability of observing larger values than 1.820782 into consideration. Since pdf is symmetric, the probability of observing larger values is the same. 2 * pt(-diff / se, df = 7, lower.tail = F) ## [1] 0.1114408 Since some of you go with positive difference. Here I tested it, assigning lower.tail=F, which gives me the area under the pdf curve, right to the test statistic(1.820782). Multiply it by 2, we get the same p-value. When it comes to finding the probability with t-table, if you’re testing a negative test-statistic, go to the t-table with its absolute value, get the corresponding probability. Since t-table always give back upper-tail probability, what you need to do is just multiply that by 2. Always useful to have the pdf in mind: curve(dt(x, 7), from = -4, to = 4, col = "orange", xlab = "Quantile", ylab = "Density", lwd = 2) −4 −2 0 2 4 0.00.10.20.30.4 Quantile Density (h) 2
  • 3. S = 1 se = sqrt(S/length(a) + S/length(b)) se ## [1] 0.6708204 CI = c(diff - qnorm(0.95)*se, diff + qnorm(0.95)*se) CI ## [1] -2.17075636 0.03604636 p-value: 2 * pnorm(diff / se) ## [1] 0.1115828 pdf of standard normal distribution: curve(dnorm(x), from = -4, to = 4, col = "blue", xlab = "Quantile", ylab = "Density", lwd = 2) −4 −2 0 2 4 0.00.10.20.30.4 Quantile Density 3