plot,SimInf_model-method {SimInf} | R Documentation

## Display the outcome from a simulated trajectory

### Description

Plot either the median and the quantile range of the counts in all nodes, or plot the counts in specified nodes.

### Usage

    ## S4 method for signature 'SimInf_model'
    plot(x, legend = NULL, col = NULL,
      lty = NULL, lwd = 2, compartments = NULL, node = NULL,
      range = 0.5, ...)

### Arguments

`x` | The `model` to plot
`legend` | The character vector to appear in the legend. Default is to use the names of the compartments.
`col` | The plotting color for each compartment. Default is black.
`lty` | The line type for each compartment. Default is the sequence: 1=solid, 2=dashed, 3=dotted, 4=dotdash, 5=longdash, 6=twodash.
`lwd` | The line width for each compartment. Default is 2.
`compartments` | Character vector with the compartments in the model to include in the plot. Default is `NULL` i.e. include all compartments in the model.
`node` | indices specifying the nodes to include when plotting data. Plot one line for each node. Default (`node = NULL`) is to extract data from all nodes and plot the median count for the specified compartments.
`range` | show the quantile range of the count in each compartment. Default is to show the interquartile range i.e. the middle 50% of the count in transparent color. The median value is shown in the same color. Use `range = 0.95` to show the middle 95% of the count. To display individual lines for each node, specify `range = FALSE`.
`...` | Additional arguments affecting the plot produced.

### Examples

    ## Not run:
    ## Create an 'SIR' model with 100 nodes and initialise
    ## it with 990 susceptible individuals and 10 infected
    ## individuals in each node. Run the model over 100 days.
    model <- SIR(u0 = data.frame(S = rep(990, 100),
                                 I = rep(10, 100),
                                 R = rep(0, 100)),
                 tspan = 1:100,
                 beta = 0.16,
                 gamma = 0.077)

    ## Run the model and save the result.
    result <- run(model)

    ## Plot the median and interquartile range of the number
    ## of susceptible, infected and recovered individuals.
    plot(result)

    ## Plot the median and the middle 95\% quantile range of the
    ## number of susceptible, infected and recovered individuals.
    plot(result, range = 0.95)

    ## Plot the median and interquartile range of the  number
    ## of infected individuals.
    plot(result, compartments = "I")

    ## Plot the number of susceptible, infected
    ## and recovered individuals in the first
    ## three nodes.
    plot(result, node = 1:3, range = FALSE)

    ## Plot the number of infected individuals in the first node.
    plot(result, compartments = "I", node = 1, range = FALSE)

    ## End(Not run)

[Package SimInf version 6.3.0 Index]