Learn R Programming

StatMeasures (version 1.0)

actvspred: Comparison of actual and predicted linear response

Description

Takes in actual, predicted linear response and quantile value, and returns average actual and predicted response in each quantile

Usage

actvspred(y, yhat, n)

Arguments

y
actual linear response
yhat
predicted linear response
n
quantiles to be created for comparison

Value

a data.frame with average actual and predicted response in each quantile

Details

actvspred function divides the data into n (given as input by the user) quantiles and computes mean of y and yhat for each quantile. All NA's in n, y and yhat are removed for calculation.

The function also plots a line chart of average actual response and average predicted response over n quantiles. This plot can be used to visualize how close both the lines are.

See Also

mape, splitdata

Examples

Run this code
# A 'data.frame' with y and yhat
df <- data.frame(y = c(1, 2, 3, 6, 8, 10, 15),
                 yhat = c(1.2, 2.5, 3.3, 6.9, 9.3, 6.5, 12.3))

# Get actual vs predicted table
ACTVSPRED <- actvspred(y = df[, 'y'], yhat = df[, 'yhat'], n = 5)

Run the code above in your browser using DataLab