This function extracts model simulations for objects of classes seiqhrf into a data frame using the generic as.data.frame function.

# S3 method for seiqhrf
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  out = "vals",
  sim,
  qval,
  ...
)

Arguments

x

An EpiModel object of class icm or netsim.

row.names

See as.data.frame.default.

optional

See as.data.frame.default.

out

Data output to data frame: "mean" for row means across simulations, "sd" for row standard deviations across simulations, "qnt" for row quantiles at the level specified in qval, or "vals" for values from individual simulations.

sim

If out="vals", the simulation number to output. If not specified, then data from all simulations will be output.

qval

Quantile value required when out="qnt".

...

See as.data.frame.default.

Details

These methods work for both seiqhrf class models. The available output includes time-specific means, standard deviations, quantiles, and simulation values (compartment and flow sizes) from these stochastic model classes. Means, standard deviations, and quantiles are calculated by taking the row summary (i.e., each row of data is corresponds to a time step) across all simulations in the model output.

Examples

## Stochastic SEIQHRF model param <- param_seiqhrf() init <- init_seiqhrf(s.num = 500, i.num = 1) control <- control_seiqhrf(nsteps = 10, nsims = 3) mod <- seiqhrf(init, control, param) # Default output all simulation runs, default to all in stacked data.frame as.data.frame(mod)
#> sim time s.num i.num num se.flow is.flow iq.flow iq2h.flow hf.flow ds.flow #> 1 1 1 500 1 501 0 0 0 0 0 0 #> 2 1 2 499 1 501 1 0 0 0 0 0 #> 3 1 3 499 1 501 0 0 0 0 0 0 #> 4 1 4 499 1 501 0 0 0 0 0 0 #> 5 1 5 498 1 501 1 0 0 0 0 0 #> 6 1 6 495 2 501 1 1 0 0 0 0 #> 7 1 7 493 2 501 2 0 0 0 0 0 #> 8 1 8 490 3 501 3 0 0 0 0 0 #> 9 1 9 485 4 501 4 0 0 0 0 0 #> 10 1 10 479 6 501 4 1 0 0 0 0 #> 11 2 1 500 1 501 0 0 0 0 0 0 #> 12 2 2 499 1 501 1 0 0 0 0 0 #> 13 2 3 499 1 501 0 1 0 0 0 0 #> 14 2 4 499 1 501 0 0 0 0 0 0 #> 15 2 5 499 1 501 0 0 0 0 0 0 #> 16 2 6 499 1 501 0 0 0 0 0 0 #> 17 2 7 498 1 501 1 0 0 0 0 0 #> 18 2 8 498 1 501 0 0 0 0 0 0 #> 19 2 9 496 1 501 1 0 0 0 0 0 #> 20 2 10 494 2 501 1 0 0 0 0 0 #> 21 3 1 500 1 501 0 0 0 0 0 0 #> 22 3 2 499 1 501 1 0 0 0 0 0 #> 23 3 3 499 0 501 0 1 1 0 0 0 #> 24 3 4 499 0 501 0 0 0 0 0 0 #> 25 3 5 499 0 501 0 0 0 0 0 0 #> 26 3 6 499 0 501 0 0 0 0 0 0 #> 27 3 7 499 0 501 0 0 0 0 0 0 #> 28 3 8 499 0 501 0 0 0 0 0 0 #> 29 3 9 498 0 501 1 0 0 0 0 0 #> 30 3 10 498 0 501 0 0 0 0 0 0 #> de.flow di.flow dq.flow dh.flow dr.flow a.flow a.e.flow a.i.flow a.q.flow #> 1 0 0 0 0 0 0 0 0 0 #> 2 0 0 0 0 0 0 0 0 0 #> 3 0 0 0 0 0 0 0 0 0 #> 4 0 0 0 0 0 0 0 0 0 #> 5 0 0 0 0 0 0 0 0 0 #> 6 0 0 0 0 0 0 0 0 0 #> 7 0 0 0 0 0 0 0 0 0 #> 8 0 0 0 0 0 0 0 0 0 #> 9 0 0 0 0 0 0 0 0 0 #> 10 0 0 0 0 0 0 0 0 0 #> 11 0 0 0 0 0 0 0 0 0 #> 12 0 0 0 0 0 0 0 0 0 #> 13 0 0 0 0 0 0 0 0 0 #> 14 0 0 0 0 0 0 0 0 0 #> 15 0 0 0 0 0 0 0 0 0 #> 16 0 0 0 0 0 0 0 0 0 #> 17 0 0 0 0 0 0 0 0 0 #> 18 0 0 0 0 0 0 0 0 0 #> 19 0 0 0 0 0 0 0 0 0 #> 20 0 0 0 0 0 0 0 0 0 #> 21 0 0 0 0 0 0 0 0 0 #> 22 0 0 0 0 0 0 0 0 0 #> 23 0 0 0 0 0 0 0 0 0 #> 24 0 0 0 0 0 0 0 0 0 #> 25 0 0 0 0 0 0 0 0 0 #> 26 0 0 0 0 0 0 0 0 0 #> 27 0 0 0 0 0 0 0 0 0 #> 28 0 0 0 0 0 0 0 0 0 #> 29 0 0 0 0 0 0 0 0 0 #> 30 0 0 0 0 0 0 0 0 0 #> e.num r.num q.num h.num f.num #> 1 NA NA NA NA NA #> 2 1 0 0 0 0 #> 3 1 0 0 0 0 #> 4 1 0 0 0 0 #> 5 2 0 0 0 0 #> 6 3 1 0 0 0 #> 7 5 1 0 0 0 #> 8 7 1 0 0 0 #> 9 11 1 0 0 0 #> 10 14 2 0 0 0 #> 11 NA NA NA NA NA #> 12 1 0 0 0 0 #> 13 0 1 0 0 0 #> 14 0 1 0 0 0 #> 15 0 1 0 0 0 #> 16 0 1 0 0 0 #> 17 1 1 0 0 0 #> 18 1 1 0 0 0 #> 19 3 1 0 0 0 #> 20 4 1 0 0 0 #> 21 NA NA NA NA NA #> 22 1 0 0 0 0 #> 23 0 1 1 0 0 #> 24 0 1 1 0 0 #> 25 0 1 1 0 0 #> 26 0 1 1 0 0 #> 27 0 1 1 0 0 #> 28 0 1 1 0 0 #> 29 1 1 1 0 0 #> 30 1 1 1 0 0
as.data.frame(mod, sim = 2)
#> sim time s.num i.num num se.flow is.flow iq.flow iq2h.flow hf.flow ds.flow #> 1 2 1 500 1 501 0 0 0 0 0 0 #> 2 2 2 499 1 501 1 0 0 0 0 0 #> 3 2 3 499 1 501 0 1 0 0 0 0 #> 4 2 4 499 1 501 0 0 0 0 0 0 #> 5 2 5 499 1 501 0 0 0 0 0 0 #> 6 2 6 499 1 501 0 0 0 0 0 0 #> 7 2 7 498 1 501 1 0 0 0 0 0 #> 8 2 8 498 1 501 0 0 0 0 0 0 #> 9 2 9 496 1 501 1 0 0 0 0 0 #> 10 2 10 494 2 501 1 0 0 0 0 0 #> de.flow di.flow dq.flow dh.flow dr.flow a.flow a.e.flow a.i.flow a.q.flow #> 1 0 0 0 0 0 0 0 0 0 #> 2 0 0 0 0 0 0 0 0 0 #> 3 0 0 0 0 0 0 0 0 0 #> 4 0 0 0 0 0 0 0 0 0 #> 5 0 0 0 0 0 0 0 0 0 #> 6 0 0 0 0 0 0 0 0 0 #> 7 0 0 0 0 0 0 0 0 0 #> 8 0 0 0 0 0 0 0 0 0 #> 9 0 0 0 0 0 0 0 0 0 #> 10 0 0 0 0 0 0 0 0 0 #> e.num r.num q.num h.num f.num #> 1 NA NA NA NA NA #> 2 1 0 0 0 0 #> 3 0 1 0 0 0 #> 4 0 1 0 0 0 #> 5 0 1 0 0 0 #> 6 0 1 0 0 0 #> 7 1 1 0 0 0 #> 8 1 1 0 0 0 #> 9 3 1 0 0 0 #> 10 4 1 0 0 0
# Time-specific means across simulations as.data.frame(mod, out = "mean")
#> time s.num i.num num se.flow is.flow iq.flow iq2h.flow hf.flow #> 1 1 500.0000 1.0000000 501 0.0000000 0.0000000 0.0000000 0 0 #> 2 2 499.0000 1.0000000 501 1.0000000 0.0000000 0.0000000 0 0 #> 3 3 499.0000 0.6666667 501 0.0000000 0.6666667 0.3333333 0 0 #> 4 4 499.0000 0.6666667 501 0.0000000 0.0000000 0.0000000 0 0 #> 5 5 498.6667 0.6666667 501 0.3333333 0.0000000 0.0000000 0 0 #> 6 6 497.6667 1.0000000 501 0.3333333 0.3333333 0.0000000 0 0 #> 7 7 496.6667 1.0000000 501 1.0000000 0.0000000 0.0000000 0 0 #> 8 8 495.6667 1.3333333 501 1.0000000 0.0000000 0.0000000 0 0 #> 9 9 493.0000 1.6666667 501 2.0000000 0.0000000 0.0000000 0 0 #> 10 10 490.3333 2.6666667 501 1.6666667 0.3333333 0.0000000 0 0 #> ds.flow de.flow di.flow dq.flow dh.flow dr.flow a.flow a.e.flow a.i.flow #> 1 0 0 0 0 0 0 0 0 0 #> 2 0 0 0 0 0 0 0 0 0 #> 3 0 0 0 0 0 0 0 0 0 #> 4 0 0 0 0 0 0 0 0 0 #> 5 0 0 0 0 0 0 0 0 0 #> 6 0 0 0 0 0 0 0 0 0 #> 7 0 0 0 0 0 0 0 0 0 #> 8 0 0 0 0 0 0 0 0 0 #> 9 0 0 0 0 0 0 0 0 0 #> 10 0 0 0 0 0 0 0 0 0 #> a.q.flow e.num r.num q.num h.num f.num #> 1 0 NaN NaN NaN NaN NaN #> 2 0 1.0000000 0.0000000 0.0000000 0 0 #> 3 0 0.3333333 0.6666667 0.3333333 0 0 #> 4 0 0.3333333 0.6666667 0.3333333 0 0 #> 5 0 0.6666667 0.6666667 0.3333333 0 0 #> 6 0 1.0000000 1.0000000 0.3333333 0 0 #> 7 0 2.0000000 1.0000000 0.3333333 0 0 #> 8 0 2.6666667 1.0000000 0.3333333 0 0 #> 9 0 5.0000000 1.0000000 0.3333333 0 0 #> 10 0 6.3333333 1.3333333 0.3333333 0 0
# Time-specific standard deviations across simulations as.data.frame(mod, out = "sd")
#> time s.num i.num num se.flow is.flow iq.flow iq2h.flow #> 1 1 0.0000000 0.0000000 0 0.0000000 0.0000000 0.0000000 0 #> 2 2 0.0000000 0.0000000 0 0.0000000 0.0000000 0.0000000 0 #> 3 3 0.0000000 0.5773503 0 0.0000000 0.5773503 0.5773503 0 #> 4 4 0.0000000 0.5773503 0 0.0000000 0.0000000 0.0000000 0 #> 5 5 0.5773503 0.5773503 0 0.5773503 0.0000000 0.0000000 0 #> 6 6 2.3094011 1.0000000 0 0.5773503 0.5773503 0.0000000 0 #> 7 7 3.2145503 1.0000000 0 1.0000000 0.0000000 0.0000000 0 #> 8 8 4.9328829 1.5275252 0 1.7320508 0.0000000 0.0000000 0 #> 9 9 7.0000000 2.0816660 0 1.7320508 0.0000000 0.0000000 0 #> 10 10 10.0166528 3.0550505 0 2.0816660 0.5773503 0.0000000 0 #> hf.flow ds.flow de.flow di.flow dq.flow dh.flow dr.flow a.flow a.e.flow #> 1 0 0 0 0 0 0 0 0 0 #> 2 0 0 0 0 0 0 0 0 0 #> 3 0 0 0 0 0 0 0 0 0 #> 4 0 0 0 0 0 0 0 0 0 #> 5 0 0 0 0 0 0 0 0 0 #> 6 0 0 0 0 0 0 0 0 0 #> 7 0 0 0 0 0 0 0 0 0 #> 8 0 0 0 0 0 0 0 0 0 #> 9 0 0 0 0 0 0 0 0 0 #> 10 0 0 0 0 0 0 0 0 0 #> a.i.flow a.q.flow e.num r.num q.num h.num f.num #> 1 0 0 NA NA NA NA NA #> 2 0 0 0.0000000 0.0000000 0.0000000 0 0 #> 3 0 0 0.5773503 0.5773503 0.5773503 0 0 #> 4 0 0 0.5773503 0.5773503 0.5773503 0 0 #> 5 0 0 1.1547005 0.5773503 0.5773503 0 0 #> 6 0 0 1.7320508 0.0000000 0.5773503 0 0 #> 7 0 0 2.6457513 0.0000000 0.5773503 0 0 #> 8 0 0 3.7859389 0.0000000 0.5773503 0 0 #> 9 0 0 5.2915026 0.0000000 0.5773503 0 0 #> 10 0 0 6.8068593 0.5773503 0.5773503 0 0
# Time-specific quantile values across simulations as.data.frame(mod, out = "qnt", qval = 0.25)
#> time s.num i.num num se.flow is.flow iq.flow iq2h.flow hf.flow ds.flow #> 1 1 500.0 1.0 501 0.0 0.0 0 0 0 0 #> 2 2 499.0 1.0 501 1.0 0.0 0 0 0 0 #> 3 3 499.0 0.5 501 0.0 0.5 0 0 0 0 #> 4 4 499.0 0.5 501 0.0 0.0 0 0 0 0 #> 5 5 498.5 0.5 501 0.0 0.0 0 0 0 0 #> 6 6 497.0 0.5 501 0.0 0.0 0 0 0 0 #> 7 7 495.5 0.5 501 0.5 0.0 0 0 0 0 #> 8 8 494.0 0.5 501 0.0 0.0 0 0 0 0 #> 9 9 490.5 0.5 501 1.0 0.0 0 0 0 0 #> 10 10 486.5 1.0 501 0.5 0.0 0 0 0 0 #> de.flow di.flow dq.flow dh.flow dr.flow a.flow a.e.flow a.i.flow a.q.flow #> 1 0 0 0 0 0 0 0 0 0 #> 2 0 0 0 0 0 0 0 0 0 #> 3 0 0 0 0 0 0 0 0 0 #> 4 0 0 0 0 0 0 0 0 0 #> 5 0 0 0 0 0 0 0 0 0 #> 6 0 0 0 0 0 0 0 0 0 #> 7 0 0 0 0 0 0 0 0 0 #> 8 0 0 0 0 0 0 0 0 0 #> 9 0 0 0 0 0 0 0 0 0 #> 10 0 0 0 0 0 0 0 0 0 #> e.num r.num q.num h.num f.num #> 1 NA NA NA NA NA #> 2 1.0 0.0 0 0 0 #> 3 0.0 0.5 0 0 0 #> 4 0.0 0.5 0 0 0 #> 5 0.0 0.5 0 0 0 #> 6 0.0 1.0 0 0 0 #> 7 0.5 1.0 0 0 0 #> 8 0.5 1.0 0 0 0 #> 9 2.0 1.0 0 0 0 #> 10 2.5 1.0 0 0 0
as.data.frame(mod, out = "qnt", qval = 0.75)
#> time s.num i.num num se.flow is.flow iq.flow iq2h.flow hf.flow ds.flow #> 1 1 500.0 1.0 501 0.0 0.0 0.0 0 0 0 #> 2 2 499.0 1.0 501 1.0 0.0 0.0 0 0 0 #> 3 3 499.0 1.0 501 0.0 1.0 0.5 0 0 0 #> 4 4 499.0 1.0 501 0.0 0.0 0.0 0 0 0 #> 5 5 499.0 1.0 501 0.5 0.0 0.0 0 0 0 #> 6 6 499.0 1.5 501 0.5 0.5 0.0 0 0 0 #> 7 7 498.5 1.5 501 1.5 0.0 0.0 0 0 0 #> 8 8 498.5 2.0 501 1.5 0.0 0.0 0 0 0 #> 9 9 497.0 2.5 501 2.5 0.0 0.0 0 0 0 #> 10 10 496.0 4.0 501 2.5 0.5 0.0 0 0 0 #> de.flow di.flow dq.flow dh.flow dr.flow a.flow a.e.flow a.i.flow a.q.flow #> 1 0 0 0 0 0 0 0 0 0 #> 2 0 0 0 0 0 0 0 0 0 #> 3 0 0 0 0 0 0 0 0 0 #> 4 0 0 0 0 0 0 0 0 0 #> 5 0 0 0 0 0 0 0 0 0 #> 6 0 0 0 0 0 0 0 0 0 #> 7 0 0 0 0 0 0 0 0 0 #> 8 0 0 0 0 0 0 0 0 0 #> 9 0 0 0 0 0 0 0 0 0 #> 10 0 0 0 0 0 0 0 0 0 #> e.num r.num q.num h.num f.num #> 1 NA NA NA NA NA #> 2 1.0 0.0 0.0 0 0 #> 3 0.5 1.0 0.5 0 0 #> 4 0.5 1.0 0.5 0 0 #> 5 1.0 1.0 0.5 0 0 #> 6 1.5 1.0 0.5 0 0 #> 7 3.0 1.0 0.5 0 0 #> 8 4.0 1.0 0.5 0 0 #> 9 7.0 1.0 0.5 0 0 #> 10 9.0 1.5 0.5 0 0