Question

In: Computer Science

sleep data analysis: a) What is the dataset “sleep” in R? and its description? b) Draw...

sleep data analysis:

a) What is the dataset “sleep” in R? and its description?

b) Draw boxplots for two drug groups in ONE plot.

c) Set up a hypothesis (null and alternative) for testing whether there exists an effect difference between two drugs. Using both words and symbols for hypothesis settings. (Hint: this is a paired sample test, rather than a general two sample t test.)

d) Use an appropriate formula to calculate the test statistic and find its p-value for part c) and draw a conclusion at the significance level α=0.05.

e) Check the function “t.test”in R, i.e, read the description of this function and its usage, values, and even play the examples provided at the end of the help page. What is the function description?

f) Use the function “t.test” in R to answer c) with the significance level α=0.05. (Hint: you need to change the “paired” status from FALSE to TRUE) g) Compare the conclusions in d) and f) Attach all the R code you used for this problem.

Solutions

Expert Solution

1.

datasets

Usage

sleep

Details

The group variable name may be misleading about the data: They represent measurements on 10 persons, not in groups.

Format

A data frame with 20 observations on 3 variables.

1 Extea numeric increase in hours of sleep
2 Group factor drug given

# NOT RUN {
require(stats)
## Student's paired t-test
with(sleep,
t.test(extra[group == 1],
extra[group == 2], paired = TRUE))

## The sleep *prolongations*
sleep1 <- with(sleep, extra[group == 2] - extra[group == 1])
summary(sleep1)
stripchart(sleep1, method = "stack", xlab = "hours",
main = "Sleep prolongation (n = 10)")
boxplot(sleep1, horizontal = TRUE, add = TRUE,
at = .6, pars = list(boxwex = 0.5, staplewex = 0.25))
# }

2.

Description

Data which show the effect of two soporific drugs (increase in hours of sleep compared to control) on 10 patients.

Usage

sleep

Format

A data frame with 20 observations on 3 variable

1 extra Numeric increase in hours of sleep
2 group Factor Drugs given
3 Id Factor Patient ID

Details

The group variable name may be misleading about the data: They represent measurements on 10 persons, not in groups

require(stats)
## Student's paired t-test
with(sleep,
     t.test(extra[group == 1],
            extra[group == 2], paired = TRUE))

## The sleep *prolongations*
sleep1 <- with(sleep, extra[group == 2] - extra[group == 1])
summary(sleep1)
stripchart(sleep1, method = "stack", xlab = "hours",
           main = "Sleep prolongation (n = 10)")
boxplot(sleep1, horizontal = TRUE, add = TRUE,
        at = .6, pars = list(boxwex = 0.5, staplewex = 0.25))

3


Related Solutions

Use "PLUC" data and the description for the dataset on the blackboard. Is there sufficient evidence...
Use "PLUC" data and the description for the dataset on the blackboard. Is there sufficient evidence that the population mean of "PLUC.pre" is different than that of "PLUC.post"? Use R to find the p-value for the test. ***Answer is 8.739E-08*** PLUC.post PLUC.pre 6.483496 8.078464 8.607279 8.539505 12.41932 13.32073 11.72048 8.640824 12.26601 9.979111 11.15877 8.878284 7.527066 10.6834 10.60626 8.728163 6.276827 10.68463 10.1099 11.35035 6.520483 12.71441 11.91813 8.892171 10.66304 8.830107 9.777328 10.50259 9.220989 5.537055 11.79612 8.710783 11.11839 12.75601 8.965028 6.423624 11.48719 3.823811...
For this step, you should draw an E-R Diagram for this dataset. To this goal, you...
For this step, you should draw an E-R Diagram for this dataset. To this goal, you should conduct the following steps: 1. Identify the entities and composite entities 2. Identify the entities’ attributes and primary key 3. Identify the relationships among the entities and between entities and composite entities 4. Specify the relationships' integrities
Use "PLUC" data and the description for the dataset on the blackboard. Conduct a two sample...
Use "PLUC" data and the description for the dataset on the blackboard. Conduct a two sample independent t test to test if the population means of heights of male is higher than that of female. Use R to calculate the p-value. ***Answer is 0.8974*** sex hgt m 45.68187 m 54.76593 m 43.80479 f 46.1765 m 57.60508 f 40.02826 f 52.50647 f 43.14426 m 45.27999 m 41.95513 m 43.67319 f 58.09449 m 42.47022 f 55.91853 m 44.01857 f 43.25757 m 57.4945...
Use "PLUC" data and the description for the dataset on the blackboard. Conduct a two sample...
Use "PLUC" data and the description for the dataset on the blackboard. Conduct a two sample independent t test to test if the population means of heights of male is higher than that of female. Use R to calculate the p-value. ***Answer is 0.8974*** sex hgt m 45.68187 m 54.76593 m 43.80479 f 46.1765 m 57.60508 f 40.02826 f 52.50647 f 43.14426 m 45.27999 m 41.95513 m 43.67319 f 58.09449 m 42.47022 f 55.91853 m 44.01857 f 43.25757 m 57.4945...
Instructions tell you how to get the data in R R has built in dataset called...
Instructions tell you how to get the data in R R has built in dataset called Iris. This famous (Fisher's or Anderson's) iris data set gives the measurements in centimeters of the variables sepal length and width and petal length and width, respectively, for 50 flowers from each of 3 species of iris. The species are Iris setosa, versicolor, and virginica. We are interested in estimating the length of Petal (Y) using the length of Sepal (X). First, load the...
R has many build-in dataset. The data mtcars is one of them. The following R code...
R has many build-in dataset. The data mtcars is one of them. The following R code read-in data and save the data to input.                   input <- mtcars[,c("am","cyl","hp","wt")]              Write a few line of R code to conduct a regression analysis with am as the response variable, and              cyl, hp, wt as explanation variables.
You will be performing an analysis on a dataset that contains data on fertility and life...
You will be performing an analysis on a dataset that contains data on fertility and life expectancy for 198 different countries. All data is from the year 2013. The fertility numbers are the average number of children per woman in each of the countries. The life expectancy numbers are the average life expectancy in each of the countries. You will be turning in a paper that should include section headings, graphics and tables when appropriate and complete sentences which explain...
The dataset ’anorexia’ in the MASS package in R-Studio contains data for an anorexia study. In...
The dataset ’anorexia’ in the MASS package in R-Studio contains data for an anorexia study. In the study, three treatments (Treat) were applied to groups of young female anorexia patients, and their weights before (Prewt) and after (Postwt) treatment were recorded. The three treatments adminstered were no treatment (Cont), Cognitive Behavioural treatment (CBT), and family treatment (FT). Determine at the 5% significance level if there is a difference in mean weight gain between those receiving no treatment and those receiving...
The dataset ’anorexia’ in the MASS package in R-Studio contains data for an anorexia study. In...
The dataset ’anorexia’ in the MASS package in R-Studio contains data for an anorexia study. In the study, three treat- ments (Treat) were applied to groups of young female anorexia patients, and their weights before (Prewt) and after (Postwt) treatment were recorded. The three treatments adminstered were no treatment (Cont), Cognitive Behavioural treatment (CBT), and family treatment (FT). Determine at the 5% significance level if there is a difference in mean weight gain between those receiving no treatment and those...
R has a number of datasets built in. One such dataset is called mtcars. This data...
R has a number of datasets built in. One such dataset is called mtcars. This data set contains fuel consumption and 10 aspects of automobile design and performance for 32 automobiles (1973-74 models) as reported in a 1974 issue of Motor Trend Magazine. We do not have to read in these built-in datasets. We can just attach the variables by using the code attach(mtcars) We can just type in mtcars and see the entire dataset. We can see the variable...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT