Stat 401 A Lab 2

advertisement
Stat 401 A
Lab 2
Note: These notes are lightly adapted from those I used last semester for Stat 301. The JMP
principles are just as valid for 401. The data sets are different. In particular, text saying
‘presented in class’ is probably not correct for 401.
Goals:
Practice using commands in the JMP Analyze / Distribution menu to produce quantitative
summaries of single samples.
Learn how to save JMP graphs or other JMP output in a word processor.
Demonstrate the importance of the Modeling type attribute.
Demonstrate how to read space separated files
Demonstrate how to compute Two-sample t-tests
Lab Activities
1. The first part of this lab will analyze the COD data presented in class. That file is
COD.txt on the 301 web site, http://www.public.iastate.edu/~pdixon/stat301/
Download that file into a convenient folder and use File / Open (change the file type
from “All JMP files” to Text files), select the file, and check “Data, using Text Import
preferences”. The File / Open dialog window should look like:
then left click the open button. A new window should pop open showing the contents
of the COD data set. This has one variable, called COD with 24 values.
If the data was not read properly (the data in the window doesn’t look like what you
expected), reread the using “Data, with preview” the third option for “Open As”.
This gives you the ability to tell JMP exactly how to read the data.
2. The “Modeling Type” of a column is critical to JMP. What JMP does / can do with a
variable depends on the modeling type for the variable. The most common JMP
problems happen when JMP and you disagree about the modeling type. JMP tells you
the modeling type in the “Columns” box (see below). The blue ramp means
quantitative data (continuous in JMP’s lingo). You can also see this by right clicking
on the column, or selecting Cols/Column info from the menu in the data window.
There are two related boxes in the Cols/Column Info dialog box. “Data Type” is
what is contained in the column (numbers, characters) and “Modeling Type” is how
to use that information. Numbers can be quantitative = continuous or qualitative =
nominal; characters can only be nominal (What is the average of A, B, C?).
Make sure COD was read as a continuous variable.
3. Make the JMP home window active, then choose Analyze / Distribution. Select COD
and make it a Y variable by clicking “Y, columns”. Then click OK to do the analysis.
4. The results window (below) shows a histogram next to a “outlier” box plot, a table of
quantiles, and a Summary Statistics box with 6 numbers:
Mean = sample average,
Std Dev = sample standard deviation,
Std Err Mean = standard error of the mean,
Upper and Lower 95% Mean = 95% confidence interval for the mean
N = number of observations
Make sure you know how these numbers are used (see lecture notes or the book).
I haven’t talked about the box plot. I will later. If you want a sneak preview, look at
http://www.jmp.com/academic/pdf/learning/02_box_plots.pdf
5. The 6 summary statistics shown by JMP are the default choice. Many more are
available by clicking the red triangle by Summary Statistics then clicking “Customize
Summary Statistics”. One especially useful choice is at the very bottom of that dialog:
Enter (1-alpha) for mean confidence interval. The default is 0.95 for a 95% confidence
interval. To get a 90% interval, change to 0.90; to get a 99% interval, change to 0.99.
What is the 90% confidence interval for the mean COD?
A: (25.1, 32.2) after rounding
Is this interval shorter or longer than the 95% confidence interval? Why?
6. JMP can do many more calculations and draw many more types of plots for the COD
data. To access these, click the red triangle by COD or right-click on the variable
name (COD). There are three red triangles (by Distributions, by Summary Statistics,
and by COD). You need to click the correct one. A dialog box will pop up looking
like:
This provides another way to get confidence intervals other than the 95% CI.
The Test Mean option provides access to hypothesis tests about the population mean.
7. When I produce a report that presents results from a statistical analysis, I find it easier
to retype numeric results so I include only the results I need in my report. However,
it is convenient to be able to copy graphs or plots from JMP without printing them.
The easiest way is to copy and paste using keyboard shortcut keys. Left click on the
graph, to make it active, then type ctrl-c (hold down the Ctrl key while typing once on
the c key). That copies the graph to the clipboard. Navigate to your Word (or other
word processing) document and type ctrl-v to paste the graph into your report. If you
left click on the graph in Word, you activate the picture menu that allows you to
resize or edit the graph. Here’s a copy and paste of the bar chart of COD values,
using Graph/Chart.
If you click on the window with the Analyze/Distribution results, you can copy the
entire window into Word, then delete the parts you don’t want. Here’s the histogram
and box plot for the COD data, after deleting the other pieces of the output.
If you want to get rid of the box plot, do that before copying the output. Click on the
red triangle by the variable name (COD) and uncheck “Outlier Box Plot”. The box
plot will disappear from the JMP output, so when you copy that output, you don’t get
the box plot.
8. The Modeling type is VERY IMPORTANT to JMP. Remember, the COD values are
numeric (numbers) that should be treated as continuous (quantitative) data. When
you select Analyze/Distribution for a continuous variable, you get the histogram,
quantiles, and numeric statistics (average, standard deviation, …).
Let’s see what happens when the Modeling type is incorrectly set. Go to the window
with the COD data set and find the Columns box (on the left side, middle). There
should be one entry, COD, because there is one variable, called COD, in the COD
data set. (Variable names don’t have to be the same as the data set name; it just
happens to be so for this data set). There is a blue ramp (or triangle) next to the COD
variable name as a visual indication that COD is a quantitative variable. Either select
Cols / Column Info from the window menu or click on the blue ramp by COD.
Change the modeling type from Continuous to Nominal (qualitative variable). The
blue ramp should change to a red bar chart-like visual (see below, left middle):
Now select Analyze/Distribution. The output is now very different: a bar chart and
list of frequencies (see output on next page). And, the options available by
clicking on the red triangle are completely different. The new output and options
are appropriate for qualitative data. They are probably not what you wanted, if you
intended the data to be quantitative.
If JMP doesn’t behave as expected or doesn’t give you the options you expected,
check that the modeling type is correct.
Distributions
COD
Frequencies
Level
11
15
18
22
23
24
25
26
27
28
31
33
39
40
41
44
45
48
Total
N Missing
0
18 Levels
Count
2
1
1
1
2
1
1
2
1
3
2
1
1
1
1
1
1
1
24
Prob
0.08333
0.04167
0.04167
0.04167
0.08333
0.04167
0.04167
0.08333
0.04167
0.12500
0.08333
0.04167
0.04167
0.04167
0.04167
0.04167
0.04167
0.04167
1.00000
The last part of this lab uses the mousewt.txt data file from the datasets page on the class web
site.
9. Use File / Open / Text import preferences (the default) to read the file.
10. JMP displays the data file, as it read it. If your browser and copy of JMP work like mine, you
will notice a problem. The first few lines of data look like:
JMP read the file as containing one variable (i.e., one column of information).
There should be two columns of data: tg with 0 (indicating wild type mouse) or 1 (indicating
successful insert of the piece of human chromosome 21) and weight with the mouse adult
weight, in grams. Instead, JMP thought there was one variable with both pieces of
information. Worse, JMP thinks that variable is a qualitative variable. (Ask, if you don’t know
why I know JMP thinks it’s qualitative).
11. The solution is to help JMP read the file properly. Close the mousewt window, And tell JMP
to open the file again. This time, select the file, then click on the ‘Text, with preview’ button
before clicking ok. A preview window will open that gives you control of how to read the file.
You can change the character(s) that separate fields on a line (i.e. separate tg from weight),
the characters that mark the end of the line, and other things. A preview of the result
appears in the top of the preview window (see next page). The vertical line separates fields
that JMP will consider separate variables. In this case, the options in the preview window are
sufficient to read each line as two fields. If you unclick the “Space” box in the end of field
choices, you see that the vertical line disappears – JMP is now reading both variables as one
field. Make sure that “Space” is active, so JMP will read two variables, then click Next.
The next dialog provides options to change how each variable is read. In this case, we want tg to
be a qualitative variable (identifying groups). The little graphic to the left of the red triangle by tg
changes this. Click on that box twice. The first time, the box changes to an “excluded” symbol.
The second time, the box changes to another box with red bars in it. (A third click will cycle back to
a box with a blue ramp).
Remember from last week:
blue ramp is a quantitative variable; red bars are a qualitative variable.
We want tg to be a qualitative variable and weight to be a quantitative variable.
When satisfied, click Import.
Note: If this step is too confusing, ignore it and change the data type later (see next point). The
crucial part of step 4 is to read two fields: tg and weight.
12. You should see a new data table with two variables (i.e., two columns). tg is a red bars
column; weight is a blue ramp column (see next page).
If you did not change tg to a qualitative variable before (in step 4), then change it now. Either
right click on tg in the columns box and change the data type to nominal (qualitative) or choose
Cols / Column Info from the top menu bar and change the tg column to nominal.
13. To get descriptive plots and summary statistics for each group of mice separately, choose
Analyze/Distribution from the main menu. Put weight into the Y, Columns box and tg into the
By box. The dialog window should look like:
Then click OK. You will get a histogram, quantiles, and summary statistics just like last week,
except now there is a block for observations with tg=0 (wild type mice) and block for observations
with tg=1 (transgenic mice).
14. To calculate an equal variance t-test, choose Analyze/Fit Y by X from the main menu. Put
weight into the Y, columns box and tg into the X, factor box. The dialog should look like:
Then click OK.
15. You will get a dot plot of the response variable (Y, weight) for each level of tg:
This works for any qualitative variable as the X, factor variable. It would work just as well if the
two levels of tg were “WT” and “TG”
16. All the interesting stuff is obtained by clicking on the red triangle. The menu looks like:
We need to know about the first four items (for now)
17. Quantiles: reports various quantiles and adds simple box plots to the graph. If you want the
dots marking each point to disappear, the way I know to do that is to right-click on the graph,
select transparency, then put 0 in the box. (Aside: since the dots overlap, setting
transparency to 0.1 or 0.2 does nice things to the plot. Try and see).
18. Means / Anova / Pooled t: This does the equal variance t-test. Look at the box labelled t Test.
Ask if you can’t figure out how any of the results are labelled.
19.
The one non-obvious number that you might want is the pooled standard deviation. That is
labeled “Root Mean Square Error” in the first box (Summary of Fit).
20. Means and Std Dev: Adds a box with sample statistics for each group, and 95% confidence
intervals for each mean. The confidence level can be changed using the ‘Set alpha level’
option (12’th in the list).
21. t Test: Does the unequal variance t-test. Notice that the DF are not an integer. This is the
approximation mentioned in lecture.
Download