This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up**This preview shows
pages
1–2. Sign up
to
view the full content.*

# The following will illustrate some of the concepts we introduced during last
# week.
# 1) Let's get a feeling of what a Normal qqplot looks like for
# different kinds of distributions. Recall, that if the data comes from a
# Normal distribution, then it's qqplot should look line a straight line,
# at least in the bulk of the plot; the tails usually deviate from a straight
# line, because there are usually few cases there anyway. This
# is a visual method for checking whether your data is normally distributed.
# Also, if linear, then the intercept and slope of the line can be used as
# estimates of the mu and sigma of the normal distribution.
# The answers you get on your screen may look different from what your TA
# shows on screen, but that's because of the different random samples.
x = rnorm(500,0,1)
# Sample of size 500 from a normal dist with mu=0, sigma=1.
hist(x)
qqnorm(x)
x = rexp(500,1)
# Sample of size 500 from an exponential dist with lambda=1.
hist(x)
# Use UP-ARROW
qqnorm(x)
# So, as you can see, that a normal sample will produce a linear pattern
# in qqnorm(), but an exponential sample will not. Clearly, that's
# because qqnorm() checks the data against a normal distribution.
# But how do we identify if some data comes from some other distribution,
# say, from the exponential distribution? Answer: use analog of qqnorm
# for the exponential distribution. In R, the function qqmath() allows
# for a large number of theoretical distributions.
# Let me just show you that it succeeds in identifying the above exponential
# data as being from an exponential distribution?
library(lattice)
# This is the library that contains qqmath().
x = rexp(500,1)
hist(x)
qqmath(x, dist = qexp)
############################################################################
# 2) Scatterplots:
# Let's pick a 100 random x values, and corresponding y values that have
# some linear association with x. We'll change the amount of linear association
# by adding different amounts of noise to y. Look:
# Cut/paste the following 2 blocks from

This
** preview**
has intentionally

This is the end of the preview. Sign up
to
access the rest of the document.

Ask a homework question
- tutors are online