Simulates fake O-ring thermal distress data for Challenger Space Shuttle launches at different launch temperatures. The simulated data are based on a linear logistic regression model fitted to the real data from the 23 (pre-disaster) launches.
shuttle_sim(n_sim = 1, temperature = NULL)
A integer scalar. The number of fake datasets to simulate.
A numeric vector of launch temperatures.
If temperature
is not supplied then the 23 launch temperatures
from the real dataset are used.
If temperature
is supplied then it must be a vector of length one
(i.e. a scalar). In this event n_sim
gives the number of
simulated numbers of damaged O-rings at launch temperature
temperature
. If temperature
has length greater than one
then only the first element of temperature
is used and a warning
is given.
The output depends on whether or not temperature
is supplied by
the user.
If temperature
is supplied then shuttle_sim
returns a dataframe with 2 + n_sim
columns.
Column 1 contains the launch temperatures, column 2 contains the numbers
of distressed O-rings in the real data and columns 3 to
2 + n_sim
the n_sim
simulated datasets.
If temperature
is not supplied then shuttle_sim
returns a vector of length n_sim
.
The data are simulated from a linear logistic regression model
fitted to the real (pre-disaster) O-ring distress and launch
temperature data. For a given launch temperature \(t\) this model
provides an estimate, \(\hat{p}(t)\) say, of the probability that an
O-ring suffers thermal distress. Then the number of the 6 O-rings
that suffers from thermal distress is simulated from a
binomial(6, \(\hat{p}(t)\)) distribution, under an assumption that
the fates of the O-rings are independent. This is repeated for each of
the launch temperatures in temperatures
.
For further details see the
Challenger Space Shuttle Disaster
vignette.
The Challenger Space Shuttle Disaster vignette.
shuttle_sim_plot
for assessing uncertainty concerning
the modelling of the space shuttle data using simulation.
# Simulate 10 fake datasets of size 23, using the real temperatures.
res <- shuttle_sim(n_sim = 10)
res
#> temps real sim1 sim2 sim3 sim4 sim5 sim6 sim7 sim8 sim9 sim10
#> 1 66 0 1 0 0 1 1 0 1 0 1 1
#> 2 70 1 0 1 0 0 0 0 0 2 0 0
#> 3 69 0 0 0 2 0 0 0 0 0 2 1
#> 4 68 0 1 0 0 1 0 0 2 0 0 1
#> 5 67 0 0 1 0 2 0 0 1 1 0 0
#> 6 72 0 0 0 0 0 1 0 2 2 0 0
#> 7 73 0 0 1 0 1 0 0 0 0 1 0
#> 8 70 0 0 0 0 0 2 0 1 0 0 0
#> 9 57 1 1 1 1 2 1 2 0 0 0 0
#> 10 63 1 2 0 0 0 0 0 1 0 1 0
#> 11 70 1 0 0 1 0 0 0 0 0 0 1
#> 12 78 0 0 0 0 0 0 0 1 0 0 0
#> 13 67 0 1 2 0 0 1 1 0 0 2 0
#> 14 53 3 3 3 2 4 3 0 2 1 4 2
#> 15 67 0 0 0 2 0 1 1 0 0 0 0
#> 16 75 0 1 0 0 0 0 0 0 0 0 0
#> 17 70 0 1 0 0 0 0 0 0 1 0 0
#> 18 81 0 1 0 0 0 0 0 0 0 0 0
#> 19 76 0 0 0 0 0 2 0 0 0 0 0
#> 20 79 0 0 0 1 0 0 0 0 0 0 0
#> 21 75 2 0 0 0 0 0 0 0 0 0 0
#> 22 76 0 0 0 0 0 0 0 0 0 0 0
#> 23 58 1 1 0 1 3 0 2 1 1 0 2
# Simulate the number of distressed O-rings for 1000 launches at 31 deg F.
res <- shuttle_sim(n_sim = 1000, temperature = 31)
res[1:100]
#> [1] 4 6 5 6 5 6 6 6 5 6 6 5 5 6 6 6 5 4 6 6 4 5 5 6 6 4 6 6 6 6 6 6 6 6 6 6 5
#> [38] 6 6 6 4 6 6 6 6 5 6 6 5 6 5 6 6 6 5 5 4 6 5 5 6 6 6 5 5 6 5 6 6 6 5 6 6 6
#> [75] 4 5 6 5 5 5 6 6 6 6 6 5 6 6 6 6 4 6 4 5 6 6 6 6 6 6
table(res)
#> res
#> 2 3 4 5 6
#> 13 189 1571 7380 13847