Learn R Programming

PSTR (version 2.0.0)

plot_coefficients: Plot coefficients, standard errors, and p-values against the transition variable

Description

This function plots three curves against the transition variable: the coefficient function, its standard error, and the corresponding p-value.

Usage

plot_coefficients(obj, vars, length.out = 100, color = "blue", size = 1.5)

Value

A named list of ggplot2 objects.

Arguments

obj

An object of class "PSTR".

vars

A vector of column indices or variable names from the nonlinear part.

length.out

Number of grid points over the transition variable.

color

Line colour.

size

Line width.

Details

For each selected variable \(j\), the curves are $$f_1(x) = \beta_{0j} + \beta_{1j} g(x;\gamma,c)$$ $$f_2(x) = se\{f_1(x)\}$$ $$f_3(x) = 1 - \Pr\left\{X < \left[f_1(x)/f_2(x)\right]^2\right\}$$ where \(X\) follows a chi-square distribution with one degree of freedom.

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

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 function
ret <- plot_coefficients(pstr, vars = 1:4)

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

Run the code above in your browser using DataLab