Question

In: Statistics and Probability

# R Hypothesis Tests install.packages("dplyr") tScore_before <- c(40, 62, 74, 22, 64, 65, 49, 49, 49)...

# R Hypothesis Tests

install.packages("dplyr")

tScore_before <- c(40, 62, 74, 22, 64, 65, 49, 49, 49)

tScore_after <- c(68, 61, 64, 76, 90, 75, 66, 60, 63)

# Create a data frame

my_data <- data.frame(

                group = rep(c("Score Before", "Score After"), each = 9),

                scores = c(tScore_before, tScore_after)

                )

# Print all data

print(my_data)

#Compute summary statistics by groups

library(dplyr)

group_by(my_data, group) %>%

summarise(

    count = n(),

    mean = mean(scores, na.rm = TRUE),

    sd = sd(scores, na.rm = TRUE)

)

# Compute Unpaired Two Sample t-test

res <- t.test(tScore_before, tScore_after, var.equal = TRUE)

res

# Compute independent t-test

res <- t.test(scores ~ group, data = my_data, var.equal = TRUE)

res

#test whether the average score before score is less than the average after score, type this:

t.test(scores ~ group, data = my_data,

        var.equal = TRUE, alternative = "less")

The instructions say to include a snippet of the graph created but I do not get a graph after running this code. Just wanted to make sure there is not one.

Solutions

Expert Solution

*************OUTPUT after RUNNING CODE IN R**************

> # R Hypothesis Tests
>
> #install.packages("dplyr")
>
>
> tScore_before <- c(40, 62, 74, 22, 64, 65, 49, 49, 49)
>
> tScore_after <- c(68, 61, 64, 76, 90, 75, 66, 60, 63)
>
> # Create a data frame
>
> my_data <- data.frame(
+   
+ group = rep(c("Score Before", "Score After"), each = 9),
+   
+ scores = c(tScore_before, tScore_after)
+   
+ )
>
>
> # Print all data
>
> print(my_data)
group scores
1 Score Before 40
2 Score Before 62
3 Score Before 74
4 Score Before 22
5 Score Before 64
6 Score Before 65
7 Score Before 49
8 Score Before 49
9 Score Before 49
10 Score After 68
11 Score After 61
12 Score After 64
13 Score After 76
14 Score After 90
15 Score After 75
16 Score After 66
17 Score After 60
18 Score After 63
>
>
> #Compute summary statistics by groups
>
> library(dplyr)
>
> group_by(my_data, group) %>%
+   
+ summarise(
+   
+ count = n(),
+   
+ mean = mean(scores, na.rm = TRUE),
+   
+ sd = sd(scores, na.rm = TRUE)
+   
+ )
# A tibble: 2 x 4
group count mean sd
<fct> <int> <dbl> <dbl>
1 Score After 9 69.2 9.63
2 Score Before 9 52.7 15.7
>
>
> # Compute Unpaired Two Sample t-test
>
> res <- t.test(tScore_before, tScore_after, var.equal = TRUE)
>
> res

   Two Sample t-test

data: tScore_before and tScore_after
t = -2.7007, df = 16, p-value = 0.01575
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-29.550620 -3.560491
sample estimates:
mean of x mean of y
52.66667 69.22222

>
>
> # Compute independent t-test
>
> res <- t.test(scores ~ group, data = my_data, var.equal = TRUE)
>
> res

   Two Sample t-test

data: scores by group
t = 2.7007, df = 16, p-value = 0.01575
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
3.560491 29.550620
sample estimates:
mean in group Score After mean in group Score Before
69.22222 52.66667

>
>
> #test whether the average score before score is less than the average after score, type this:
>
> t.test(scores ~ group, data = my_data,
+
+ var.equal = TRUE, alternative = "less")

   Two Sample t-test

data: scores by group
t = 2.7007, df = 16, p-value = 0.9921
alternative hypothesis: true difference in means is less than 0
95 percent confidence interval:
-Inf 27.25786
sample estimates:
mean in group Score After mean in group Score Before
69.22222 52.66667

*********************************************************************

No commmand in code create graph.so these code doesn't have graph.


Related Solutions

Flu 0-18 years 7 19-34 years 22 35-49 Years 40 50-64 Years 57 65 years or...
Flu 0-18 years 7 19-34 years 22 35-49 Years 40 50-64 Years 57 65 years or older 61 Total Cases 187 The age distribution has 20% of its citizens under the age of 18 and 13% over the age of 65. Using this information, answer the following questions. Back up your conclusions with an appropriate test. To receive full credit, include the test statistic, p-value, expected counts and conclusion in plain English. 1. Does the age distribution statistically differ from...
36, 52, 60, 60, 62, 65, 65, 65, 70, 72, 74, 75, 75, 76, 76, 78,...
36, 52, 60, 60, 62, 65, 65, 65, 70, 72, 74, 75, 75, 76, 76, 78, 79, 79, 80, 80, 82, 83, 84, 85, 88, 90, 90, 92, 95, 98, 99 Please find the upper bound of the above set:
moving = data.frame (hours = c(49, 61.5, 65, 38, 26, 46, 28, 45.5, 35.5, 62, 18,...
moving = data.frame (hours = c(49, 61.5, 65, 38, 26, 46, 28, 45.5, 35.5, 62, 18, 11, 53, 22, 59.5, 17, 44, 49, 45, 24.5, 25, 43, 29, 37, 20.5, 31, 29, 19.5, 17.5, 14, 41, 37, 27, 25.5, 43.5, 41.5, 65.5, 45, 18, 54.5, 53, 11, 13.5), size = c(940, 1187, 1135, 849, 524, 992, 563, 953, 628, 1122, 394, 264, 1109, 472, 1148, 316, 875, 1096, 836, 355, 407, 693, 745, 719, 511, 667, 576, 498, 381, 459,...
C++ Text file contains numbers 92 87 65 49 92 100 100 100 82 75 64...
C++ Text file contains numbers 92 87 65 49 92 100 100 100 82 75 64 55 100 98 -99 Modify your program from Exercise 1 so that it reads the information from the gradfile.txt file, reading until the end of file is encountered. You will need to first retrieve this file from the Lab 7 folder and place it in the same folder as your C++ source code. Run the program #include <iostream> using namespace std; typedef int GradeType[100];...
X | 65 67 62 68 66 69 61 67 64 69 Y | 110 105...
X | 65 67 62 68 66 69 61 67 64 69 Y | 110 105 113 107 109 111 104 110 116 115 A)Given the paired data set above of Super Models heights and weights, then Determine the Line of Regression. B)Calculate the Coefficient of Correlation for the data set C) Using the Line of Regression from the data set, predict the weight of a Model who is 69 inches tall. D) Using the data set construct a Scatter...
A 100 kW, 8-cylinder R-22 compressor with 20 kW power operates at zero & 40 C...
A 100 kW, 8-cylinder R-22 compressor with 20 kW power operates at zero & 40 C evaporating & condensing temps. The compressor bore 0.07 m & stroke 0.06 m with clearance volume of 5% runs at 30 rev/sec. Determine: a. Draw the PH diagram indicating all enthalpy & sp. vol. b. Volumetric efficiency c. Suction volume, m3/s d. Piston displacement, m3/s e. Actual volumetric efficiency f. Actual work of compressor, kJ/kg g. Isentropic work of compression, kJ/kg h. Compression or...
Lower Class Limit Upper Class Limit Frequency 60 64 3 65 69 7 70 74 3...
Lower Class Limit Upper Class Limit Frequency 60 64 3 65 69 7 70 74 3 75 79 7 80 84 7 85 89 11 90 94 10 95 99 9 100 104 12 (a) What is the 11th percentile for the following Grouped Frequency Data Table? (b) What is the 4th decile for the following Grouped Frequency Data Table?
X 28 39 32 37 44 22 40 Y 83 108 97 108 107 74 114...
X 28 39 32 37 44 22 40 Y 83 108 97 108 107 74 114 The standard error of the estimate for the above bivariate data is: Question 3 options: 5.45 5.65 5.85 6.05
_ 18-22 23-35 36-49 50-64 65_and_over Several_times_a_day 21 18 9 2 1 About_once_a_day 27 39 13...
_ 18-22 23-35 36-49 50-64 65_and_over Several_times_a_day 21 18 9 2 1 About_once_a_day 27 39 13 3 2 3-5_times_per_week 31 44 31 6 3 1-2_times_per_week 30 70 34 15 5 Every_few_weeks 19 67 45 25 8 Less_Often 14 57 59 65 16 Never 5 15 44 68 21 How often do users of a certain social media post on the​ site? The accompanying table represents the frequency of posting for a sample of 932 respondents classified according to their age...
Is there a relationship between confidence intervals and two-tailed hypothesis tests? Let c be the level...
Is there a relationship between confidence intervals and two-tailed hypothesis tests? Let c be the level of confidence used to construct a confidence interval from sample data. Let α be the level of significance for a two-tailed hypothesis test. The following statement applies to hypothesis tests of the mean. For a two-tailed hypothesis test with level of significance α and null hypothesis H0: μ = k, we reject H0 whenever k falls outside the c = 1 –  α confidence interval...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT