Hypothesis Testing using R - OneTailTest


METHODS FOR HYPOTHESIS TESTING
  • z-Test
    • Used when Sample Size is Large
    • Used for single Population or single Sample
    • Used for Proportion
  • t-Test
    • Used when Sample Size is small
    • Used when Standard Deviation of the population is not known
    • Types:
      • One Sample 
      • Two Sample
      • Paired t Test
  • Chi-Square-Test
One Sample t-Test Example
A typical American mean mobile internet usage is 144 minutes. You select a sample size of 30.
  • Is there a evidence that the population mean time spent accessing the internet via mobile is different than 144 minutes? Use P-Value approach and level of significance of 0.05
The mobile internet usage is given as below:
Minutes
72
144
48
72
36
360
44
30
432
24
288
144
144
240
432
144
144
144
576
216
72
72
144
288
144
36
288
48
288
144

Load this data to some file and read it into R variable mydata

attach(mydata)

#Hypothesis testing => H0: Mu = 144, Ha: Mu < 144
#Sample Mean
Xbar = mean(Minutes); Xbar
#Sample Standard Deviation
Sigma = sd(Minutes); Sigma

#Population Mean
Mu = 144; Mu 
#Sample Size
n = 30; n

#Degrees of Freedom
dF = n - 1; dF

#Function sqrt or  ^0.5 i.e. to power 0.5 
tval = (Xbar - Mu)/(Sigma/sqrt(n)); tval

#P-Value 
Pval = pt(tval, dF); Pval

OUTPUT


CONCLUSION
Since, P-value = 0.885 or 88.5% > Alpha = 0.05 or 5%, we do not reject the NULL hypothesis i.e. Average time spent is 144 minutes

NOTE:

  • 1 - P-value => This is the lowest value for a One-Tail test. Excel function - T.DIST
  • (1 - P-value) * 2 => This is the lowest value for a Two-Tail test. Excel function - T.DIST.2T
REFERENCES



Comments