Generating Random Samples - PowerPoint PPT Presentation

About This Presentation
Title:

Generating Random Samples

Description:

Generating Random Samples SAS, EXCEL, JMP, SPSS Population of Data Sample Data should be in a dataset where each row represents an individual unit, and column fields ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 11
Provided by: statUflE
Category:

less

Transcript and Presenter's Notes

Title: Generating Random Samples


1
Generating Random Samples
  • SAS, EXCEL, JMP, SPSS

2
Population of Data ? Sample
  • Data should be in a dataset where each row
    represents an individual unit, and column fields
    represent variables measured on the individual
  • A new column field will be created that contains
    a pseudo-random number generated by statistal
    software package (usually Uniform(0,1) r.v.)
  • Data are sorted by the random number, or simply
    selected for analysis (depending on software)

3
All ATL/HNL 10/2004 Delta Flights (N31)
4
SAS Code to Generate Random Sample (n10)
Data Pop Input Day FlightNum TailNum DestCity
TaxiTime Sched Actual Distance RanxRanuni(seed
) / Put in a number where seed is
/ Cards 1 317 N834MH HNL 29 580 567 4496 31 31
7 N840MH HNL 16 580 576 4496 Proc Sort By
Ranx Data Sample Set Pop If _N_ lt
10 Run / You can run any procedures now on
the Sample /
5
Generating Random Samples in EXCEL
  • In a new column past the data, type in the first
    row containing data on a unit RAND()
  • COPY and PASTE that cell until all N units have a
    random number
  • While that range of N cells is still highlighted,
    click on COPY ? EDIT ? PASTE SPECIAL ? Click on
    VALUES (This changes them from Dynamic to
    Static)
  • Place Cursor in Data Field, Click on DATA ? SORT
    ? Choose Column with Random Values and Choose
    appropriate Header Row Status
  • After data are sorted, COPY and PASTE (SPECIAL
    VALUES) the first n units to a new worksheet

6
Random Numbers (Not Sorted Yet)
7
Data Sorted By Random Number
8
EXCEL Random Sample (n10)
9
Random Samples in JMP
  • Import Data into JMP
  • Click on TABLES ? SUBSET ? RANDOM SAMPLE ? Enter
    Your Sample Size (e.g. 10) in Box
  • Subset Dataset Appears in New Table
  • Analyze the Data in that Table

10
Random Samples in SPSS
  • Import Data into SPSS
  • Older Versions Click Transform ? Random Seed ?
    Enter a numeric seed
  • Newer Versions Click Transform ? Random
    Generators ? Active Generator Initialization ?
    Fixed Value ? Enter a numeric seed
  • Click Data ? Select Cases
  • Under Select, choose Random Sample of Cases.
    Click on Sample box.
  • Choose Exactly n (10) of the first N (31), click
    Continue
  • Click OK. Slashes will appear in the case numbers
    of the cases not in the sample, and an indicator
    variable representing Filter will be attached to
    end of dataset.
  • Analyze the Data
Write a Comment
User Comments (0)
About PowerShow.com