© All Rights Reserved

0 views

© All Rights Reserved

- Hypothesis testing in one sample
- 6. Significance tests.ppt
- Czech Study
- Bluman 5th_Chapter 8 HW Soln for My Class
- Testing of Hypothesis
- Hypothesis Testing
- Design of Experiments.pdf
- Stats 250 W17 Exam 2 for Practice
- 52.Format. Hum - A Study of Awareness and Use of Technology
- Hypothesis Testing
- The Effects of Instructional Materials on Students’ Performance in English Language at Senior Secondary Schools in Katagum Zone, Bauchi State, Nigeria.
- Math 12 Practice Exam-3 (F2010) - Comprehensive Review
- JAMA subgroup analyses 1 2014.pdf
- HOMW Chap8&9Fall2009
- Exam2 Practice Solutions
- Ultimate Guide to Ab Testing
- IE005 Lab Exercise 1 and 2mn
- A COMPARATIVE STUDY OF PERSONAL, PROFESSIONAL AND SOCIAL ADJUSTMENT OF TEACHERS WORKING IN GOVERNMENT AND PRIVATE SECONDARY SCHOOLS
- 95%Cis Primer
- Guilford, J. P. (1948). Factor Analysis in a Test-Development Program. Psychological Review, 55(2), 79-94

You are on page 1of 5

directory

set.seed(12051984) #this randomly sets a seed

xbar_1 <- 82 #sample mean of sample one

xbar_2 <- 78 #sample mean of sample two

d0 <- 0 #assumption

sigma_1 <- 10 #population standard deviation of population one

sigma_2 <- 10 #population standard deviation of population two

n_1 <- 30 #sample size of sample one

n_2 <- 40 #sample size of sample two

se <- sqrt(((sigma_1^2)/n_1) + ((sigma_2^2)/n_2)) #standard error

z <- ((xbar_1-xbar_2)-d0)/se #calculates Z

#calculate 90% critical values using R

alpha_10 <- .10 #this is alpha at 90%

z_half_alpha_10 <- qnorm(1-(alpha_10/2)) #finds positive z sub alpha over two

cv_10 <- c(-z_half_alpha_10, z_half_alpha_10) #saves the negative and positive critical values in a vector

#calculate 95% critical values using R

alpha_05 <- .05 #this is alpha at 95%

z_half_alpha_05 <- qnorm(1-(alpha_05/2)) #finds positive z sub alpha over two

cv_05 <- c(-z_half_alpha_05, z_half_alpha_05) #saves the negative and positive critical values in a vector

#calculate 99% critical values using R

alpha_01 <- .01 #this is alpha at 99%

z_half_alpha_01 <- qnorm(1-(alpha_01/2)) #finds positive z sub alpha over two

cv_01 <- c(-z_half_alpha_01, z_half_alpha_01) #saves the negative and positive critical values in a vector

#calculate the margin of error at 90%

moe_90 <- z_half_alpha_10 * se #calculate margin of error

CI_90 <- (xbar_1 - xbar_2) + c(-moe_90, moe_90) #finds confidence interval

CI_90_est <- print(paste("We are 90% sure that the difference between the population means is

between", CI_90[1], "and", CI_90[2])) #prints the confidence interval in a sentence

CI_result_90 <- if(d0 <= CI_90[1] | d0 >= CI_90[2]){

print("We are 90% sure that we reject the null hypothesis and accept the alternative hypothesis")

} else {

print("We fail to reject the null hypothesis")

}# conducts the hypothesis test

#calculate the margin of error at 95%

moe_95 <- z_half_alpha_05 * se #calculate margin of error

CI_95 <- (xbar_1 - xbar_2) + c(-moe_95, moe_95) #finds confidence interval

CI_95_est <- print(paste("We are 95% sure that the difference between the population means is

between", CI_95[1], "and", CI_95[2])) #prints the confidence interval in a sentence

CI_result_95 <- if(d0 <= CI_95[1] | d0 >= CI_95[2]){

print("We are 95% sure that we reject the null hypothesis and accept the alternative hypothesis")

} else {

print("We fail to reject the null hypothesis")

}# conducts the hypothesis test

#calculate the margin of error at 99%

moe_99 <- z_half_alpha_01 * se #calculate margin of error

CI_99 <- (xbar_1 - xbar_2) + c(-moe_99, moe_99) #finds confidence interval

CI_99_est <- print(paste("We are 99% sure that the difference between the population means is

between", CI_99[1], "and", CI_99[2])) #prints the confidence interval in a sentence

CI_result_99 <- if(d0 <= CI_99[1] | d0 >= CI_99[2]){

print("We are 99% sure that we reject the null hypothesis and accept the alternative hypothesis")

} else {

print("We fail to reject the null hypothesis")

}# conducts the hypothesis test

print(paste(CI_99_est,CI_result_99))

#CONDUCT HYPOTHESIS TEST AT 90% (CRITICAL VALUE)

cv_result_90 <- if(z <= -z_half_alpha_10 | z >= z_half_alpha_10){

print("We are 90% sure that we reject the null hypothesis and accept the alternative hypothesis")

} else {

print("We fail to reject the null hypothesis")

}

#CONDUCT HYPOTHESIS TEST AT 95% (CRITICAL VALUE)

cv_result_95 <- if(z <= -z_half_alpha_05 | z >= z_half_alpha_05){

print("We are 95% sure that we reject the null hypothesis and accept the alternative hypothesis")

} else {

print("We fail to reject the null hypothesis")

}

#CONDUCT HYPOTHESIS TEST AT 99% (CRITICAL VALUE)

cv_result_99 <- if(z <= -z_half_alpha_01 | z >= z_half_alpha_01){

print("We are 99% sure that we reject the null hypothesis and accept the alternative hypothesis")

} else {

print("We fail to reject the null hypothesis")

}

pval <- 2 * pnorm(-abs(z))

pval

#CONDUCT HYPOTHESIS TEST AT 90% (p-value)

pval_result_90 <- if(pval <= alpha_10){

print("We are 90% sure that we reject the null hypothesis and accept the alternative hypothesis")

} else {

print("We fail to reject the null hypothesis")

}

#CONDUCT HYPOTHESIS TEST AT 95% (p-value)

pval_result_95 <- if(pval <= alpha_05){

print("We are 95% sure that we reject the null hypothesis and accept the alternative hypothesis")

} else {

print("We fail to reject the null hypothesis")

}

#CONDUCT HYPOTHESIS TEST AT 99% (p-value)

pval_result_99 <- if(pval <= alpha_01){

print("We are 99% sure that we reject the null hypothesis and accept the alternative hypothesis")

} else {

print("We fail to reject the null hypothesis")

}

rm(list=ls()) #this clears the global environment

setwd("/Users/matthewlehnert/Documents/AUI/Quantitative Methods Code") #this sets the working

directory

set.seed(12051984) #this randomly sets a seed

xbar <- 23.89 #sample mean

mu0 <- 24.57 #assumption

sigma <- 2.4 #population standard deviation

n <- 30 #sample size

se <- sigma/sqrt(n) #standard error

z <- (xbar-mu0)/se

#calculate 90% critical values using R

alpha_10 <- .10 #this is alpha at 90%

z_half_alpha_10 <- qnorm(1-(alpha_10/2)) #finds positive z sub alpha over two

cv_10 <- c(-z_half_alpha_10, z_half_alpha_10) #saves the negative and positive critical values in a vector

#calculate 95% critical values using R

alpha_05 <- .05 #this is alpha at 95%

z_half_alpha_05 <- qnorm(1-(alpha_05/2)) #finds positive z sub alpha over two

cv_05 <- c(-z_half_alpha_05, z_half_alpha_05) #saves the negative and positive critical values in a vector

#calculate 99% critical values using R

alpha_01 <- .01 #this is alpha at 99%

z_half_alpha_01 <- qnorm(1-(alpha_01/2)) #finds positive z sub alpha over two

cv_01 <- c(-z_half_alpha_01, z_half_alpha_01) #saves the negative and positive critical values in a vector

#calculate the margin of error at 90%

moe_90 <- z_half_alpha_10 * se #calculate margin of error

CI_90 <- xbar + c(-moe_90, moe_90) #finds confidence interval

CI_90_est <- print(paste("We are 90% sure that the population mean is between", CI_90[1], "and",

CI_90[2])) #prints the confidence interval in a sentence

CI_result_90 <- if(mu0 <= CI_90[1] | mu0 >= CI_90[2]){

print("We are 90% sure that we reject the null hypothesis and accept the alternative hypothesis")

} else {

print("We fail to reject the null hypothesis")

}# conducts the hypothesis test

moe_95 <- z_half_alpha_05 * se #calculate margin of error

CI_95 <- xbar + c(-moe_95, moe_95) #finds confidence interval

CI_95_est <- print(paste("We are 95% sure that the population mean is between", CI_95[1], "and",

CI_95[2])) #prints the confidence interval in a sentence

CI_result_95 <- if(mu0 <= CI_95[1] | mu0 >= CI_95[2]){

print("We are 95% sure that we reject the null hypothesis and accept the alternative hypothesis")

} else {

print("We fail to reject the null hypothesis")

}# conducts the hypothesis test

moe_99 <- z_half_alpha_01 * se #calculate margin of error

CI_99 <- xbar + c(-moe_99, moe_99) #finds confidence interval

CI_99_est <- print(paste("We are 99% sure that the population mean is between", CI_99[1], "and",

CI_99[2])) #prints the confidence interval in a sentence

CI_result_99 <- if(mu0 <= CI_99[1] | mu0 >= CI_99[2]){

print("We are 99% sure that we reject the null hypothesis and accept the alternative hypothesis")

} else {

print("We fail to reject the null hypothesis")

}# conducts the hypothesis test

print(paste(CI_99_est,CI_result_99))

- Hypothesis testing in one sampleUploaded byAnastasia
- 6. Significance tests.pptUploaded byTruong Giang Vo
- Czech StudyUploaded byAndreea Andrusca
- Bluman 5th_Chapter 8 HW Soln for My ClassUploaded bybill power
- Testing of HypothesisUploaded bysaketrama
- Hypothesis TestingUploaded byAnastasia
- Design of Experiments.pdfUploaded byandresjyp
- Stats 250 W17 Exam 2 for PracticeUploaded byAnonymous pUJNdQ
- 52.Format. Hum - A Study of Awareness and Use of TechnologyUploaded byImpact Journals
- Hypothesis TestingUploaded byMicaiah Das
- The Effects of Instructional Materials on Students’ Performance in English Language at Senior Secondary Schools in Katagum Zone, Bauchi State, Nigeria.Uploaded byAJHSSR Journal
- Math 12 Practice Exam-3 (F2010) - Comprehensive ReviewUploaded byMarcos Magana
- JAMA subgroup analyses 1 2014.pdfUploaded byAnonymous b2k9ABe7e
- HOMW Chap8&9Fall2009Uploaded byKawtar Aallam
- Exam2 Practice SolutionsUploaded byMack Coleman Dowdall
- Ultimate Guide to Ab TestingUploaded byalexproducts5674
- IE005 Lab Exercise 1 and 2mnUploaded byApril Dawates
- A COMPARATIVE STUDY OF PERSONAL, PROFESSIONAL AND SOCIAL ADJUSTMENT OF TEACHERS WORKING IN GOVERNMENT AND PRIVATE SECONDARY SCHOOLSUploaded byAnonymous CwJeBCAXp
- 95%Cis PrimerUploaded byjimij_1
- Guilford, J. P. (1948). Factor Analysis in a Test-Development Program. Psychological Review, 55(2), 79-94Uploaded byAcatalepso
- Hypothesis TestingUploaded byGabriel Nagy
- IJMS_Vol_2_Iss_4_Paper_2_384_388.pdfUploaded byNishant Jha
- R Notebook - PrimerUploaded byAleksandar Tomašević
- REPORT _an_Uploaded byroetjieke
- t-dist CI wkshtUploaded byRolly L. Sagario
- Hypothesis TestingUploaded byfarhaj
- week2-1lectureUploaded byapi-359248071
- The Effect of Edmodo on Students Writing Skill InUploaded byaisyah ai aisyah
- Torre2018_Spatial and Orientation Patterns of Experimental Stone Tool RefitsUploaded bySári Gábriel
- Hypothesis Testing Intro 2Uploaded bySigei Leonard

- Report Mission to Kazakhstan, April 2018Uploaded byKatarzyna Chimiak
- HmsUploaded byRiya Sharma
- CHAPTER 5 - polstra.docxUploaded bykyra inarsolin
- Exxon Valdez - Most Expensive Oil Spill (Marèe noire)Uploaded byCfonsecaCAM
- PMP 3 ManualUploaded bydonjuanjr
- The Power of NutritionUploaded byTom McSorley
- Life ProphetUploaded byfaisal_SAP
- 06 an Overview on the Global Presence of Filipinos - Prof. Mary Lou L. AlcidUploaded byJ. O. M. Salazar
- The Electron Transport Chain StepsUploaded byalokesh1982
- Antimicrobial Resistance, Problem Pathogens and Clinical CountermeasuresUploaded byPutri Amirah
- Alati - Cgstools - End Mill Speeds CarbideUploaded byDejan Babic
- Pipeline GuidelinesUploaded bysidrana7
- Engine - Wikipedia, The Free EncyclopediaUploaded byJohn
- 3D ULTRASONOGRAPHY DAIGNOSIS OF POLYPOID GALL BLADDER IN DOG.Uploaded byIJAR Journal
- WHAM Nuclear Power SupplementUploaded byAffNeg.Com
- TM-9-2320-360-20-2; HET 1070Uploaded byDeen-Paul Zoto
- The Impact of Motivational Policies of Employee PerformanceUploaded byIPROJECCT
- NIOS SSC SCIENCE LESSON Chapter 10Uploaded bykodatic
- scalarUploaded byZain Saleem
- JNS UP - Broken WheelsUploaded bysalih havak
- Exam QuestionsUploaded bypierrette1
- 2005 Road Design Standards Rural Roads FinalUploaded byOGSAJIB
- ADPROUploaded byHanniyaMirza
- Difference between Vacuum Circuit Breaker & Vacuum ContactorUploaded byMohan K
- SAMSUNG Bottom Mount Refrigerator RB2155SH:XAA Manual.pdfUploaded bysgross2130
- CATIA V5 Mechanical Designer AdvancedUploaded bysadham hussain
- CA Weekly Pocket PDF 2018 - March(16-21) by ACUploaded bymehak chadha
- Agri ScienceUploaded byrizwan900
- Plastics GuidebookUploaded byjroyal692974
- 01 Lewabrane Manual Reverse Osmosis 05Uploaded byratgeneral