schwartz97fitted: Extract Model Fitted Values

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Function to extract fitted values from schwartz2f.fit-objects.

Usage

1
2
## S4 method for signature 'schwartz2f.fit'
fitted(object, data, ttm)

Arguments

object

A schwartz2f.fit-object returned from schwartz2f.fit.

data

A matrix with futures prices.

ttm

A matrix with the corresponding times to maturity (see Details).

Details

The elements of data and ttm have the following interpretation: data[i,j] denotes the futures price whose time to maturity was ttm[i,j] when it was observed. The unit of ttm was defined by the argument deltat of fit.schwartz2f.

Value

A matrix containing the fitted values of the same dimension as data.

Author(s)

Philipp Erb, David Luethi, Juri Hinz

See Also

fit.schwartz2f, schwartz2f.fit-class, resid.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# data(futures)
# 
# ## Estimate parameters for lumber data. Fit only 'mu', 'sigmaS',
# ## 'sigmaE', and 'rho' (and stop after 100 iterations).
# fit.obj <- fit.schwartz2f(futures$lumber$price, futures$lumber$ttm / 260,
#                           opt.pars = c(s0 = FALSE, delta0 = FALSE, mu = TRUE, 
#                                        sigmaS = TRUE, kappa = FALSE, alpha = FALSE, 
#                                        sigmaE = TRUE, rho = TRUE, lambda = FALSE),
#                           alpha = 0, kappa = 1.2, lambda = 0,
#                           deltat = 1 / 260, control = list(maxit = 100))
# fit.obj
# 
# ## Get the fitted values
# fitted.futures <- fitted(fit.obj, futures$lumber$price, futures$lumber$ttm / 260)
# 
# par(mfrow = c(1, 3))
# ## Plot futures prices
# plot(as.ts(futures$lumber$price), plot.type = "single", ylab = "Futures prices",
#      col = gray(seq(0.1, 0.9, length = 4)))
# ## Plot fitted values
# plot(as.ts(fitted.futures), plot.type = "single", ylab = "Fitted values",
#      col = gray(seq(0.1, 0.9, length = 4)))
# ## Plot relative difference
# plot(as.ts((fitted.futures - futures$lumber$price) / fitted.futures), plot.type = "single",
#      ylab = "Relative difference", col = gray(seq(0.1, 0.9, length = 4)))

schwartz97 documentation built on May 29, 2017, 12:18 p.m.