R language Access Menu

Type of distributions

Most classical statistical tests assume that the data is normally distributed, ie its histogram or density curve is bell shaped with peak at center. 

code: 

> hist(bwdf$age)

output (graph): 

 

               

code: 

          > plot(density(bwdf$age))

output (graph): 

               

Following function plots 4 graphs which indicate whether the data is normally distributed or not: 

code:

> myqq = function(vect) {
             par(mfrow=c(2,2))
             qqnorm(vect); qqline(vect)
             plot(ecdf(vect), main = 'Cumulative Distribution Curve\n(sigmoid shape means normal distribution)')
 # cumulative distribution; 
            hist(vect)
            plot(density(vect))
}
 > myqq(birthwt$age)

output (graph): 

              
 
 


    Comments & Feedback