Learn R Programming

capn (version 2.0.0)

plotgen: Plot Generator for Shadow Price and Value Function

Description

Generate plots of shadow prices and value functions based on simulation results from vsim, psim, or pdotsim.

Usage

plotgen(simres, ftype = NULL, whichs = NULL, tvar = NULL,
        xlabel = NULL, ylabel = NULL)

Value

Produces a plot of shadow prices, value function, and optionally W-values. The function is called for its side effect of producing a plot.

Arguments

simres

A simulation result from vsim, psim, or pdotsim.

ftype

Plot type. If NULL (default) or "p", plot shadow price. If "vw", plot value function (and W-value if available).

whichs

An integer specifying which stock to plot in multi-stock cases. Must satisfy 1 <= whichs <= number of stocks. If NULL (default), the first stock is used.

tvar

Optional time variable. If provided, the x-axis is time instead of stock.

xlabel

Optional character string for the x-axis label. Defaults to "Stock" or "Time" depending on tvar.

ylabel

Optional character vector for y-axis labels. For ftype = "p", provide one label. For ftype = "vw", provide one or two labels for the value function and W-value, respectively.

Details

This function produces one-dimensional plots for:

  • Shadow price versus stock

  • Shadow price versus time

  • Value function versus stock

  • Value function versus time

  • Value function and W-value versus stock

  • Value function and W-value versus time

The specific plot depends on the combination of ftype, whichs, and tvar.

See Also

GOM pdotsim psim, vsim, vaprox.pindyck

Examples

Run this code
## 1-D Reef-fish example: see Fenichel and Abbott (2014)
data("GOM")

param <- GOM$param
simData <- GOM$simData

Aspace <- aproxdef(param$order, param$lowerK, param$upperK, param$delta)

pC <- paprox(
  Aspace,
  simData$stock,
  simData$sdot,
  simData$dsdotds,
  simData$dwds
)

## Without providing W-value
GOMSimP <- psim(
  pC,
  simData$stock
)

## With W-value
GOMSimP2 <- psim(pC,
  simData$stock,
  simData$profit,
  simData$sdot)

## Shadow price vs stock
plotgen(GOMSimP)
plotgen(GOMSimP, ftype = "p")
plotgen(GOMSimP,
        xlabel = "Stock Size, S",
        ylabel = "Shadow Price (USD/kg)")

## Value function and W-value vs stock
plotgen(GOMSimP2, ftype = "vw")
plotgen(GOMSimP2,
        ftype  = "vw",
        xlabel = "Stock Size, S",
        ylabel = c("Value Function", "Profit"))

Run the code above in your browser using DataLab