Yadav_module_4
docx
keyboard_arrow_up
School
Northeastern University *
*We aren’t endorsed by this school
Course
6010
Subject
Statistics
Date
Apr 3, 2024
Type
docx
Pages
8
Uploaded by ConstableKudu4044
Manish Kumar Yadav
Module 4 R Practice
ALY 6010: Probability Theory and Introductory Statistics
Dr. A. Narayan
March 21, 2024
Introduction
In this report, we conducted two analyses using R. In Part 1, we performed a two-sample t-
test with unequal variance using the 'cats' dataset to compare the body weights of male and
female cats. We conducted the test twice, first with a significance level (alpha) of 0.05 and then with a significance level of 0.1. In Part 2, we evaluated the effect of meditation on sleep
quality using a paired t-test. Like Part 1, we conducted the paired t-test twice, once with alpha = 0.05 and again with alpha = 0.1.
The variables that are being analyzed or compared are:
Body Weight of Cats:
This variable represents the body weights of cats, specifically males and females. In the code, this variable is denoted by "Bwt" in the "cats" dataset.
Sleep Quality Scores:
This variable represents the sleep quality scores of individuals before and after meditation. In the code, this variable is represented by the "before" and "after" vectors.
Part 1 Two-sample t-test with unequal variance
#====================================Part -
1================================#
# installing the package and library so that we can use cats dataset
install.packages
(MASS)
## Error in install.packages : object 'MASS' not found
# loading the MASS library
library
(MASS)
#reading the dataset
data
(
"cats"
)
# Create separate vectors for male and female cat body weights
male <-
subset
(cats, subset =
(cats
$
Sex ==
"M"
))
$
Bwt
female <-
subset
(cats, subset =
(cats
$
Sex ==
"F"
))
$
Bwt
Performing a two-sample t-test which is a statistical hypothesis test that is used to
determine if there is a significant difference between the means of the two subsets (male, female). Taking significance level (alpha) = 0.05
The var.equal argument is set to FALSE, to accommodate potentially different variances between the two groups.
# Perform two-sample t-test with unequal variance where alpha = 0.05
t.test
(male, female, var.equal =
FALSE
)
## ## Welch Two Sample t-test
## ## data: male and female
## t = 8.7095, df = 136.84, p-value = 8.831e-15
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.4177242 0.6631268
## sample estimates:
## mean of x mean of y ## 2.900000 2.359574
Null Hypothesis (H0):
The mean body weight of male cats is equal to the mean body weight of female cats.
Alternative Hypothesis (Ha):
The mean body weight of male cats is not equal to the mean body weight of female cats.
Output:
t-value:
8.7095
Degrees of Freedom:
136.84
p-value:
8.831e-15
Mean of male cat body weights (x):
2.900000
Mean of female cat body weights (y):
2.359574
Findings with interpretation:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
If the p-value is less than the chosen significance level (alpha = 0.05), we reject the null hypothesis.
If the p-value is greater than the significance level (alpha = 0.05), we fail to reject the
null hypothesis.
The p-value (p = 8.831e-15) is less than the significance level of 0.05, indicating strong evidence against the null hypothesis. Therefore
, we reject the null hypothesis
and conclude that there is a significant difference in mean body weight between male and female cats. Specifically, the mean body weight of male cats is significantly higher than that of female cats.
#===================================Part
2==================================#
Paired T-test for Before and After Meditation
Creating separate vectors (before and after) of average sleeping quality score, so that we can do the paired t-test between the two. Taking alpha = 0.05.
# sleeping quality scores before and after meditation
before <-
c
(
4.6
, 7.8
, 9.1
, 5.6
, 6.9
, 8.5
, 5.3
, 7.1
, 3.2
, 4.4
)
after <-
c
(
6.6
, 7.7
, 9.0
, 6.2
, 7.8
, 8.3
, 5.9
, 6.5
, 5.8
, 4.9
)
Paired = true because we are using the same 10 students for before and after analysis.
# Perform paired t-test where alpha = 0.05
t.test
(before, after, paired =
TRUE
)
## ## Paired t-test
## ## data: before and after
## t = -1.9481, df = 9, p-value = 0.08322
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## -1.33995222 0.09995222
## sample estimates:
## mean difference ## -0.62
Null Hypothesis (H0):
There is no difference in the average sleeping quality scores before and after meditation.
Alternative Hypothesis (Ha):
There is a difference in the average sleeping quality scores before and after meditation.
Output:
t-value:
-1.9481
Degrees of Freedom:
9
p-value:
0.08322
Findings with interpretation:
If the p-value is less than the chosen significance level (alpha = 0.05), we reject the null hypothesis.
If the p-value is greater than the significance level (alpha = 0.05), we fail to reject the
null hypothesis.
As the p-value is greater than the significance level (p-value (0.0832) > 0.05). This analysis showed no significant difference in average sleep quality before and after meditation. We fail to reject the null hypothesis
. This suggests that meditation does not have a significant impact on sleep quality based on the provided data.
Changing Significance Level
#if the level of significance changes from 0.05 to 0.1
The conf.level = 0.9 argument in the t.test() function specifies the confidence level for the confidence interval. In a two-sided test with a 90% confidence level, the significance level (alpha) is implicitly set to 0.1, as the confidence level and the significance level sum up to 1.
With conf.level = 0.9.
# perform paired t-test with alpha = 0.1
t.test
(before, after, paired =
TRUE
, alternative =
"two.sided"
, conf.level =
0.9
)
## ## Paired t-test
## ## data: before and after
## t = -1.9481, df = 9, p-value = 0.08322
## alternative hypothesis: true mean difference is not equal to 0
## 90 percent confidence interval:
## -1.20340497 -0.03659503
## sample estimates:
## mean difference ## -0.62
Null Hypothesis (H0):
There is no difference in the average sleeping quality scores before and after meditation.
Alternative Hypothesis (Ha):
There is a difference in the average sleeping quality scores before and after meditation.
Output:
t-value:
-1.9481
Degrees of Freedom:
9
p-value:
0.08322
Findings with interpretation:
If the p-value is less than the chosen significance level (alpha = 0.1), we reject the null hypothesis.
If the p-value is greater than the significance level (alpha = 0.1), we fail to reject the null hypothesis.
As the p-value is smaller than the significance level (p-value (0.0832) < 0.1).
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
We reject the null hypothesis
. The analysis showed there is a significant difference in average sleep quality before and after meditation.
Justification of the Testing Procedure
In Part 1,
we chose a two-sample t-test with unequal variance to compare the body weight of male and female cats. This test is suitable for assessing differences in mean body weight between independent groups (male and female cats). As the groups are independent, a two-sample t-test is appropriate. We opted for an unequal variance assumption to accommodate potentially different variances between the two groups, ensuring robustness in our analysis.
In Part 2,
a paired t-test was chosen to assess the effect of meditation on sleep quality. This
test is suitable for within-subject designs, where the same individual's sleep quality was measured before and after the meditation. This approach allows for a precise assessment of the treatment effect within the same group, increasing the statistical power of the analysis.
Conclusion
Part 1:
The analysis revealed a significant difference in body weights between male and female cats. Male cats were found to have significantly higher body weights compared to female cats.
Part 2:
The results of the analysis on sleep quality before and after meditation varied based
on the chosen significance level (alpha).
With alpha set to 0.05, there was no significant difference observed in sleep quality before and after meditation.
However, when alpha was increased to 0.1, the analysis indicated a significant difference in sleep quality before and after meditation.
Overall, the findings do not provide conclusive evidence regarding the claim that meditation improves sleeping quality. While the analysis did not find a significant
difference in sleep quality at a significance level(alpha) of 0.05, a significant difference was observed when the significance level was increased to 0.1.
Related Documents
Recommended textbooks for you

Glencoe Algebra 1, Student Edition, 9780079039897...
Algebra
ISBN:9780079039897
Author:Carter
Publisher:McGraw Hill

College Algebra (MindTap Course List)
Algebra
ISBN:9781305652231
Author:R. David Gustafson, Jeff Hughes
Publisher:Cengage Learning

Recommended textbooks for you
- Glencoe Algebra 1, Student Edition, 9780079039897...AlgebraISBN:9780079039897Author:CarterPublisher:McGraw HillCollege Algebra (MindTap Course List)AlgebraISBN:9781305652231Author:R. David Gustafson, Jeff HughesPublisher:Cengage Learning

Glencoe Algebra 1, Student Edition, 9780079039897...
Algebra
ISBN:9780079039897
Author:Carter
Publisher:McGraw Hill

College Algebra (MindTap Course List)
Algebra
ISBN:9781305652231
Author:R. David Gustafson, Jeff Hughes
Publisher:Cengage Learning
