resiPlot: resiPlot

Description Usage Arguments Details Author(s) Examples

Description

This function assess the residual using given actual and predicted values.

Usage

1
resiPlot(act,pred,weight=NULL,exposure=NULL,bucket=20)

Arguments

act

numerical vector for actual observation.

pred

numerical vector for model preidctions. It must have the same length as act.

weight

numerical vector to give weight to observations.

exposure

numerical vector to give exposure to observations.

bucket

Integer. It specifies the number of bucket of the AvsE plot.

residualFun

Character. Name of residual function. The first parameter must be actual, and second parameter must be predictions. By default, residual function is difference between 'act' and 'pred'.

...

other parameters for 'residualFun' specified.

Details

In previous version of this function, the residual in this function is defined as: Residual = actual - predicted. 'resi' or 'reisdual' function from 'stats' package are not used because this function will be used for much wider model assess (e.g. 'randomFoest', 'gbm'), and 2 functions mentioned above can only applied to 'glm' and 'lm'.

This function will give 2 plots: AvsE plot: The average actual and predicted value for each bucket, with a diagnal line for comparison. Residual vs Prediction: This plot is used to assess the baise and heterogeneity

Author(s)

Sixiang Hu

Examples

1
2
3
4
5
6
7
set.seed(1L)
act <- rgamma(10000,1)
pred <- act + rnorm(10000)
signDeviance <- function(y,mu){
  sign(y-mu)*sqrt(residualDeviance(y,mu,family = "gamma"))
}
resiPlot(act,pred,residualFun = "signDeviance")

SixiangHu/DataMan documentation built on May 9, 2019, 1:48 p.m.