Research breakthrough possible @S-Logix pro@slogix.in

Office Address

Social List

How to find goodness of fit using Chi-Squared Test in R?

Description

To find the goodness of fit using Chi-Squared Test in R programming.

Process

chi-quare goodness of fit:

   To compare the observed distribution to an expected distribution Can onlybe used on discrete data.

   Null hypothesis(H0): There is no significant difference between the observed and the expected value.

  Alternative hypothesis(H1): There is a significant difference between the observed and the expected value.

Sapmle Code

#Finding Goodness of fit using Chisquared test

#Example 1
#Input vector and Expected Probability
vect<-c(5,10,15)
prob<-c(0.2,0.4,0.4)

#Sum of Probability should be 1
sum(prob)

#Chisquared test
chisq.test(x=vect,p=prob)

#Example 2
#Input
vect_1<-c(15,10,5)
prob_1<-c(0.2,0.4,0.4)

#Sum of Probability should be 1
sum(prob_1)

#Chisquared test
chisq.test(x=vect_1,p=prob_1)

Screenshots
find goodness of fit using Chi-Squared Test in R