CHAPTER 3 AppendixSimple Random Samples with Excel, JMP, Minitab, SPSS, CrunchIt!, R, and TI-83/-84 Calculators

TA3-1

Simple Random Samples

image

  1. Assign a numerical label in the form of an integer to each population element. For example, as suggested with Example 3.5 in the text, we would assign the numbers 1–30 to the 30 population elements. These numerical labels should be put in a column in the spreadsheet.
  2. Select “Sampling” in the “Data Analysis” menu box and click “OK.”
  3. Enter the cell range of the numerical labels into the “Input Range” box.
  4. Choose the “Random” option and input the number of random selections you wish Excel to make.

    Note: Repeated selections are possible, so it is advisable that you generate several more random numbers than the sample size.

  5. Click “OK” and find the random numbers outputted to a new worksheet.

    Note: If you wish to sort the random numbers, you should first highlight the cells to be sorted and then click the “Sort & Filter” option, found under the “Home” tab. You can now pick the option to have the numbers sorted from smallest to largest.

image

  1. Tables ➔ Subset
  2. Select “Random—sampling rate” or “Random—sample size.”
  3. Under “Columns,” choose to keep all columns or only the selected columns.
  4. Click “OK.”

image

  1. Calc ➔ Random Data ➔ Sample from Columns
  2. In “From Columns,” click in the column from which you wish to sample.
  3. In “Store Samples in,” type in a new column or select an existing column to replace.
  4. Click “OK.”

image

  1. Data ➔ Select Cases
  2. Under “Select,” pick “Random sample of cases.”
  3. Click “Sample” and specify percent or number of cases to sample, then click “Continue.”
  4. Under “Output,” select selection option (usually “Copy selected cases to a new dataset”).

TA3-2

image

CrunchIt does not formally support random sampling, but a random sample (without replacement) can be obtained by creating a column of random values to allow the selection of only those rows with values matching a particular value.

  1. Insert ➔ Random Numbers ➔ Binomial
  2. Enter 1 for n (this means values will be between 0 and 1).
  3. For p, enter the proportion of data you wish to sample; for instance, 0.50.
  4. For samples, enter the number of rows available, or a value smaller if you wish to sample from only the first number of rows specified.
  5. Click “Sample.”

A new variable will be created with values of 0 and 1—to use this variable to form a selection:

  1. Click “Filtering, Exclude.”
  2. In the “where” section, select the newly created variable.
  3. In the final section, enter “0.”
  4. Click “OK.”

Rows not matching this criterion will be excluded from analysis.

image

TI calculators do not perform random sampling, but they can generate a random list of numbers to use in selecting a sample.

  1. Press for the Statistics list editor. Select an empty list, or clear one.
  2. Press image to highlight the list name. In the input area at the bottom of the screen, you should see something like
  3. Press image to PRB. Then select option
  4. Enter the minimum desired value, the maximum, and the number of values to generate. Ask for a few more than you need, because duplicates may occur. A finished command should look like (to generate five numbers between 1 and 33, inclusive)

    L1=randInt(1,33,5)

image

Use sample() to take a random sample of size from a data set. An example of this command is shown and selects a sample of size from data set named “mydata” into a subset named “mysamp:”

> mysamp=mydata[sample(1:nrow(mydata),15,replace=F),]