1 / 10

Generating Random Samples

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 represent variables measured on the individual

janine
Download Presentation

Generating Random Samples

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 (N=31)

  4. SAS Code to Generate Random Sample (n=10) Data Pop; Input Day FlightNum TailNum $ DestCity $ TaxiTime Sched Actual Distance; Ranx=Ranuni(seed); /* Put in a number where “seed” is */ Cards; 1 317 N834MH HNL 29 580 567 4496 … 31 317 N840MH HNL 16 580 576 4496 ; Proc Sort; By Ranx; Data Sample; Set Pop; If _N_ <= 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 (n=10)

  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

More Related