Assumption of Z-test

  • samples are randomly selected from the population
  • Population is normally distributed
  • population variance is known

Assumption of T-test

  • samples are randomly selected from the population
  • population is normally distributed
  • populations variance is unknown
  • sample data are continuous

Z-test VS T-test

  • Z test can be only apply when the population variance is known and sample size is 30 or more than 30, and Z-test is used in one population sampling
  • T – test only be used population variance is unknown and the sample size is less than 30 and T – test can be used in one population sampling(one sample t- test)and two population sampling. (independent and paired sample t -test)

Independent VS dependent (paired) sample t-test

  • independent sample T-test compare variable between two unrelated groups (e.g. – age of the male and female)
  • dependent sample T-test compare variable between two related groups ( e.g – body weight before and after the exercise)

Z – test in R

install.packages("TeachingDemos") 
library(TeachingDemos)
z.test(x, mu = 0, stdev, alternative = c("two.sided", "less", "greater"),
  sd = stdev, n=length(x), conf.level = 0.95)
  • x = data values
  • mu = hypothesized mean
  • stdev = standard deviation
  • alternative = alternative hypothesis
  • conf.level = level of the confident
  • n = sample size

T – test in R

1. one sample T -test

install.packages("TeachingDemos") 
library(TeachingDemos)
t.test(x, mu, alternative, conf.level, var.equal=TRUE)

  • var.equal = the assumption than variable is equal or not

2. Paired (dependent sample t -test)

t.test(x, y, alternative, conf.level, paired = TRUE, var.equal=TRUE)

3. Independent sample T-test

t.test(x, y, alternative, conf.level, paired = FALSE, var.equal=TRUE)
  • x = vector of the data values of 1st sample
  • y = vector of the data values of 2nd sample
  • paired = if samples are dependent or independent

Leave a Reply

Your email address will not be published.