Learn R Programming

capm (version 0.3)

PlotModels: Plot results of capm model functions

Description

Plot results of one of the following functions: SolveIASA, SolveSI or SolveTC.

Usage

PlotModels(model.out = NULL, variable = NULL, col = "red",
  col1 = c("cadetblue1", "yellow", "red"), col2 = c("blue", "darkgreen",
  "darkred"), x.label = "Years", y.label = NULL,
  scen.label = "Im = (__ * owned carrying capacity)", leg.label = NULL,
  pop = NULL)

Arguments

model.out
output of one of the function previously mentioned.
variable
string to specify the variable to be ploted.

For SolveSI function:

"n" (population size).

"q" (proportion of sterilized animals).

For SolveIASA

col
string indicating the color of ploted line, when s.range is NULL.
col1
character vector indicating the color of lowest (highest) population sizes (proportion of sterilized animals), when s.range is not
col2
character vector indicating the color of highest (lowest) population sizes (proportion of sterilized animals), when s.range is not
x.label
string with the name of x axis.
y.label
string with the name of y axis.
leg.label
string with the name of legend, for plots of SolveIASA output.
scen.label
string with the name of scenarios of SolveIASA output, determined by the immigartion rates. Within the string, use the expression __ in the location where you want to appear the value of the immig
pop
value indicating the output of SolveIASA to be ploted. When NULL (default), plots for owned and stray populations under scenarios created by immigartion rate are created. If 1

Details

Font size of saved plots is usually different to the font size seen in graphic browsers. Before changing font sizes, see the final result in saved (or preview) plots.

Other details of the plot can be modifyed using appropriate functions from ggplot2 package.

References

Chang W (2012). R Graphics Cookbook. O'Reilly Media, Inc.

http://oswaldosantos.github.io/capm

See Also

plot.deSolve.

Examples

Run this code
#####################
## SolveIASA model ##
#####################

## Parameters and intial conditions.
pars.solveiasa = c(
   b1 = 21870.897, b2 = 4374.179,
   df1 = 0.104, dm1 = 0.098, df2 = 0.1248, dm2 = 0.1176,
   sf1 = 0.069, sf2 = 0.05, sm1 = 0.028, sm2 = 0.05,
   k1 = 98050.49, k2 = 8055.456, h1 = 1, h2 = .5,
   ab = 0.054, ad = 0.1, v = 0.2, z = 0.1)

init.solveiasa = c(
   f1 = 33425.19, fs1 = 10864.901,
   m1 = 38038.96, ms1 = 6807.759,
   f2 = 3342.519, fs2 = 108.64901,
   m2 = 3803.896, ms2 = 68.07759)


# Solve for point estimates.
solveiasa.pt <- SolveIASA(pars = pars.solveiasa,
                          init = init.solveiasa,
                          time = 0:10, method = 'rk4')

# Solve for parameter ranges.
solveiasa.rg <- SolveIASA(pars = pars.solveiasa,
                          init = init.solveiasa,
                          time = 0:10,
                          s.range = seq(0, .4, l = 15),
                          ab.range = c(0, .2),
                          ad.range = c(0, .2),
                          im.range = c(0, .1),
                          method = 'rk4')

## Plot stray population sizes using point estimates
# Uncomment the following line:
# PlotModels(solveiasa.pt, variable = "ns2")

## Plot all scenarios and change the label for the scenarios.
# Uncomment the following line:
# PlotModels(solveiasa.rg, variable = 'ns', scen.label = 'Im = (__ * de la capacidad de carga)')

Run the code above in your browser using DataLab