{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Parametric bootstrap in Julia" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Fabrizzio Sanchez](http://www.stat.wisc.edu/node/2034) suggested bootstrapping a statistical model as a non-trivial task on which to demonstrate the speed of [Julia](http://www.stat.wisc.edu).\n", "\n", "In this notebook I will demonstrate a _parametric bootstrap_, which means that samples are drawn from the probability model with parameters set at their estimated values from the original model, and the model refit.\n", "\n", "A simple example is a _linear model_ which can be fit using the `GLM` package." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "WARNING: Base.String is deprecated, use AbstractString instead.\n", " likely near /home/bates/.julia/v0.4/RDatasets/src/dataset.jl:1\n", "WARNING: Base.String is deprecated, use AbstractString instead.\n", " likely near /home/bates/.julia/v0.4/RDatasets/src/dataset.jl:1\n", "WARNING: Base.String is deprecated, use AbstractString instead.\n", " likely near /home/bates/.julia/v0.4/RDatasets/src/datasets.jl:1\n" ] }, { "data": { "text/html": [ "
Country | SR | Pop15 | Pop75 | DPI | DDPI | |
---|---|---|---|---|---|---|
1 | Australia | 11.43 | 29.35 | 2.87 | 2329.68 | 2.87 |
2 | Austria | 12.07 | 23.32 | 4.41 | 1507.99 | 3.93 |
3 | Belgium | 13.17 | 23.8 | 4.43 | 2108.47 | 3.82 |
4 | Bolivia | 5.75 | 41.89 | 1.67 | 189.13 | 0.22 |
5 | Brazil | 12.88 | 42.19 | 0.83 | 728.47 | 4.56 |
6 | Canada | 8.79 | 31.72 | 2.85 | 2982.88 | 2.43 |
7 | Chile | 0.6 | 39.74 | 1.34 | 662.86 | 2.67 |
8 | China | 11.9 | 44.75 | 0.67 | 289.52 | 6.51 |
9 | Colombia | 4.98 | 46.64 | 1.06 | 276.65 | 3.08 |
10 | Costa Rica | 10.78 | 47.64 | 1.14 | 471.24 | 2.8 |
11 | Denmark | 16.85 | 24.42 | 3.93 | 2496.53 | 3.99 |
12 | Ecuador | 3.59 | 46.31 | 1.19 | 287.77 | 2.19 |
13 | Finland | 11.24 | 27.84 | 2.37 | 1681.25 | 4.32 |
14 | France | 12.64 | 25.06 | 4.7 | 2213.82 | 4.52 |
15 | Germany | 12.55 | 23.31 | 3.35 | 2457.12 | 3.44 |
16 | Greece | 10.67 | 25.62 | 3.1 | 870.85 | 6.28 |
17 | Guatamala | 3.01 | 46.05 | 0.87 | 289.71 | 1.48 |
18 | Honduras | 7.7 | 47.32 | 0.58 | 232.44 | 3.19 |
19 | Iceland | 1.27 | 34.03 | 3.08 | 1900.1 | 1.12 |
20 | India | 9.0 | 41.31 | 0.96 | 88.94 | 1.54 |
21 | Ireland | 11.34 | 31.16 | 4.19 | 1139.95 | 2.99 |
22 | Italy | 14.28 | 24.52 | 3.48 | 1390.0 | 3.54 |
23 | Japan | 21.1 | 27.01 | 1.91 | 1257.28 | 8.21 |
24 | Korea | 3.98 | 41.74 | 0.91 | 207.68 | 5.81 |
25 | Luxembourg | 10.35 | 21.8 | 3.73 | 2449.39 | 1.57 |
26 | Malta | 15.48 | 32.54 | 2.47 | 601.05 | 8.12 |
27 | Norway | 10.25 | 25.95 | 3.67 | 2231.03 | 3.62 |
28 | Netherlands | 14.65 | 24.71 | 3.25 | 1740.7 | 7.66 |
29 | New Zealand | 10.67 | 32.61 | 3.17 | 1487.52 | 1.76 |
30 | Nicaragua | 7.3 | 45.04 | 1.21 | 325.54 | 2.48 |
⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ |