make_scamplot: Create Prediction Plot of SCAM

Description Usage Arguments Value Examples

View source: R/make_scamplot.R

Description

This function will generate a prediction plot for logistic, shape constrained additive models. The package scam will fit the model specified by the variables supplied in this function, and a prediction plot with a shaded confidence interval will be generated from the data. Shape constraints include monotonic increasing and decreasing, convex increasing, convex decreasing, concave increasing, and concave decreasing.

Usage

1
2
3
4
5
6
7
8
9
make_scamplot(
  data,
  y,
  smooth_terms,
  linear_terms,
  shape_type,
  type,
  title = "Prediction Plot"
)

Arguments

data

- data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model

y

- string containing name of depednent variable in model

smooth_terms

- vector of strings containing names of independent variables to be fit as splines in the model

linear_terms

- vector of strings containing names of independent variables to be fit as linear terms in the model

shape_type

- vector of strings containing the shape constraints for the spline (in the same order as smooth_terms). Can only contain shape constraints that the scam function supports

type

- string indicating "link" or "response"

title

- optional string containing title of plot

Value

None

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#Load the packages required
library(HRW)

#Load the data
data(BostonMortgages)

#Assign variables to be supplied to function
y = "deny"
smooth_terms = c("dir", "lvr")
BostonMortgages$ccs = as.factor(BostonMortgages$ccs)
linear_terms = c("ccs", "black", "pbcr", "self", "single")
shape_type = c("cr", "mpi")

#Use package to build predictive plot
make_scamplot(BostonMortgages, y, smooth_terms, linear_terms, shape_type, type = "link")
make_scamplot(BostonMortgages, y, smooth_terms, linear_terms, shape_type, type = "response")

christithomp/scamplot documentation built on Dec. 10, 2019, 11:33 a.m.