(************** Content-type: application/mathematica ************** Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 48576, 1633]*) (*NotebookOutlinePosition[ 51982, 1727]*) (* CellTagsIndexPosition[ 51205, 1705]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Confidence intervals by bootstrap", "Title"], Cell["\<\ This package demonstrates how to calculate bootstrap confidence \ intervals (BCa and extreme percentile) for univariate continuous data.\ \>", \ "Text"], Cell[TextData[{ "Author: Sergej V. Aksenov\n\nDepartment of Microbiology and Immunology\n\ University of Michigan\nAnn Arbor, MI 48109, USA\n", ButtonBox["aksenov@mac.com", ButtonData:>{ URL[ "mailto:aksenov@mac.com"], None}, ButtonStyle->"Hyperlink"] }], "Text"], Cell["Last updated 29 April 2002", "Text"], Cell[CellGroupData[{ Cell["Installation and initialization", "Section", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ "The package file ", StyleBox["Bootstrap.m", "Input"], " should be located inside the ", StyleBox["Bootstrap", "Input"], " directory. \nThe ", StyleBox["Bootstrap", "Input"], " directory should be put in one of the canonical places for AddOns. \n\ Two recommended places are first inside the ", StyleBox["Mathematica", FontSlant->"Italic"], " distribution in:" }], "Text"], Cell[BoxData[ \(ToFileName[\ {$TopDirectory, \ "\", \ "\"}]\)], \ "Input"], Cell["a second in the preferences directory:", "Text"], Cell[BoxData[ \(ToFileName[\ {$PreferencesDirectory, \ "\", \ \ "\"}]\)], "Input"], Cell[TextData[{ "When one of these locations is used there is no need to set ", StyleBox["$Path", "Input"], " and the loading instructions are identical for all versions of ", StyleBox["Mathematica", FontSlant->"Italic"], "." }], "Text"], Cell[TextData[{ StyleBox["Important note:", FontWeight->"Bold"], " \n\nthis package requires package ", StyleBox["RootSearch", "Input"], " by Ted Ersek to be installed in its default location: create directory ", StyleBox["Enhancements", "Input"], " in one of the above canonical locations and put file ", StyleBox["RootSearch.m", "Input"], " there. \nPlease download ", StyleBox["RootSearch.m", "Input"], " from ", StyleBox["MathSource", FontSlant->"Italic"], " at\n ", ButtonBox["http://www.mathsource.com/cgi-bin/msitem?0211-734", ButtonData:>{ URL[ "http://www.mathsource.com/cgi-bin/msitem?0211-734"], None}, ButtonStyle->"Hyperlink"] }], "Text"], Cell[TextData[{ "The ", StyleBox["Bootstrap` ", "Input"], "package can be loaded with" }], "Text"], Cell["<True] }, Open ]], Cell[CellGroupData[{ Cell["Introduction", "Section"], Cell[TextData[{ "Suppose that we have data ", Cell[BoxData[ \(TraditionalForm\`\(\(F\)\(\[RightArrow]\)\)\)]], Cell[BoxData[ \(TraditionalForm\`x\)]], "=", Cell[BoxData[ \(TraditionalForm\`\((x\_1, \[Ellipsis], x\_n)\)\)]], " that are obtained by random sampling from an unknown distribution. \ Suppose further that there is a parameter \[Theta]=", StyleBox["t", FontSlant->"Italic"], "(", StyleBox["F", FontSlant->"Italic"], ") that we are interested in estimating. A point estimate of this \ parameter is obtained by using e.g. empirical distribution function based on \ data, ", Cell[BoxData[ FormBox[ RowBox[{\(\[Theta]\&^\), "=", RowBox[{ RowBox[{ StyleBox["t", FontSlant->"Italic"], StyleBox["(", FontSlant->"Plain"], \(F\&^\), ")"}], "."}]}], TraditionalForm]]] }], "Text"], Cell[TextData[{ "A point estimate is usually supplemented by a confidence interval ", Cell[BoxData[ \(TraditionalForm\`I = \((\(\(\[Theta]\_lo\)\&^\), \ \(\(\[Theta]\_up\)\&^\))\)\)]], " with approximate coverage 1-2\[Alpha] that is saying that the probability \ of finding the true value of the parameter inside this interval is exactly \ 1-2\[Alpha]. This can be equivalently formulated as Prob", Cell[BoxData[ \(TraditionalForm\`{\[Theta] < \(\(\[Theta]\_lo\)\&^\)} = \[Alpha]\)]], " and Prob", Cell[BoxData[ \(TraditionalForm\`{\[Theta] < \(\(\[Theta]\_lo\)\&^\)} = \ \(\(\[Alpha]\)\(.\)\)\)]] }], "Text"], Cell[TextData[{ "Bootstrap is used to generate a distribution of ", Cell[BoxData[ \(TraditionalForm\`\(\(\[Theta]\^*\)\&^\)\)]], " that approximates the distribution of the true parameter \[Theta] by \ taking ", StyleBox["B", FontSlant->"Italic"], " resamples of the data", "." }], "Text"], Cell[TextData[{ "Bootstrap percentile intervals are constructed by taking \[Alpha]th and 1-\ \[Alpha]th percentiles of the bootstrap distribution of ", Cell[BoxData[ \(TraditionalForm\`\(\(\[Theta]\^*\)\&^\)\)]], ": ", Cell[BoxData[ \(TraditionalForm\`I = \((\(\[Theta]\&^\)\^\(\(*\)\((\[Alpha])\)\), \(\ \[Theta]\&^\)\^\(\(*\)\((1 - \[Alpha])\)\))\)\)]], ", where ", Cell[BoxData[ \(TraditionalForm\`\(\[Theta]\&^\)\^\(\(*\)\((\[Alpha])\)\)\)]], "is the ", StyleBox["B", FontSlant->"Italic"], "\[Alpha]th element of the ordered list of ", StyleBox["B", FontSlant->"Italic"], " replications of ", Cell[BoxData[ \(TraditionalForm\`\(\(\[Theta]\^*\)\&^\)\)]], ". Likewise one determines ", Cell[BoxData[ \(TraditionalForm\`\(\[Theta]\&^\)\^\(\(*\)\((1 - \[Alpha])\)\)\)]], "." }], "Text"], Cell["\<\ In this package, one can calculate two important modifications of \ the bootstrap percentile intervals: bias corrected and accelerated (BCa) and \ extreme percentiles intervals.\ \>", "Text"], Cell[TextData[{ "BCa interval is given by ", Cell[BoxData[ \(TraditionalForm\`I\_BCa = \ \((\(\[Theta]\&^\)\^\(\(*\)\((\[Alpha]\_1)\)\), \(\[Theta]\&^\)\^\(\(*\)\((\ \[Alpha]\_2)\)\))\)\)]], " where the modified percentile points are calculated as" }], "Text"], Cell[BoxData[{ \(\[Alpha]\_1 = \[CapitalPhi] \((\(z\&^\)\_0 + \(\(z\&^\)\_0 + z\^\((\ \[Alpha])\)\)\/\(1 - \(a\&^\) \((\(z\&^\)\_0 + z\^\((\[Alpha])\))\)\))\)\), "\ \[IndentingNewLine]", \(\[Alpha]\_2 = \[CapitalPhi] \((\(z\&^\)\_0 + \(\(z\&^\)\_0 + z\^\((1 - \ \[Alpha])\)\)\/\(1 - \(a\&^\) \((\(z\&^\)\_0 + z\^\((1 - \ \[Alpha])\))\)\))\)\)}], "DisplayFormula"], Cell[TextData[{ "Here \[CapitalPhi] is the standard normal cumulative distribution function \ and ", Cell[BoxData[ \(TraditionalForm\`z\^\((\[Alpha])\)\)]], " is 100\[Alpha]th percentile point of a standard normal distribution." }], "Text"], Cell[TextData[{ "Bias-correction constant ", Cell[BoxData[ \(TraditionalForm\`\(z\&^\)\_0\)]], " is obtained directly from the proportion of bootstrap replications less \ or equal to the original estimate ", Cell[BoxData[ \(TraditionalForm\`\(\[Theta]\&^\)\)]], ", and the acceleration constant can be most conveniently estimated with \ jackknife values of the statistic ", Cell[BoxData[ \(TraditionalForm\`\(\[Theta]\&^\)\_\((i)\)\)]], "(obtained with the original sample with the ", StyleBox["i", FontSlant->"Italic"], "th point deleted):" }], "Text"], Cell[BoxData[{ \(\(z\&^\)\_0 = \(\[CapitalPhi]\^\(-1\)\) \((\(# \ \((\(\(\[Theta]\&^\)\^*\) < \(\[Theta]\&^\))\)\)\/B)\)\), \ "\[IndentingNewLine]", \(\(a\&^\) = \(\[Sum]\+\(i = 1\)\%n\((\(\[Theta]\&^\)\_\((\[CenterDot])\) \ - \(\[Theta]\&^\)\_\((i)\))\)\^3\)\/\(6 {\[Sum]\+\(i = 1\)\%n\((\(\[Theta]\&^\ \)\_\((\[CenterDot])\) - \(\[Theta]\&^\)\_\((i)\))\)\^2}\^\(3/2\)\)\)}], \ "DisplayFormula"], Cell[TextData[{ "where ", Cell[BoxData[ \(\(\[Theta]\&^\)\_\((\[CenterDot])\) = \[Sum]\+\(i = 1\)\%n\( \[Theta]\ \&^\)\_\((i)\)/n\)]], "." }], "Text"], Cell[TextData[{ "Extreme percentiles intervals ", Cell[BoxData[ \(TraditionalForm\`I\_EX = \((\(\(\[Theta]\&^\)\_\((1)\)\%*\), \(\(\ \[Theta]\&^\)\_\((B)\)\%*\))\)\)]], "are obtained by first and last elements in the ordered list of bootstrap \ replications, where the size of bootstrap effort ", StyleBox["B", FontSlant->"Italic"], " is determined by solving extreme coverage equations for the optimal ", StyleBox["B", FontSlant->"Italic"], ":" }], "Text"], Cell[BoxData[{ \(\((1)\)\ \ \ \ Prob {\[Theta] \[LessEqual] \ \(\(\[Theta]\&^\)\_\((B)\)\%*\)} = 1 - \((B + 1)\)\^\(-1\) - \((1/6)\) \((b\^3/B)\)\ \(A\_1/ n\^\(1/2\)\)/\[Sigma]\^3\), "\[IndentingNewLine]", \(\((2)\)\ \ \ \ Prob {\[Theta] \[GreaterEqual] \ \(\(\[Theta]\&^\)\_\((1)\)\%*\)} = 1 - \((B + 1)\)\^\(-1\) + \((1/6)\) \((b\^3/B)\)\ \(A\_1/ n\^\(1/2\)\)/\[Sigma]\^3\), "\[IndentingNewLine]", \(\((3)\)\ \ \ \ Prob {\(\(\[Theta]\&^\)\_\((1)\)\%*\) \[LessEqual] \ \[Theta] \[LessEqual] \(\(\[Theta]\&^\)\_\((B)\)\%*\)} = 1 - 2 \((B + 1)\)\^\(-1\) - \((1/36)\) \((b\^6/B)\)\ \(A\_1\%2/ n\)/\[Sigma]\^6\)}], "DisplayFormula"], Cell[TextData[{ "where ", StyleBox["b", FontSlant->"Italic"], " is the maximum positive solution of " }], "Text"], Cell[BoxData[ \(\((4)\)\ \ \ \ B\ \[Phi] \((b - b\^\(-1\))\) = b\)], "DisplayFormula"], Cell["\<\ Here, Eqs. (1), (2), and (3) are solved for one-sided upper, \ one-sided lower, and two-sided intervals, respectively. To obtain an \ equi-tailed two-sided interval of coverage \[Alpha], one has to solve two \ equations (1) and (2) equating each to (1+\[Alpha])/2 and then follow the \ algorithm described in Lee's paper (the purpose of that special calculation \ is to reduce the variability of endpoints).\ \>", "Text"], Cell[TextData[{ StyleBox["References\n\n", FontWeight->"Bold"], "B. Efron, R.J. Tibshirani, \"An introduction to the Bootstrap\", Chapman \ and Hall, Inc., New York, London, 1993.\n\nS.M.S. Lee, \"Nonparametric \ confidence intervals based on extreme bootstrap percentiles\", Statistica \ Sinica, 10: 475, 2000." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Examples", "Section"], Cell[CellGroupData[{ Cell["Example 1", "Subsection"], Cell[TextData[StyleBox["In Example 1 we calculate two-sided BCa percentile \ interval for the sample mean.", FontWeight->"Bold"]], "Text"], Cell[TextData[{ "In general, a statistic (function of a random variable) to be bootstrapped \ should be defined as a ", StyleBox["Mathematica", FontSlant->"Italic"], " function. In the case of the mean, however, there exists a standard ", StyleBox["Mathematica", FontSlant->"Italic"], " function Mean that can be given as an argument to bootstrapping \ functions." }], "Text"], Cell["\<\ Generate a random sample from the standard normal distribution \ (first fix random seed to reproduce the sample later).\ \>", "Text"], Cell[BoxData[ \(SeedRandom[228930]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(data1 = RandomArray[NormalDistribution[0, 1], 30]\)], "Input"], Cell[BoxData[ \({2.403130066935532`, 0.29863980549296354`, \(-0.2524814844046087`\), \ \(-2.0330939375862456`\), 1.1722404149392849`, 0.6462071548479135`, 0.38926126389864646`, 0.19179946197329603`, \(-1.519922058529406`\), 0.22062568709390606`, 0.7096751670508148`, 1.0856574626018203`, \(-0.5405508983699421`\), \ \(-1.2719631474350275`\), \(-1.680770940251678`\), \(-0.27071848779088736`\), 1.3450273416028717`, 1.6528885422937007`, 0.2874253285639046`, 0.22855727644603724`, \(-1.345312219975815`\), \ \(-0.49598726503351304`\), 0.8488508513093912`, \(-0.23970306174687833`\), \ \(-1.5017503706105257`\), \(-0.3509587579929159`\), 0.16392529717448454`, 1.0725308481400788`, \(-0.4506612925618982`\), 0.12677854113675152`}\)], "Output"] }, Open ]], Cell["Here's the observed value of the statistic (sample mean):", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Mean[data1]\)], "Input"], Cell[BoxData[ \(0.02964488630706855`\)], "Output"] }, Open ]], Cell["Here are the jackknife replications of the statistic:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?JackknifeReplications\)\)], "Input"], Cell[BoxData[ \("JackknifeReplications[fun, dat] returns a list of jackknife \ replications of a statistic, given a function that computes the statistic \ (fun) and the sample data (dat)."\)], "Print", CellTags->"Info3229117211-9070610"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(jack1 = JackknifeReplications[Mean, data1]\)], "Input"], Cell[BoxData[ \({\(-0.05219943026632675`\), 0.020369199438589412`, 0.03937338184885051`, 0.10077381126890696`, \(-0.009754959507835463`\), 0.008384118426349754`, 0.01724432156253138`, 0.024053349215129683`, 0.08307822923246425`, 0.02305934145235003`, 0.0061955662814221334`, \(-0.006769340461715964`\), 0.04930680991662065`, 0.0745279219533477`, 0.0886247423953012`, 0.04000224403458428`, \(-0.01571312939278673`\), \ \(-0.02632903286488427`\), 0.020755905539591467`, 0.022785838371242054`, 0.07705720031682317`, 0.04777013290501965`, 0.0013964047552643248`, 0.03893274658479085`, 0.082451619304227`, 0.042769149903619755`, 0.02501452731164042`, \(-0.006316698583724923`\), 0.046207168337032915`, 0.026295449933631206`}\)], "Output"] }, Open ]], Cell["\<\ Here are the nonparametric bootstrap replications of the statistic:\ \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?BootstrapReplications\)\)], "Input"], Cell[BoxData[ \("BootstrapReplications[fun, B, arg, S] returns a nested list {boot, \ bootinds} containing a list of B bootstrap replications of a statistic (boot) \ and a list of B lists each corresponding to a bootstrap resample and \ containing indices of data points in the sample data list that are not \ present in that resample (bootinds). Resamples are generated from sample \ data (nonparametric mode, arg is the list of data) or from a given \ distribution (parametric mode, arg is a completely specified distribution). \ In case of parametric resamples, an optional argument S gives the size of a \ sample. Statistic is computed with function fun."\)], "Print", CellTags->"Info3229117223-9270034"] }, Open ]], Cell[BoxData[ \(SeedRandom[338901]\)], "Input"], Cell[BoxData[ \(\(boot1 = BootstrapReplications[Mean, 2000, data1];\)\)], "Input"], Cell["Here are the BCa confidence intervals:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?BootstrapCI\)\)], "Input"], Cell[BoxData[ \("BootstrapCI[obs, boot, jack] returns a list {lower, upper} \ representing a bootsrap confidence interval, given the observed value of the \ statistic (obs), a list of its bootstrap replications (boot), and a list of \ its jackknife replications (jack)."\)], "Print", CellTags->"Info3229117238-8127272"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(BootstrapCI[Mean[data1], boot1[\([1]\)], jack1, BootstrapCIMethod \[Rule] BCaPercentiles]\)], "Input"], Cell[BoxData[ \({\(-0.3407003507280921`\), 0.39938215012236294`}\)], "Output"] }, Open ]], Cell["\<\ Here are the variances of endpoints of the above BCa \ interval:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?VarianceNonParametricBCaCIEndpoints\)\)], "Input"], Cell[BoxData[ \("VarianceNonParametricBCaCIEndpoints[obs, boot, jack, bootinds] returns \ a list {lower, upper} representing estimates of variance of BCa percentile \ interval endpoints using the jackknife-after-bootstrap method, given observed \ value of the statistic (obs), a list of nonparametric bootstrap replications \ of the statistic (boot), a list of jackknife replications of the statistic \ (jack), and a list of indices of sample data points that do not occur in each \ nonparametric bootstrap resample (bootinds)."\)], "Print", CellTags->"Info3229117248-6425053"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(VarianceNonParametricBCaCIEndpoints[Mean[data1], boot1[\([1]\)], jack1, boot1[\([2]\)]]\)], "Input"], Cell[BoxData[ \({0.05577934578903807`, 0.07701036640099765`}\)], "Output"] }, Open ]], Cell["Standard deviations..", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Sqrt[%]\)], "Input"], Cell[BoxData[ \({0.23617651405048318`, 0.27750741683961827`}\)], "Output"] }, Open ]], Cell[TextData[{ "Now let's calculate confidence interval for the mean based on the normal \ theory using standard ", StyleBox["Mathematica", FontSlant->"Italic"], " package ", StyleBox["Statistics`ConfidenceIntervals`", "Input"] }], "Text"], Cell[BoxData[ \(<< Statistics`ConfidenceIntervals`\)], "Input"], Cell["\<\ Notice that the standard interval is a little wider than the \ bootstrap interval.. However, given rather large variances of the endpoints, the results are \ equivalent.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(MeanCI[data1]\)], "Input"], Cell[BoxData[ \({\(-0.3635138824977288`\), 0.42280365511186596`}\)], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Example 2", "Subsection"], Cell[TextData[StyleBox["In Example 2 we calculate minimum number of bootstrap \ resamples needed for the extreme percentile interval for the sample \ variance.", FontWeight->"Bold"]], "Text"], Cell["\<\ First we generate a random sample from the standard normal \ distribution..\ \>", "Text"], Cell[BoxData[ \(SeedRandom[932648]\)], "Input"], Cell[BoxData[ \(\(data2 = RandomArray[NormalDistribution[0, 1], 20];\)\)], "Input"], Cell["We will need jackknife replications..", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(jack2 = JackknifeReplications[Variance, data2]\)], "Input"], Cell[BoxData[ \({0.8114248843454512`, 0.8991884699234459`, 0.8673624508140518`, 0.9078701058436166`, 0.8615244265210394`, 0.8005625539182186`, 0.9087669862106527`, 0.9044574234284004`, 0.6133405427724605`, 0.8869907978054443`, 0.8761254178996449`, 0.882861411304286`, 0.8163767848949433`, 0.9067603978302432`, 0.9071136064255081`, 0.8616073494223556`, 0.9075404848684688`, 0.8595122610554373`, 0.8352272087651835`, 0.9065642837354171`}\)], "Output"] }, Open ]], Cell["\<\ Now we calculate the minimum numbers of resamples for the one-sided \ upper 0.99 confidence limit for the sample variance.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?BootstrapResamples\)\)], "Input"], Cell[BoxData[ \("BootstrapResamples[obs, jack] returns a list {B1, B2} of estimated \ numbers of bootstrap resamples needed for construction of an extreme \ percentile confidence interval, given the observed value of the statistic \ (obs) and a list of jackknife replications for that statistic (jack)."\)], \ "Print", CellTags->"Info3229117299-7115019"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(BootstrapResamples[Variance[data2], jack2, ConfidenceLevel \[Rule] 0.99, ConfidenceInterval \[Rule] OneSidedLower]\)], "Input"], Cell[BoxData[ \({16, 16}\)], "Output"] }, Open ]], Cell["\<\ Now we calculate minimum numbers for different type of intervals \ and different coverage levels.. These results can be compared with the Table 1 in S.M.S Lee's paper in Stat. \ Sinica, 10 (2000), 475. The discrepancies are due to estimation of A_1 and sigma by jackknife in our \ function, whereas Lee used analytical expressions.\ \>", "Text"], Cell["\<\ Please note the following about the resulting table: 1) columns correspond to one-sided upper, one-sided lower, two-sided \ asymmetrical, two-sided equi-tailed intervals; 2) rows correspond to confidence levels 0.8,0.85,0.9,0.925,0.95,0.975,0.99 \ that refer to two-sided coverage; therefore, for comparison, to obtain \ one-sided and two-sided equitailed intervals of coverage, that would be \ equivalent to two-sided coverage \[Alpha], one has to specify ConfidenceLevel \ -> (1+\[Alpha])/2.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Map[ Map[Apply[ BootstrapResamples[Variance[data2], jack2, ConfidenceLevel \[Rule] #1, ConfidenceInterval \[Rule] #2] &, #] &, {{\((1 + #)\)/2, OneSidedUpper}, {\((1 + #)\)/2, OneSidedLower}, {#, TwoSidedAsymmetrical}, {\((1 + #)\)/2, TwoSidedEquiTailed}}] &, {0.8, 0.85, 0.9, 0.925, 0.95, 0.975, 0.99}] // TableForm\)], "Input"], Cell[BoxData[ InterpretationBox[GridBox[{ {GridBox[{ {"18"}, {"18"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"5"}, {"5"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"11"}, {"11"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"5"}, {"18"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {GridBox[{ {"27"}, {"27"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"6"}, {"6"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"17"}, {"17"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"6"}, {"27"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {GridBox[{ {"47"}, {"47"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"8"}, {"8"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"33"}, {"33"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"8"}, {"47"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {GridBox[{ {"69"}, {"69"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"10"}, {"10"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"55"}, {"55"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"10"}, {"69"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {GridBox[{ {"119"}, {"119"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"12"}, {"12"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"118"}, {"118"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"12"}, {"119"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {GridBox[{ {"292"}, {"292"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"15"}, {"15"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"434"}, {"434"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"15"}, {"292"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]}, {GridBox[{ {"925"}, {"925"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"19"}, {"19"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"2133"}, {"2133"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}], GridBox[{ {"19"}, {"925"} }, RowSpacings->0.25, ColumnSpacings->1, RowAlignments->Baseline, ColumnAlignments->{Left}]} }, RowSpacings->1, ColumnSpacings->3, RowAlignments->Baseline, ColumnAlignments->{Left}], TableForm[ {{{18, 18}, {5, 5}, {11, 11}, {5, 18}}, {{27, 27}, {6, 6}, { 17, 17}, {6, 27}}, {{47, 47}, {8, 8}, {33, 33}, {8, 47}}, {{69, 69}, { 10, 10}, {55, 55}, {10, 69}}, {{119, 119}, {12, 12}, {118, 118}, {12, 119}}, {{292, 292}, {15, 15}, {434, 434}, {15, 292}}, {{925, 925}, { 19, 19}, {2133, 2133}, {19, 925}}}]]], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Example 3", "Subsection"], Cell[TextData[StyleBox["In Example 3 we calculate extreme percentile interval \ for a goodness-of-fit statistic.", FontWeight->"Bold"]], "Text"], Cell["Generate sample data from standard normal distribution..", "Text"], Cell[BoxData[ \(SeedRandom[390013]\)], "Input"], Cell[BoxData[ \(\(data3 = RandomArray[NormalDistribution[0, 1], 50];\)\)], "Input"], Cell["\<\ CDF of the normal distribution that we will fit to the \ sample..\ \>", "Text"], Cell[BoxData[ \(ncdf[xlist_, mu_, sigma_] := CDF[NormalDistribution[mu, sigma], xlist]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(Attributes[ncdf] = {Listable}\)], "Input"], Cell[BoxData[ \({Listable}\)], "Output"] }, Open ]], Cell["Root mean square error is our goodness-of-fit statistic..", "Text"], Cell[BoxData[ \(rmserror[m_, s_] := \[IndentingNewLine]Sqrt[ Apply[Plus, \((ylist - ncdf[xlist, m, s])\)^2]]\)], "Input"], Cell[TextData[{ "This function takes in a list of random data, fits the distribution, and \ outputs the value of a goodness-of-fit statistic.\nIt is defined in a form \ suitable for input into functions of the ", StyleBox["Bootstrap", "Input"], " package." }], "Text"], Cell[BoxData[ \(fun[data_] := \((xlist = \(Transpose[QuantileForm[data]]\)[\([2]\)]; ylist = \(Transpose[QuantileForm[data]]\)[\([1]\)] // N; fitres = FindMinimum[rmserror[m, s], {m, {0.0, 0.1}}, {s, {1.0, 1.1}}]; fitres[\([1]\)])\)\)], "Input"], Cell["We will need observed value and jackknife replications..", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(obs = fun[data3]\)], "Input"], Cell[BoxData[ \(0.17615631262492973`\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(jack3 = JackknifeReplications[fun, data3]\)], "Input"], Cell[BoxData[ \({0.17944093433985972`, 0.182850773351589`, 0.1781761725005569`, 0.1666130395073546`, 0.18246246082315934`, 0.17020785884228837`, 0.16633190615790783`, 0.1734766270334508`, 0.1775153703873478`, 0.1793422649757576`, 0.18279583623358575`, 0.1782298596248352`, 0.17662560673897884`, 0.18659789141065755`, 0.18135265211429089`, 0.17154860701993754`, 0.16586259426263356`, 0.16737323122691056`, 0.17032142601887063`, 0.1781657811053614`, 0.16864805022717988`, 0.1929640534457162`, 0.18141455861355232`, 0.1722178197670199`, 0.1912932271609621`, 0.18602908586247577`, 0.17640963943982943`, 0.1848743772293825`, 0.190091534331443`, 0.1703277755444119`, 0.16583823319423166`, 0.16996068450364402`, 0.16619022733016423`, 0.17751258806617035`, 0.178341966786231`, 0.17100737570467595`, 0.1742506447008215`, 0.17817950732022617`, 0.18542103005459726`, 0.18606947204348828`, 0.17819391509092247`, 0.16868334614369926`, 0.18876546192637014`, 0.17650854339117386`, 0.17669658853951495`, 0.18062453413996418`, 0.16593606316323142`, 0.1830935424004079`, 0.16935127963793387`, 0.16660958200454526`}\)], "Output"] }, Open ]], Cell["\<\ Calculate minimum number of resamples needed for construction of \ one-sided upper 0.95 extreme percentile confidence interval. Notice that this number is much smaller than 1000-2000 usually recommended \ for BCa intervals..\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BootstrapResamples[obs, jack3, ConfidenceInterval \[Rule] OneSidedUpper]\)], "Input"], Cell[BoxData[ \({17, 17}\)], "Output"] }, Open ]], Cell["\<\ Calculate bootstrap replications of the goodness-of-fit statistic..\ \ \>", "Text"], Cell[BoxData[ \(SeedRandom[590246]\)], "Input"], Cell[BoxData[ \(\(boot3 = BootstrapReplications[fun, 17, data3];\)\)], "Input"], Cell["\<\ Calculate the upper confidence limit.. The observed rms value is well below the 0.95 upper confidence limit so the \ hypothesis that fitted distribution generated the sample is not rejected at \ the significance level 0.05.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BootstrapCI[obs, boot3[\([1]\)], jack3, ConfidenceInterval \[Rule] OneSidedUpper]\)], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ InterpretationBox[\(-\[Infinity]\), DirectedInfinity[ -1]], ",", "0.41971712139232625`"}], "}"}]], "Output"] }, Open ]] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell["Bootstrap options", "Section"], Cell["\<\ The following lists what options are available for functions in the \ package: Options and their values are explained with examples below.\ \>", \ "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Options[BootstrapResamples]\)], "Input"], Cell[BoxData[ \({ConfidenceLevel \[Rule] 0.95`, ConfidenceInterval \[Rule] TwoSidedAsymmetrical}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Options[BootstrapReplications]\)], "Input"], Cell[BoxData[ \({BootstrapSamplingMethod \[Rule] NonParametric}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Options[VarianceNonParametricBCaCIEndpoints]\)], "Input"], Cell[BoxData[ \({ConfidenceLevel \[Rule] 0.95`}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Options[BootstrapCI]\)], "Input"], Cell[BoxData[ \({ConfidenceLevel \[Rule] 0.95`, BootstrapCIMethod \[Rule] ExtremePercentiles, ConfidenceInterval \[Rule] TwoSidedAsymmetrical}\)], "Output"] }, Open ]], Cell[TextData[{ "Since functions ", StyleBox["BootstrapResamples", "Input"], " and ", StyleBox["BootstrapCI", "Input"], " use ", StyleBox["RootSearch", "Input"], ", one can pass ", StyleBox["RootSearch", "Input"], " options to them.. Please refer to the ", StyleBox["RootSearch", "Input"], " documentation for more information on values of these options." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Options[RootSearch]\)], "Input"], Cell[BoxData[ \({InitialSamples \[Rule] 300, RootTest \[RuleDelayed] \((Abs[#2] \[LessEqual] 10\^5\ \((Abs[#1] + $MinMachineNumber)\)\ $MachineEpsilon &)\), MaxBrentSteps \[Rule] 150, MaxSecantSteps \[Rule] 90, PrecisionGoal \[RuleDelayed] $MachinePrecision, InitialPrecision \[RuleDelayed] $MachinePrecision}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["BootstrapCIMethod", "Subsection"], Cell["The following explains option BootstrapCIMethod.", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?BootstrapCIMethod\)\)], "Input"], Cell[BoxData[ \("Option BootstrapCIMethod specifies bootstrap method for constructing \ confidence intervals: ExtremePercentiles uses extreme percentile method, \ BCaPercentiles uses BCa percentile method."\)], "Print", CellTags->"Info3229117558-6828883"] }, Open ]], Cell["\<\ The following explains possible values for option BootstrapCIMethod\ \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?BCaPercentiles\)\)], "Input"], Cell[BoxData[ \("BCaPercentiles is value for option BootstrapCIMethod that selects \ construction of BCa percentile confidence intervals."\)], "Print", CellTags->"Info3229117559-8543814"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\(?ExtremePercentiles\)\)], "Input"], Cell[BoxData[ \("ExtremePercentiles is value for option BootstrapCIMethod that selects \ construction of extreme percentile confidence intervals."\)], "Print", CellTags->"Info3229117560-9027466"] }, Open ]], Cell["The default value is", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BootstrapCIMethod /. Options[BootstrapCI]\)], "Input"], Cell[BoxData[ \(ExtremePercentiles\)], "Output"] }, Open ]], Cell["\<\ Uses of BCaPercentiles value was demonstrated in the Example 1 \ above; uses of ExtremePercentiles value were demonstrated in the Examples 2 \ and 3 above.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["BootstrapSamplingMethod", "Subsection"], Cell["The following explains option BootstrapSamplingMethod.", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?BootstrapSamplingMethod\)\)], "Input"], Cell[BoxData[ \("Option BootstrapSamplingMethod specifies bootstrap resampling mode: \ NonParametric uses nonparametric resampling from observed sample with \ replacement, Parametric uses parametric resampling from a completely \ specified distribution."\)], "Print", CellTags->"Info3229117567-7061287"] }, Open ]], Cell["\<\ The following explains possible values for option \ BootstrapSamplingMethod\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?NonParametric\)\)], "Input"], Cell[BoxData[ \("NonParametric is value for option BootstrapSamplingMethod that selects \ nonparametric resampling from the observed sample with replacement."\)], \ "Print", CellTags->"Info3229117570-4513053"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\(?Parametric\)\)], "Input"], Cell[BoxData[ \("Parametric is value for option BootstrapSamplingMethod that selects \ parametric resampling from the completely specified distribution."\)], "Print",\ CellTags->"Info3229117570-8625798"] }, Open ]], Cell["The default value is", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BootstrapSamplingMethod /. Options[BootstrapReplications]\)], "Input"], Cell[BoxData[ \(NonParametric\)], "Output"] }, Open ]], Cell["\<\ Assume now that sample from Example 1 is generated (and stored in \ data1) and jackknife replications are calculated (and stored in \ jack1)..\ \>", "Text"], Cell["Calculate parametric bootstrap resamples", "Text"], Cell[BoxData[ \(SeedRandom[119082]\)], "Input"], Cell[BoxData[ \(\(boot1par = BootstrapReplications[Mean, 2000, NormalDistribution[0, 1], 30, BootstrapSamplingMethod \[Rule] Parametric];\)\)], "Input"], Cell[TextData[{ "Notice that the second element of the list ", StyleBox["boot1par", "Input"], " is empty; it is nonempty only in the nonparametric mode." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(boot1par[\([2]\)]\)], "Input"], Cell[BoxData[ \({}\)], "Output"] }, Open ]], Cell["Now let's calculate BCa interval again..", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BootstrapCI[Mean[data1], boot1par[\([1]\)], jack1, BootstrapCIMethod \[Rule] BCaPercentiles]\)], "Input"], Cell[BoxData[ \({\(-0.2788466530017277`\), 0.44859708391329184`}\)], "Output"] }, Open ]], Cell["\<\ To appreciate the difference, let's look at some parameters of \ intervals. Parametric intervals are shorter and more asymmetric..\ \>", "Text"], Cell["Length of the parametric interval:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\((Part[#, 2] - Part[#, 1])\) &\)[{\(-0.2788466530017277`\), 0.44859708391329184`}]\)], "Input"], Cell[BoxData[ \(0.7274437369150195`\)], "Output"] }, Open ]], Cell["Length of the nonparametric interval:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\((Part[#, 2] - Part[#, 1])\) &\)[{\(-0.3407003507280921`\), 0.39938215012236294`}]\)], "Input"], Cell[BoxData[ \(0.740082500850455`\)], "Output"] }, Open ]], Cell["Shape of the parametric interval:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\((Part[#, 2] - Mean[data1])\)/\((Mean[data1] - Part[#, 1])\) &\)[{\(-0.2788466530017277`\), 0.44859708391329184`}]\)], "Input"], Cell[BoxData[ \(1.3580670592941522`\)], "Output"] }, Open ]], Cell["Shape of the nonparametric interval:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\((Part[#, 2] - Mean[data1])\)/\((Mean[data1] - Part[#, 1])\) &\)[{\(-0.3407003507280921`\), 0.39938215012236294`}]\)], "Input"], Cell[BoxData[ \(0.9983583609047236`\)], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["ConfidenceInterval", "Subsection"], Cell["The following explains option ConfidenceInterval.", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?ConfidenceInterval\)\)], "Input"], Cell[BoxData[ \("Option ConfidenceInterval specifies a type of an extreme percentile \ interval to be constructed: OneSidedUpper, OneSidedLower for intervals with \ the one-sided coverage and TwoSidedAsymmetrical and TwoSidedEquiTailed for \ intervals with the two-sided coverage."\)], "Print", CellTags->"Info3229117605-7727247"] }, Open ]], Cell["\<\ The following explains possible values for option \ ConfidenceInterval.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?OneSidedUpper\)\)], "Input"], Cell[BoxData[ \("OneSidedUpper is value for option ConfidenceInterval that specifies \ one-sided upper confidence interval."\)], "Print", CellTags->"Info3229117607-7419164"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\(?OneSidedLower\)\)], "Input"], Cell[BoxData[ \("OneSidedLower is value for option ConfidenceInterval that specifies \ one-sided lower confidence interval."\)], "Print", CellTags->"Info3229117607-1250893"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\(?TwoSidedAsymmetrical\)\)], "Input"], Cell[BoxData[ \("TwoSidedAsymmetrical is value for option ConfidenceInterval that \ specifies two-sided asymmetrical (coverage in the tails is not equal) \ confidence interval."\)], "Print", CellTags->"Info3229117608-7590235"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\(?TwoSidedEquiTailed\)\)], "Input"], Cell[BoxData[ \("TwoSidedEquiTailed is value for option ConfidenceInterval that \ specifies two-sided equi-tailed confidence interval."\)], "Print", CellTags->"Info3229117609-3736861"] }, Open ]], Cell["The default value is", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(ConfidenceInterval /. Options[BootstrapCI]\)], "Input"], Cell[BoxData[ \(TwoSidedAsymmetrical\)], "Output"] }, Open ]], Cell["Uses of these value were demonstrated in Example 2 above.", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["ConfidenceLevel", "Subsection"], Cell[TextData[{ "Option ConfidenceLevel is a standard ", StyleBox["Mathematica", FontSlant->"Italic"], " option.." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?ConfidenceLevel\)\)], "Input"], Cell[BoxData[ RowBox[{"\<\"ConfidenceLevel is an option used to specify the confidence \ level in functions that return statistical confidence intervals.\"\>", " ", ButtonBox[ StyleBox["More\[Ellipsis]", "SR"], ButtonData:>"Statistics`ConfidenceIntervals`", Active->True, ButtonStyle->"AddOnsLink"]}]], "Print", CellTags->"Info3229117620-1991159"] }, Open ]], Cell["Default value is", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(ConfidenceLevel /. Options[BootstrapCI]\)], "Input"], Cell[BoxData[ \(0.95`\)], "Output"] }, Open ]] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell["Notes", "Section"], Cell[CellGroupData[{ Cell["\<\ How to specify option ConfidenceLevel for equi-tailed \ intervals\ \>", "Subsection"], Cell[TextData[{ "Suppose that ", StyleBox["alpha", "Input"], " is the desired coverage of an interval." }], "Text"], Cell["\<\ Then for upper and lower one-sided and for the two-sided \ asymmetrical intervals one should use option\ \>", "Text"], Cell[BoxData[ \(ConfidenceLevel \[Rule] alpha\)], "Input"], Cell["\<\ However, for the two-sided equitailed interval, one should use \ option \ \>", "Text"], Cell[BoxData[ \(ConfidenceLevel \[Rule] \((1 + alpha)\)/2\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["How equations are solved in BootstrapResamples", "Subsection"], Cell[TextData[{ "In function ", StyleBox["BootstrapResamples", "Input"], ", Ersek's function ", StyleBox["RootSearch", "Input"], " is instructed to search for all roots of the equation (4) in the \ Introduction in the interval (0,5), because it was found empirically that b=5 \ corresponds to some millions of ", StyleBox["B", FontSlant->"Italic"], ", a practically not achievable number of resamples." }], "Text"], Cell[TextData[{ "Moreover, only the larger one from the two positive roots of equation (4) \ in the Introduction is taken, because the asymtotic theory of extreme \ intervals assumes ", StyleBox["b\[RightArrow]\[Infinity].", "InlineFormula"] }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["How to use options with user functions", "Subsection"], Cell["\<\ You can use options with the function you want \ bootstrapped/jackknived; just pass them to functions BootstrapReplications \ and JackknifeReplications and they will be passed on to all your function \ calls inside. \ \>", "Text"], Cell["Use the syntax below.", "Text"], Cell[BoxData[ \(JackknifeReplications[\(\(<\)\(funname\)\(>\)\), \(\(<\)\(datalist\)\(>\ \)\), OptionName1 \[Rule] OptionValue1, ... ]\)], "Input"], Cell[TextData[{ "Note however, that you should have a list of default options assigned to \ your function ", StyleBox["", "Input"], ", e.g. with the built-in function ", StyleBox["Options", "Input"], ", because ", StyleBox["Bootstrap.m", "Input"], " functions use ", StyleBox["FilterOptions", "Input"], " package and will use only those options that are assigned to the function \ ", StyleBox["", "Input"], "." }], "Text"], Cell[TextData[{ "For example, since ", StyleBox["", "Input"], " should take only one argument, data list, and the calculation might \ involve setting other parameters, you might be forced to write a wrapper for \ your custom function and use options with that wrapper to pass all necessary \ parameters for your calculation. In this case, don't forget to assign all \ the options that you intend to use to the wrapper function." }], "Text"], Cell[TextData[{ "For example, if your calculation involves standard ", StyleBox["Mathematica", FontSlant->"Italic"], " function ", StyleBox["FindMinimum", "Input"], ", use the assignment below." }], "Text"], Cell[BoxData[ \(Options[\(<\)\(funname\)\(>\)] = Options[FindMinimum]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["How to implement computation failures in user functions", "Subsection"], Cell[TextData[{ "User functions that calculate statistics of random data and are used in \ functions ", StyleBox["BootstrapReplications", "Input"], " and ", StyleBox["JackknifeReplications", "Input"], " can fail to compute. ", StyleBox["BootstrapReplications", "Input"], " and ", StyleBox["JackknifeReplications", "Input"], " can handle these situations but user functions has to be written \ appropriately." }], "Text"], Cell[TextData[{ "A user function should evaluate its intrinsic error conditions and return \ symbol ", StyleBox["$Failed", "Input"], " in such cases", "." }], "Text"], Cell[TextData[{ "Function ", StyleBox["BootstrapReplications", "Input"], " detects the return values ", StyleBox["$Failed", "Input"], " and ignores the bootstrap resample that caused failure. A new resample \ is drawn until the requested number of replications is accumulated." }], "Text"], Cell[TextData[{ "Function ", StyleBox["JackknifeReplications", "Input"], " detects the return value ", StyleBox["$Failed", "Input"], " and aborts the calculation; its return value is a list ", StyleBox["{$Failed, }", "Input"], ", where ", StyleBox["", "Input"], " is the index of the jackknife resample that caused failure. Index of the \ jackknife resample is simply the index of the point from the original (as \ supplied to ", StyleBox["JackknifeReplications", "Input"], ") data list that is omitted in that particular jackknife sample." }], "Text"] }, Closed]] }, Open ]] }, Open ]] }, FrontEndVersion->"4.1 for Macintosh", ScreenRectangle->{{0, 1024}, {0, 746}}, WindowToolbars->"EditBar", WindowSize->{819, 658}, WindowMargins->{{19, Automatic}, {Automatic, 0}}, Magnification->1.25 ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{ "Info3229117211-9070610"->{ Cell[13673, 427, 243, 4, 66, "Print", CellTags->"Info3229117211-9070610"]}, "Info3229117223-9270034"->{ Cell[15033, 464, 717, 10, 180, "Print", CellTags->"Info3229117223-9270034"]}, "Info3229117238-8127272"->{ Cell[16039, 490, 325, 5, 85, "Print", CellTags->"Info3229117238-8127272"]}, "Info3229117248-6425053"->{ Cell[16819, 518, 583, 8, 142, "Print", CellTags->"Info3229117248-6425053"]}, "Info3229117299-7115019"->{ Cell[19959, 626, 360, 6, 85, "Print", CellTags->"Info3229117299-7115019"]}, "Info3229117558-6828883"->{ Cell[35398, 1129, 261, 4, 66, "Print", CellTags->"Info3229117558-6828883"]}, "Info3229117559-8543814"->{ Cell[35847, 1146, 193, 3, 47, "Print", CellTags->"Info3229117559-8543814"]}, "Info3229117560-9027466"->{ Cell[36136, 1157, 201, 3, 47, "Print", CellTags->"Info3229117560-9027466"]}, "Info3229117567-7061287"->{ Cell[36980, 1192, 309, 5, 85, "Print", CellTags->"Info3229117567-7061287"]}, "Info3229117570-4513053"->{ Cell[37482, 1210, 215, 4, 47, "Print", CellTags->"Info3229117570-4513053"]}, "Info3229117570-8625798"->{ Cell[37785, 1222, 210, 4, 47, "Print", CellTags->"Info3229117570-8625798"]}, "Info3229117605-7727247"->{ Cell[40872, 1351, 336, 5, 85, "Print", CellTags->"Info3229117605-7727247"]}, "Info3229117607-7419164"->{ Cell[41397, 1369, 179, 3, 47, "Print", CellTags->"Info3229117607-7419164"]}, "Info3229117607-1250893"->{ Cell[41667, 1380, 179, 3, 47, "Print", CellTags->"Info3229117607-1250893"]}, "Info3229117608-7590235"->{ Cell[41944, 1391, 232, 4, 66, "Print", CellTags->"Info3229117608-7590235"]}, "Info3229117609-3736861"->{ Cell[42272, 1403, 190, 3, 47, "Print", CellTags->"Info3229117609-3736861"]}, "Info3229117620-1991159"->{ Cell[43052, 1439, 402, 9, 47, "Print", CellTags->"Info3229117620-1991159"]} } *) (*CellTagsIndex CellTagsIndex->{ {"Info3229117211-9070610", 49223, 1650}, {"Info3229117223-9270034", 49339, 1653}, {"Info3229117238-8127272", 49457, 1656}, {"Info3229117248-6425053", 49573, 1659}, {"Info3229117299-7115019", 49690, 1662}, {"Info3229117558-6828883", 49806, 1665}, {"Info3229117559-8543814", 49923, 1668}, {"Info3229117560-9027466", 50040, 1671}, {"Info3229117567-7061287", 50157, 1674}, {"Info3229117570-4513053", 50274, 1677}, {"Info3229117570-8625798", 50391, 1680}, {"Info3229117605-7727247", 50508, 1683}, {"Info3229117607-7419164", 50625, 1686}, {"Info3229117607-1250893", 50742, 1689}, {"Info3229117608-7590235", 50859, 1692}, {"Info3229117609-3736861", 50976, 1695}, {"Info3229117620-1991159", 51093, 1698} } *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1727, 52, 50, 0, 134, "Title"], Cell[1780, 54, 162, 4, 55, "Text"], Cell[1945, 60, 283, 7, 131, "Text"], Cell[2231, 69, 42, 0, 36, "Text"], Cell[CellGroupData[{ Cell[2298, 73, 98, 2, 70, "Section", Evaluatable->False], Cell[2399, 77, 413, 12, 74, "Text"], Cell[2815, 91, 102, 2, 33, "Input"], Cell[2920, 95, 54, 0, 36, "Text"], Cell[2977, 97, 110, 2, 33, "Input"], Cell[3090, 101, 251, 7, 55, "Text"], Cell[3344, 110, 702, 19, 131, "Text"], Cell[4049, 131, 106, 4, 36, "Text"], Cell[4158, 137, 65, 1, 32, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[4260, 143, 31, 0, 70, "Section"], Cell[4294, 145, 937, 29, 77, "Text"], Cell[5234, 176, 640, 14, 80, "Text"], Cell[5877, 192, 311, 10, 58, "Text"], Cell[6191, 204, 856, 25, 85, "Text"], Cell[7050, 231, 201, 4, 55, "Text"], Cell[7254, 237, 272, 7, 39, "Text"], Cell[7529, 246, 372, 6, 101, "DisplayFormula"], Cell[7904, 254, 252, 6, 55, "Text"], Cell[8159, 262, 593, 16, 80, "Text"], Cell[8755, 280, 405, 7, 128, "DisplayFormula"], Cell[9163, 289, 162, 6, 43, "Text"], Cell[9328, 297, 485, 13, 59, "Text"], Cell[9816, 312, 706, 12, 84, "DisplayFormula"], Cell[10525, 326, 123, 5, 36, "Text"], Cell[10651, 333, 90, 1, 31, "DisplayFormula"], Cell[10744, 336, 432, 7, 93, "Text"], Cell[11179, 345, 332, 7, 112, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[11548, 357, 27, 0, 70, "Section"], Cell[CellGroupData[{ Cell[11600, 361, 31, 0, 58, "Subsection"], Cell[11634, 363, 140, 2, 36, "Text"], Cell[11777, 367, 395, 10, 74, "Text"], Cell[12175, 379, 143, 3, 36, "Text"], Cell[12321, 384, 51, 1, 33, "Input"], Cell[CellGroupData[{ Cell[12397, 389, 82, 1, 33, "Input"], Cell[12482, 392, 806, 14, 109, "Output"] }, Open ]], Cell[13303, 409, 73, 0, 36, "Text"], Cell[CellGroupData[{ Cell[13401, 413, 44, 1, 33, "Input"], Cell[13448, 416, 54, 1, 33, "Output"] }, Open ]], Cell[13517, 420, 69, 0, 36, "Text"], Cell[CellGroupData[{ Cell[13611, 424, 59, 1, 33, "Input"], Cell[13673, 427, 243, 4, 66, "Print", CellTags->"Info3229117211-9070610"] }, Open ]], Cell[CellGroupData[{ Cell[13953, 436, 75, 1, 33, "Input"], Cell[14031, 439, 807, 12, 109, "Output"] }, Open ]], Cell[14853, 454, 93, 3, 36, "Text"], Cell[CellGroupData[{ Cell[14971, 461, 59, 1, 33, "Input"], Cell[15033, 464, 717, 10, 180, "Print", CellTags->"Info3229117223-9270034"] }, Open ]], Cell[15765, 477, 51, 1, 33, "Input"], Cell[15819, 480, 86, 1, 33, "Input"], Cell[15908, 483, 54, 0, 36, "Text"], Cell[CellGroupData[{ Cell[15987, 487, 49, 1, 33, "Input"], Cell[16039, 490, 325, 5, 85, "Print", CellTags->"Info3229117238-8127272"] }, Open ]], Cell[CellGroupData[{ Cell[16401, 500, 129, 2, 33, "Input"], Cell[16533, 504, 82, 1, 33, "Output"] }, Open ]], Cell[16630, 508, 88, 3, 36, "Text"], Cell[CellGroupData[{ Cell[16743, 515, 73, 1, 33, "Input"], Cell[16819, 518, 583, 8, 142, "Print", CellTags->"Info3229117248-6425053"] }, Open ]], Cell[CellGroupData[{ Cell[17439, 531, 127, 2, 52, "Input"], Cell[17569, 535, 78, 1, 33, "Output"] }, Open ]], Cell[17662, 539, 37, 0, 36, "Text"], Cell[CellGroupData[{ Cell[17724, 543, 40, 1, 33, "Input"], Cell[17767, 546, 78, 1, 33, "Output"] }, Open ]], Cell[17860, 550, 252, 7, 55, "Text"], Cell[18115, 559, 67, 1, 33, "Input"], Cell[18185, 562, 193, 5, 55, "Text"], Cell[CellGroupData[{ Cell[18403, 571, 46, 1, 33, "Input"], Cell[18452, 574, 82, 1, 33, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[18583, 581, 31, 0, 37, "Subsection"], Cell[18617, 583, 193, 3, 55, "Text"], Cell[18813, 588, 99, 3, 36, "Text"], Cell[18915, 593, 51, 1, 33, "Input"], Cell[18969, 596, 87, 1, 33, "Input"], Cell[19059, 599, 53, 0, 36, "Text"], Cell[CellGroupData[{ Cell[19137, 603, 79, 1, 33, "Input"], Cell[19219, 606, 495, 7, 71, "Output"] }, Open ]], Cell[19729, 616, 146, 3, 55, "Text"], Cell[CellGroupData[{ Cell[19900, 623, 56, 1, 33, "Input"], Cell[19959, 626, 360, 6, 85, "Print", CellTags->"Info3229117299-7115019"] }, Open ]], Cell[CellGroupData[{ Cell[20356, 637, 161, 3, 52, "Input"], Cell[20520, 642, 42, 1, 33, "Output"] }, Open ]], Cell[20577, 646, 355, 7, 93, "Text"], Cell[20935, 655, 520, 11, 150, "Text"], Cell[CellGroupData[{ Cell[21480, 670, 477, 9, 147, "Input"], Cell[21960, 681, 6854, 214, 271, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[28863, 901, 31, 0, 37, "Subsection"], Cell[28897, 903, 146, 2, 36, "Text"], Cell[29046, 907, 72, 0, 36, "Text"], Cell[29121, 909, 51, 1, 33, "Input"], Cell[29175, 912, 87, 1, 33, "Input"], Cell[29265, 915, 89, 3, 36, "Text"], Cell[29357, 920, 110, 2, 33, "Input"], Cell[CellGroupData[{ Cell[29492, 926, 62, 1, 33, "Input"], Cell[29557, 929, 44, 1, 33, "Output"] }, Open ]], Cell[29616, 933, 73, 0, 36, "Text"], Cell[29692, 935, 133, 2, 52, "Input"], Cell[29828, 939, 274, 6, 55, "Text"], Cell[30105, 947, 287, 5, 90, "Input"], Cell[30395, 954, 72, 0, 36, "Text"], Cell[CellGroupData[{ Cell[30492, 958, 49, 1, 33, "Input"], Cell[30544, 961, 54, 1, 33, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[30635, 967, 74, 1, 33, "Input"], Cell[30712, 970, 1226, 17, 147, "Output"] }, Open ]], Cell[31953, 990, 248, 5, 74, "Text"], Cell[CellGroupData[{ Cell[32226, 999, 112, 2, 33, "Input"], Cell[32341, 1003, 42, 1, 33, "Output"] }, Open ]], Cell[32398, 1007, 93, 3, 36, "Text"], Cell[32494, 1012, 51, 1, 33, "Input"], Cell[32548, 1015, 83, 1, 33, "Input"], Cell[32634, 1018, 247, 5, 74, "Text"], Cell[CellGroupData[{ Cell[32906, 1027, 121, 2, 33, "Input"], Cell[33030, 1031, 180, 5, 33, "Output"] }, Open ]] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell[33271, 1043, 36, 0, 70, "Section"], Cell[33310, 1045, 165, 4, 55, "Text"], Cell[CellGroupData[{ Cell[33500, 1053, 60, 1, 33, "Input"], Cell[33563, 1056, 121, 2, 33, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[33721, 1063, 63, 1, 33, "Input"], Cell[33787, 1066, 81, 1, 33, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[33905, 1072, 77, 1, 33, "Input"], Cell[33985, 1075, 65, 1, 33, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[34087, 1081, 53, 1, 33, "Input"], Cell[34143, 1084, 174, 3, 52, "Output"] }, Open ]], Cell[34332, 1090, 390, 12, 55, "Text"], Cell[CellGroupData[{ Cell[34747, 1106, 52, 1, 33, "Input"], Cell[34802, 1109, 370, 6, 92, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[35209, 1120, 39, 0, 58, "Subsection"], Cell[35251, 1122, 64, 0, 36, "Text"], Cell[CellGroupData[{ Cell[35340, 1126, 55, 1, 33, "Input"], Cell[35398, 1129, 261, 4, 66, "Print", CellTags->"Info3229117558-6828883"] }, Open ]], Cell[35674, 1136, 93, 3, 36, "Text"], Cell[CellGroupData[{ Cell[35792, 1143, 52, 1, 33, "Input"], Cell[35847, 1146, 193, 3, 47, "Print", CellTags->"Info3229117559-8543814"] }, Open ]], Cell[CellGroupData[{ Cell[36077, 1154, 56, 1, 33, "Input"], Cell[36136, 1157, 201, 3, 47, "Print", CellTags->"Info3229117560-9027466"] }, Open ]], Cell[36352, 1163, 36, 0, 36, "Text"], Cell[CellGroupData[{ Cell[36413, 1167, 74, 1, 33, "Input"], Cell[36490, 1170, 52, 1, 33, "Output"] }, Open ]], Cell[36557, 1174, 179, 4, 55, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[36773, 1183, 45, 0, 37, "Subsection"], Cell[36821, 1185, 70, 0, 36, "Text"], Cell[CellGroupData[{ Cell[36916, 1189, 61, 1, 33, "Input"], Cell[36980, 1192, 309, 5, 85, "Print", CellTags->"Info3229117567-7061287"] }, Open ]], Cell[37304, 1200, 99, 3, 36, "Text"], Cell[CellGroupData[{ Cell[37428, 1207, 51, 1, 33, "Input"], Cell[37482, 1210, 215, 4, 47, "Print", CellTags->"Info3229117570-4513053"] }, Open ]], Cell[CellGroupData[{ Cell[37734, 1219, 48, 1, 33, "Input"], Cell[37785, 1222, 210, 4, 47, "Print", CellTags->"Info3229117570-8625798"] }, Open ]], Cell[38010, 1229, 36, 0, 36, "Text"], Cell[CellGroupData[{ Cell[38071, 1233, 90, 1, 33, "Input"], Cell[38164, 1236, 47, 1, 33, "Output"] }, Open ]], Cell[38226, 1240, 166, 4, 55, "Text"], Cell[38395, 1246, 56, 0, 36, "Text"], Cell[38454, 1248, 51, 1, 33, "Input"], Cell[38508, 1251, 176, 3, 52, "Input"], Cell[38687, 1256, 171, 4, 36, "Text"], Cell[CellGroupData[{ Cell[38883, 1264, 50, 1, 33, "Input"], Cell[38936, 1267, 36, 1, 33, "Output"] }, Open ]], Cell[38987, 1271, 56, 0, 36, "Text"], Cell[CellGroupData[{ Cell[39068, 1275, 132, 2, 52, "Input"], Cell[39203, 1279, 82, 1, 33, "Output"] }, Open ]], Cell[39300, 1283, 154, 4, 55, "Text"], Cell[39457, 1289, 50, 0, 36, "Text"], Cell[CellGroupData[{ Cell[39532, 1293, 127, 2, 33, "Input"], Cell[39662, 1297, 53, 1, 33, "Output"] }, Open ]], Cell[39730, 1301, 53, 0, 36, "Text"], Cell[CellGroupData[{ Cell[39808, 1305, 127, 2, 33, "Input"], Cell[39938, 1309, 52, 1, 33, "Output"] }, Open ]], Cell[40005, 1313, 49, 0, 36, "Text"], Cell[CellGroupData[{ Cell[40079, 1317, 174, 3, 52, "Input"], Cell[40256, 1322, 53, 1, 33, "Output"] }, Open ]], Cell[40324, 1326, 52, 0, 36, "Text"], Cell[CellGroupData[{ Cell[40401, 1330, 174, 3, 52, "Input"], Cell[40578, 1335, 53, 1, 33, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[40680, 1342, 40, 0, 37, "Subsection"], Cell[40723, 1344, 65, 0, 36, "Text"], Cell[CellGroupData[{ Cell[40813, 1348, 56, 1, 33, "Input"], Cell[40872, 1351, 336, 5, 85, "Print", CellTags->"Info3229117605-7727247"] }, Open ]], Cell[41223, 1359, 95, 3, 36, "Text"], Cell[CellGroupData[{ Cell[41343, 1366, 51, 1, 33, "Input"], Cell[41397, 1369, 179, 3, 47, "Print", CellTags->"Info3229117607-7419164"] }, Open ]], Cell[CellGroupData[{ Cell[41613, 1377, 51, 1, 33, "Input"], Cell[41667, 1380, 179, 3, 47, "Print", CellTags->"Info3229117607-1250893"] }, Open ]], Cell[CellGroupData[{ Cell[41883, 1388, 58, 1, 33, "Input"], Cell[41944, 1391, 232, 4, 66, "Print", CellTags->"Info3229117608-7590235"] }, Open ]], Cell[CellGroupData[{ Cell[42213, 1400, 56, 1, 33, "Input"], Cell[42272, 1403, 190, 3, 47, "Print", CellTags->"Info3229117609-3736861"] }, Open ]], Cell[42477, 1409, 36, 0, 36, "Text"], Cell[CellGroupData[{ Cell[42538, 1413, 75, 1, 33, "Input"], Cell[42616, 1416, 54, 1, 33, "Output"] }, Open ]], Cell[42685, 1420, 73, 0, 36, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[42795, 1425, 37, 0, 37, "Subsection"], Cell[42835, 1427, 136, 5, 36, "Text"], Cell[CellGroupData[{ Cell[42996, 1436, 53, 1, 33, "Input"], Cell[43052, 1439, 402, 9, 47, "Print", CellTags->"Info3229117620-1991159"] }, Open ]], Cell[43469, 1451, 32, 0, 36, "Text"], Cell[CellGroupData[{ Cell[43526, 1455, 72, 1, 33, "Input"], Cell[43601, 1458, 39, 1, 33, "Output"] }, Open ]] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell[43701, 1466, 24, 0, 70, "Section"], Cell[CellGroupData[{ Cell[43750, 1470, 95, 3, 58, "Subsection"], Cell[43848, 1475, 121, 4, 36, "Text"], Cell[43972, 1481, 127, 3, 36, "Text"], Cell[44102, 1486, 62, 1, 33, "Input"], Cell[44167, 1489, 96, 3, 36, "Text"], Cell[44266, 1494, 74, 1, 33, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[44377, 1500, 68, 0, 37, "Subsection"], Cell[44448, 1502, 432, 11, 74, "Text"], Cell[44883, 1515, 257, 5, 55, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[45177, 1525, 60, 0, 37, "Subsection"], Cell[45240, 1527, 241, 5, 55, "Text"], Cell[45484, 1534, 37, 0, 36, "Text"], Cell[45524, 1536, 152, 2, 52, "Input"], Cell[45679, 1540, 462, 14, 74, "Text"], Cell[46144, 1556, 456, 8, 93, "Text"], Cell[46603, 1566, 220, 7, 36, "Text"], Cell[46826, 1575, 86, 1, 33, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[46949, 1581, 77, 0, 37, "Subsection"], Cell[47029, 1583, 439, 12, 74, "Text"], Cell[47471, 1597, 174, 6, 36, "Text"], Cell[47648, 1605, 300, 7, 55, "Text"], Cell[47951, 1614, 585, 14, 93, "Text"] }, Closed]] }, Open ]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)