Learn R Programming

accrued (version 1.2)

accruedErrors: Function to calculate error between partially accrued data and final data

Description

This function returns the error between partially accrued data and the final data by lag.

Usage

accruedErrors(x, y=NULL, func=NULL)

Arguments

x
Object of the accrued class.
y
Optional second object of the accrued class.
func
Error function to calcuate errors. Default behavior depends on whether one or two objects are included in the call. The first argument is the final value of the indicator and the second argument is the lagged value of the indicator.

Value

  • An object of the accruedErrors class which consists of a matrix with columns "EncounterDate", "Lag" and "Error".

Details

If only x is specified, calculates the error between each lag value and the final value for each encounter date. If both x and y are specified, then the error is calculated for the ratio y/x (except in that $X/0$ is set to NA for all $X$). The deault error function in only x is specified is the difference between the lag value and the corresponding final value. The default error function if both are specified is the difference in logs of the two values.

See Also

data.accrued, plot.accruedErrors, summary.accruedErrors

Examples

Run this code
data(accruedDataExample)	# simulated accrued data 
	dat <- data.accrued(accruedDataExample)	
	errors <- accruedErrors(dat)
	plot(errors)
	errors <- accruedErrors(dat, func = function(a,b) {sqrt(a) - sqrt(b)} )
	plot(errors)
	
	data(accruedDataILIExample)	# simulated accrued data - ILI counts
	dat2 = data.accrued(accruedDataILIExample)
	errors <- accruedErrors(dat, dat2)
	plot(errors)

Run the code above in your browser using DataLab