Learn R Programming

PSTR (version 2.0.0)

plot_response: Plot the expected response against selected variables

Description

This function plots the effect-adjusted expected response for selected nonlinear variables in a PSTR model.

Usage

plot_response(
  obj,
  vars,
  log_scale = FALSE,
  length.out = 20,
  color = "blue",
  size = 1.5
)

Value

A named list of ggplot2 (curve) and/or

plotly (surface) objects.

Arguments

obj

An object of class "PSTR".

vars

Integer vector of column indices from the nonlinear part.

log_scale

Logical scalar or length-2 vector indicating whether to use log scale for the regressor and/or transition variable.

length.out

Scalar or length-2 numeric vector controlling grid size.

color

Line colour.

size

Line width.

Details

If the selected variable differs from the transition variable, a 3-D surface of $$(\beta_{k,0} + \beta_{k,1} g(q;\gamma,c)) z_{k}$$ is plotted against \(z_k\) and the transition variable.

If the selected variable coincides with the transition variable, a curve is plotted instead.

In addition to the exported function plot_response(obj = ...), the same functionality is available as an R6 method via obj$plot_response(...).

Examples

Run this code
# \donttest{
pstr <- NewPSTR(Hansen99, dep = "inva", indep = 4:20,
                indep_k = c("vala","debta","cfa","sales"),
                tvars = c("vala","debta","cfa","sales"), iT = 14)

pstr <- EstPSTR(use = pstr, im = 1, iq = 1,
                useDelta = TRUE, par = c(.63,0), method = "CG")

# Exported interface
ret <- plot_response(pstr, vars = 1:4)

# R6 method
ret2 <- pstr$plot_response(vars = 1:4)
# }

Run the code above in your browser using DataLab