Re: Bootstrap sampling

From: Nick Holford Date: January 08, 1998 technical Source: cognigencorp.com
From: Nick Holford <n.holford@auckland.ac.nz> Subject: Re: Bootstrap sampling Date: 8 Jan 1998 16:22:34 -0500 > > I have a dataset for 49 individuals and want to perform bootstrap > > sampling of 35 individuals (with replacement) to obtain 300 sample data > > sets. Is there any way to get NONMEM to automate this process - or do I > > have to somehow generate the samples and then use a batch file to > > process each file with NONMEM? > > > > If the latter is the case, does anybody know of any simple program which > > will read a file of random numbers (I have generated 300 sets of 35 IDs > > out of the 49 individuals, using Excel 'sample' routine) 35 at a time > > and then use these to extract records for individuals with matching IDs > > into a sample data file----and then repeat the procedure 300 times? The following awk script may help you to create the data files. If you embed a call to awk followed by a call to invoke nonmem and loop over the records in your id data file you should be able complete your bootstrap. I have only tested it in a limited fashion. Let me know if you need a copy of awk (for DOS). It is small (47k) and public domain. #boot # assume each set of IDs are in a record in a file called id.dat delimited with # spaces e.g. # 25 18 7 11 33 ... # 8 10 17 1 22 ... # assume original NONMEM input data file with ID in col 1 called nm.dat # # select record from id.dat to use by setting IDROW= to record number #Usage: # awk -f boot.awk -v DATA=nm.dat -v IDROW=1 id.dat BEGIN { IDCOL=1 # col number for ID in nm.dat DELIM=" " # field delimiter in nm.dat n=0 # counter to name each new NONMEM output file } NR==IDROW { NMOUT="nmsamp.dat" print "# IDs="$0 > NMOUT ok=getline datrec < DATA do { split(datrec,data,DELIM) id=data[IDCOL] for ( i=1; i <= NF ; i++ ) { if ( id == $i ) { do { print datrec >> NMOUT ok=getline datrec < DATA split(datrec,data,DELIM) id=data[IDCOL] } while ( id == $i && ok > 0 ) i = NF*2 # force exit from for loop } } if ( i == NF+1 ) ok=getline datrec < DATA } while ( ok > 0 ) close(DATA) close(NMOUT) } -- Nick Holford, Dept Pharmacology & Clinical Pharmacology University of Auckland, Private Bag 92019, Auckland, New Zealand email:n.holford@auckland.ac.nz tel:+64(9)373-7599x6730 fax:373-7556 http://www.phm.auckland.ac.nz/Staff/NHolford/nholford.htm
Jan 08, 1998 John Parke Bootstrap sampling
Jan 08, 1998 Pascal Girard Re: Bootstrap sampling
Jan 08, 1998 Nick Holford Re: Bootstrap sampling