Learn R Programming

schwartz97 (version 0.0.6)

resid-futures: Extract Model Residuals

Description

Function to extract model residuals from schwartz2f.fit-objects.

Usage

"resid"(object, data, ttm, type = c("filter", "filter.std", "real"))

Arguments

object
A schwartz2f.fit-object returned from schwartz2f.fit.
data
A matrix with futures prices.
ttm
A matrix with the corresponding time to maturity (see Details).
type
What kind of residuals shall be returned (see Details).

Value

A matrix containing the residuals.

Details

If type == "filter", then the residuals from the measurement equation are returned. If type == "filter.std", standardized residuals from the measurement equation are returned (note that these residuals should be standard multivariate normal). If type == "real", the difference between the observed futures prices and the fitted values (see fitted) are returned.

The model and its parameters are described in the Details section of the schwartz2f-class documentation and in the package vignette Technical Document.

See Also

fit.schwartz2f, schwartz2f.fit-class, fitted.

Examples

Run this code
# data(futures)
# 
# ## Estimate parameters for live.cattle data.
# ## (little precision required with reltol = 1e-3)
# fit.obj <- fit.schwartz2f(futures$live.cattle$price, futures$live.cattle$ttm / 260,
#                           deltat = 1 / 260,
#                           control = list(maxit = 100, reltol = 1e-3))
# 
# ## Standardized residuals 
# resid.std <- resid(fit.obj, data = futures$live.cattle$price, ttm =
#                      futures$live.cattle$ttm / 260, type = "filter.std")
# acf(resid.std, na.action = na.pass) # ...are not independent
# 
# ## Real differences
# resid.real <- resid(fit.obj, data = futures$live.cattle$price, ttm =
#                       futures$live.cattle$ttm / 260, type = "real")
# 
# plot(as.ts(resid.real / futures$live.cattle$price)) # ...are 'relatively' accurate.

Run the code above in your browser using DataLab