# The Normal Distribution # # In the tutorial we learned how to convert raw scores to z-scores # and back again. For example, given a normal distribution with mean 70 # and standard deviation of 10, the z-score for a raw score of 80 is: z <- (80-70)/10 print(z) # We can define variables 'mu' and 'sigma' to make this more general: mu <- 70 sigma <- 10 # and define X to be the raw score: X <- 80 z <- (X-mu)/sigma print(z) # To find the area above this score, we can use 'pnorm': 1-pnorm(z) # In R there's a shortcut. 'pnorm' (and qnorm) allow you to send in # means and standard deviations instead of using the default 0 and 1. # This will give you the same answer: 1-pnorm(80,70,10) # or, equivalently: 1-pnorm(X,mu,sigma) # Here are a couple more examples: # The proportion of raw scores that fall below 55 is: pnorm(55,mu,sigma) # The proportion of raw scores that fall above 90 is: 1-pnorm(90,mu,sigma) # Converting areas to scores is just as easy. For example, for the # normal distribution with mean 70 and standard deviation 10, we # can calculate the score for which 5% lies above by first finding # the z-score using qnorm: z <- qnorm(1-.05) print(z) # And then convert to raw scores using our formula: X <- z*sigma + mu print(X) # As with pnorm, there's a shortcut by giving qnorm the mean and # standard deviation instead of the default 0 and 1. This should # give us the same answer: qnorm(1-.05,mu,sigma) # The scores that bracket the middle 95% can be found similarly. The # lower score is: qnorm(.05/2,mu,sigma) # and the upper score is: qnorm(1-.05/2,mu,sigma) # We can concatenate these into a single vector: c(qnorm(.05/2,mu,sigma),qnorm(1-.05/2,mu,sigma))