Question

In: Statistics and Probability

Here is the R code for running a t-test: t.test( numeric vector of data values, another...

Here is the R code for running a t-test:

t.test( numeric vector of data values, another optional numeric vector of data values,

       alternative = c("two.sided", "less", "greater"),

       mu = Ho, paired = c(TRUE, FALSE), var.equal = c(TRUE,FALSE),conf.level =1-)

2)

You want to determine if the average height of men in California is greater than the average height of men in Nebraska. You take a random sample of 30 men in California and 30 men in Nebraska. The data below represents the heights of the men in inches. Write the R code that does the following:

H0: Difference in means in populations is zero.

Ha: Difference in means in the populations is not zero.

NE_heights<-c( 73.5, 68.5, 70, 63, 64, 65, 64, 70, 61, 61.25, 69, 73, 69, 66, 69.5, 68,

64, 64, 72.5, 69, 67, 63, 66.5, 70.5, 64, 67, 71, 74, 68, 65)

CA_heights <- c( 72, 73.5, 74, 75, 66, 78, 70, 73, 74, 68, 71, 68, 67, 66, 73, 72, 82, 71, 64, 72, 65, 66, 69, 83, 67, 74, 76, 65, 74, 79)

  

a.) Makes two boxplots, an orange one for the CA_heights data and a red one for the NE_heights data which labels the main title "Men’s heights California vs Nebraska" and names the CA_heights data as "CA heights" and the NE_heights data as "NE heights".

b.) Computes the, sample size, mean and standard deviation of both CA_heights and NE_heights data.

c.) Performs an unpaired "less" than t-test with =.02 to decide whether there is a statistically significant difference between men’s heights in California and Nebraska.

d.) Paste your R code into Run R Script and run the script.

e.) Paste the R output to the bottom R code.

f.) Looking at the p-value in the R output, decide if there is evidence to suggest that there is a statistically significant difference between men’s heights in California and Nebraska.

Write the p-value and your conclusion at the top of your R code.

Solutions

Expert Solution

> NE_heights<-c( 73.5, 68.5, 70, 63, 64, 65, 64, 70, 61, 61.25, 69, 73, 69, 66, 69.5, 68,64,64,72.5,69,67,63,66.5,70.5,64,67,71,74,68,65)
> CA_heights <- c( 72, 73.5, 74, 75, 66, 78, 70, 73, 74, 68, 71, 68, 67, 66, 73, 72, 82, 71, 64, 72, 65, 66, 69, 83, 67, 74, 76, 65, 74, 79)
> dataframe=data.frame(NE_heights,CA_heights)
> colnames(dataframe)=c("NE_heights","CA_heights")
> boxplot(dataframe,horizontal=FALSE,las=1,notch=FALSE,outline=TRUE,outcol="#000000",outpch=19, col="#000000",xlab="",ylab="", main="",sub="",col.lab="#000000",col.main="#000000",col.sub="#000000",col.axis="#000000",cex.lab=1,cex.main=1,cex.sub=1,cex.axis=1)

(unable paste the box plot)

> sample_size_n1
[1] 30
> sample_size_n2=length(CA_heights)
> sample_size_n2
[1] 30
> m1=mean(NE_heights)
> m1
[1] 67.34167
> m2=mean(CA_heights)
> m2
[1] 71.58333
> std_dev_1=sqrt(var(NE_heights))
> std_dev_1
[1] 3.610619
> std_dev_2=sqrt(var(CA_heights))
> std_dev_2
[1] 4.958593

> t.test(NE_heights,CA_heights,var.equal=T,,level=0.98)

   Two Sample t-test

data: NE_heights and CA_heights
t = -3.7876, df = 58, p-value = 0.0001818
alternative hypothesis: true difference in means is less than 0
95 percent confidence interval:
-Inf -2.369721
sample estimates:
mean of x mean of y
67.34167 71.58333

Conclusion: Here p-value is significant i,e p-value= 0.0001818< 0.02 level of significance, we may reject null hypothesis at 2% level of significance, and conclude that there is sufficient evidence that the difference in the mean of two heights population is significant.


Related Solutions

Here is the R code for running a t-test: t.test( numeric vector of data values, another...
Here is the R code for running a t-test: t.test( numeric vector of data values, another optional numeric vector of data values,        alternative = c("two.sided", "less", "greater"),        mu = Ho, paired = c(TRUE, FALSE), var.equal = c(TRUE,FALSE),conf.level =1-) 1.) Suppose 30 students are all taking the same Math 115 and English 101 classes at CSUN. You want to know in which class students tend to do better. The data below represents the class averages of the students in both classes....
Given a vector of numeric values. with a R function using loop. testdouble(data). that returns TRUE...
Given a vector of numeric values. with a R function using loop. testdouble(data). that returns TRUE if all the even indexs elements of the vector are twice their preceding value, other wise your function returns FALSE. You can assume that the given vector has an even number of values. TRUE scenarios: c(3, 6, 5, 10, 11, 22, 13, 26) c(0, 0,1, 2, 2, 4, 3, 6) FALSE scenarios: c(3, 7, 5, 6, 11, 22, 13, 26) c(0, 2, 1, 2,...
Using R code solve Here, we look at how t critical values behave as their df...
Using R code solve Here, we look at how t critical values behave as their df (degrees of freedom) increases: a. First, what is z.05? b. Second, if you look at t.05,df (t critical values for α = .05) with df = 20, 40, 60, etc (continuing up by 20 each time), for what df does the t critical value first fall strictly within (e.g. < ) i. .05 of z.05? ii. .02 of z.05? iii. .01 of z.05? c....
Numeric results for several independent samples t tests are presented here. Decide whether each test is...
Numeric results for several independent samples t tests are presented here. Decide whether each test is statistically significant, and report each result in the standard APA format. A total of 73 people were studied, 40 in one group and 33 in the other group. The test statistic was calculated as 2.13 for a two tailed test with a p level of .05 One group of 23 people was compared to another group of 18 people. The t statistic obtained for...
Data Analysis & Visualization Topic R vector and save the r code in a text file...
Data Analysis & Visualization Topic R vector and save the r code in a text file Problem 1. Create two vectors named v and w with the following contents:      v : 21,10,32,2,-3,4,5,6,7,4,-22      w : -18,72,11,-9,10,2,34,-5,18,9,2 A) Print the length of the vectors B) Print all elements of the vectors C) Print elements at indices 3 through 7. D) Print the sum of the elements in each vector. E) Find the mean of each vector. (Use R's mean() function)...
Data Structures for R studio Create a numeric vector containing 10 random numbers ranging from 1...
Data Structures for R studio Create a numeric vector containing 10 random numbers ranging from 1 to 10000. Validate that the object you created is a vector Give an example of where you might find this in a biologicall data set. Create a 10-member list containg both numeric and character data. Validate that the object you created is a list Give an example of where you might find this in a biologicall data set. Create a data frame that relates...
Consider a numeric vector x (e.g., x=c(2,3,-1,1.2,2.6,0)), write the R code that determine whether each element...
Consider a numeric vector x (e.g., x=c(2,3,-1,1.2,2.6,0)), write the R code that determine whether each element of x is (Verify that your code work correctly): (a) positive (b) non-positive (c) even or odd (d) an integer
In R, Create a function that replaces the negative values in a numeric matrix with a...
In R, Create a function that replaces the negative values in a numeric matrix with a random integer between 1 and 10. At the same time, it counts the negative values and prints their number. Apply the function to a 4 by 5 matrix of random continuous uniform values ranging from -10 to 10.
What are the values you get from "data[,1]" and "data[,2]" in r code? Are the values...
What are the values you get from "data[,1]" and "data[,2]" in r code? Are the values from "data[,1]" are the fitted values/ yhat values? When I try "fitted(data)" I get different values from "data[,1]", I am very confused.
Write a function in R named counts. This function should take as parameters a numeric vector...
Write a function in R named counts. This function should take as parameters a numeric vector x and also a number indicating a number of bins n. The function will consider the range [min(x),max(x)], and then consider a parti- tion of this interval into n non-overlapping equally sized half open intervals: I1 = [min(x),b1),I2 = [b1,b − 2),...,In = (bn−1,max(x)]. Note that since the intervals are equally sized, the value of bi is constrained. The function will then return a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT