R work (must be done in R)
Copy and paste your R code and output into a word document, along with your written answers to the questions.
Follow these instructions to import the necessary dataset:
Before opening the dataset needed for this problem, you’ll need to call the “car” package. Run the following line of code:
> library(car)
Now you can import the “ States” dataset and use it to answer the question below. Name the data frame with your EID:
> eid <- States
Remember to include any code you use along with your answers in your submission!
3. The “States” dataset contains educational information from all 50 states and Washington D.C. collected in 1992 by the U.S. Census Bureau. Let’s consider that this dataset represents a sample of statewide data over time, and we are interested if there are any differences in the average teacher’s salary (the pay variable, measured in $1,000s) in New England states compared to mountain region states (as defined by the region variable).
Conduct the appropriate analysis to answer this question. Include all steps for full credit.
Here is the test statistic for comparison between two means:
install.packages("car")
library(car)
eid <- States
mtn <- eid[which(eid$region=="MTN"),"pay"]
ne <- eid[which(eid$region=="NE"),"pay"]
n1 <- length(mtn)
n2 <- length(ne)
m.mtn <- mean(mtn)
sd.mtn <- sd(mtn)
m.ne <- mean(ne)
sd.ne <- sd(ne)
Numerator <- m.mtn - m.ne # Difference of Means
Denominator1 <- sd.mtn^2/n1 #var(mtn)/Sample Size
Denominator2 <- sd.ne^2/n2 #var(ne)/Sample Size
Statistic <- Numerator/sqrt(Denominator1 + Denominator2)
#-2.60494
#t-statistic at 5% level of significance, two sided
# df = 8+5 -2 =11
qt(0.025,11) # -2.200985
# Calculated Value is less than tabulated value.
# Hence we can reject our null hypothesis
# Null : Means are equal
# Alternate : Means are different
Get Answers For Free
Most questions answered within 1 hours.