1\name{garchFit} 2 3 4\alias{garchFit} 5\alias{garchKappa} 6 7 8\title{Univariate GARCH Time Series Fitting} 9 10 11\description{ 12 13 Estimates the parameters of an univariate ARMA-GARCH/APARCH process. 14} 15 16 17\usage{ 18garchFit(formula = ~ garch(1, 1), data = fGarch::dem2gbp, 19 init.rec = c("mci", "uev"), 20 delta = 2, skew = 1, shape = 4, 21 cond.dist = c("norm", "snorm", "ged", "sged", "std", "sstd", 22 "snig", "QMLE"), 23 include.mean = TRUE, include.delta = NULL, include.skew = NULL, 24 include.shape = NULL, leverage = NULL, trace = TRUE, 25 %recursion = c("internal", "filter", "testing"), 26 algorithm = c("nlminb", "lbfgsb", "nlminb+nm", "lbfgsb+nm"), 27 hessian = c("ropt", "rcd"), control = list(), 28 title = NULL, description = NULL, \dots) 29 30garchKappa(cond.dist = c("norm", "ged", "std", "snorm", "sged", "sstd", 31 "snig"), gamma = 0, delta = 2, skew = NA, shape = NA) 32} 33 34 35\arguments{ 36 37 %\item{recursion}{ 38 % a string parameter that determines the recursion used for calculating 39 % the maximum log-likelihood function. 40 % Allowed values are ... 41 %} 42 \item{algorithm}{ 43 a string parameter that determines the algorithm used for maximum 44 likelihood estimation. 45 % Allowed values are 46 % \code{"nmfb"}, 47 % \code{"sqp"}, 48 % \code{"nlminb"}, and 49 % \code{"bfgs"} where the third is the default 50 % setting. \code{"mnfb"} is a fully Fortran implemented and extremely 51 % fast version of the R-coded \code{"nlminb"} algorithm. 52 } 53 \item{cond.dist}{ 54 a character string naming the desired conditional distribution. 55 Valid values are \code{"dnorm"}, \code{"dged"}, \code{"dstd"}, 56 \code{"dsnorm"}, \code{"dsged"}, \code{"dsstd"} and 57 \code{"QMLE"}. The default value is the normal distribution. See 58 Details for more information. 59 } 60 \item{control}{ 61 control parameters, the same as used for the functions from 62 \code{nlminb}, and 'bfgs' and 'Nelder-Mead' from \code{optim}. 63 } 64 \item{data}{ 65 an optional timeSeries or data frame object containing the variables 66 in the model. If not found in \code{data}, the variables are taken 67 from \code{environment(formula)}, typically the environment from which 68 \code{armaFit} is called. If \code{data} is an univariate series, then 69 the series is converted into a numeric vector and the name of the 70 response in the formula will be neglected. 71 } 72 \item{delta}{ 73 a numeric value, the exponent \code{delta} of the variance recursion. 74 By default, this value will be fixed, otherwise the exponent will be 75 estimated together with the other model parameters if 76 \code{include.delta=FALSE}. 77 } 78 \item{description}{ 79 a character string which allows for a brief description. 80 } 81 \item{formula}{ 82 formula object describing the mean and variance equation of the 83 ARMA-GARCH/APARCH model. A pure GARCH(1,1) model is selected 84 when e.g. \code{formula=~garch(1,1)}. To specify for example an 85 ARMA(2,1)-APARCH(1,1) use \code{formula = ~arma(2,1)+apaarch(1,1)}. 86 } 87 \item{gamma}{ 88 APARCH leverage parameter entering into the formula for calculating 89 the expectation value. 90 } 91 % \item{hessian}{ 92 % a string denoting how the Hessian matrix should be evaluated, 93 % either \code{hessian ="cda"}, the default, or \code{"fda"}. 94 % The forward difference approximation, \code{"fda"} consumes less 95 % computer time, but is usually not as precise as approximations 96 % that use central difference approximation, \code{"cda"}, formula. 97 % } 98 \item{hessian}{ 99 a string denoting how the Hessian matrix should be evaluated, 100 either \code{hessian ="rcd"}, or \code{"ropt"}, the default, 101 \code{"rcd"} is a central difference approximation implemented 102 in R and \code{"ropt"} use the internal R function \code{optimhess}. 103 } 104 \item{include.delta}{ 105 a logical flag which determines if the parameter for the recursion 106 equation \code{delta} will be estimated or not. If 107 \code{include.delta=FALSE} then the shape parameter will be kept 108 fixed during the process of parameter optimization. 109 } 110 \item{include.mean}{ 111 this flag determines if the parameter for the mean will be estimated 112 or not. If \code{include.mean=TRUE} this will be the case, otherwise 113 the parameter will be kept fixed durcing the process 114 of parameter optimization. 115 } 116 \item{include.shape}{ 117 a logical flag which determines if the parameter for the shape 118 of the conditional distribution will be estimated or not. If 119 \code{include.shape=FALSE} then the shape parameter will be kept 120 fixed during the process of parameter optimization. 121 } 122 \item{include.skew}{ 123 a logical flag which determines if the parameter for the skewness 124 of the conditional distribution will be estimated or not. If 125 \code{include.skew=FALSE} then the skewness parameter will be kept 126 fixed during the process of parameter optimization. 127 } 128 \item{init.rec}{ 129 a character string indicating the method how to initialize the 130 mean and varaince recursion relation. 131 } 132 \item{leverage}{ 133 a logical flag for APARCH models. Should the model be leveraged? 134 By default \code{leverage=TRUE}. 135 } 136 \item{shape}{ 137 a numeric value, the shape parameter of the conditional distribution. 138 } 139 \item{skew}{ 140 a numeric value, the skewness parameter of the conditional 141 distribution. 142 } 143 \item{title}{ 144 a character string which allows for a project title. 145 } 146 \item{trace}{ 147 a logical flag. Should the optimization process of fitting the 148 model parameters be printed? By default \code{trace=TRUE}. 149 } 150 \item{\dots}{ 151 additional arguments to be passed. 152 } 153 154} 155 156\value{ 157 158 \code{garchFit} \cr 159 \cr 160 returns a S4 object of class \code{"fGARCH"} with the following slots: 161 162 \item{@call}{ 163 the call of the \code{garch} function. 164 } 165 \item{@formula}{ 166 a list with two formula entries, one for the mean and the other 167 one for the variance equation. 168 } 169 \item{@method}{ 170 a string denoting the optimization method, by default the 171 returneds string is "Max Log-Likelihood Estimation". 172 } 173 \item{@data}{ 174 a list with one entry named \code{x}, containing the data of 175 the time series to be estimated, the same as given by the 176 input argument \code{series}. 177 } 178 \item{@fit}{ 179 a list with the results from the parameter estimation. The entries 180 of the list depend on the selected algorithm, see below. 181 } 182 \item{@residuals}{ 183 a numeric vector with the (raw, unstandardized) residual values. 184 } 185 \item{@fitted}{ 186 a numeric vector with the fitted values. 187 } 188 \item{@h.t}{ 189 a numeric vector with the conditional variances 190 (\eqn{h_t = \sigma_t^\delta}{h.t = sigma.t^delta}). 191 } 192 \item{@sigma.t}{ 193 a numeric vector with the conditional standard deviation. 194 } 195 \item{@title}{ 196 a title string. 197 } 198 \item{@description}{ 199 a string with a brief description. 200 } 201 202 The entries of the @fit slot show the results from the 203 optimization. 204 205} 206 207 208\details{ 209 210 \code{"QMLE"} stands for Quasi-Maximum Likelihood Estimation, which 211 assumes normal distribution and uses robust standard errors for 212 inference. Bollerslev and Wooldridge (1992) proved that if the mean 213 and the volatility equations are correctly specified, the QML 214 estimates are consistent and asymptotically normally 215 distributed. However, the estimates are not efficient and \dQuote{the 216 efficiency loss can be marked under asymmetric ... distributions} 217 (Bollerslev and Wooldridge (1992), p. 166). The robust 218 variance-covariance matrix of the estimates equals the (Eicker-White) 219 sandwich estimator, i.e. 220 221 \deqn{V = H^{-1} G^{\prime} G H^{-1},}{V = H^(-1) G' G H^(-1),} 222 223 where \eqn{V}{V} denotes the variance-covariance matrix, \eqn{H}{H} 224 stands for the Hessian and \eqn{G}{G} represents the matrix of 225 contributions to the gradient, the elements of which are defined as 226 227 \deqn{G_{t,i} = \frac{\partial l_{t}}{\partial \zeta_{i}},}{% 228 G_{t,i} = derivative of l_{t} w.r.t. zeta_{i},} 229 230 where \eqn{t_{t}}{l_{t}} is the log likelihood of the t-th observation 231 and \eqn{\zeta_{i}}{zeta_{i}} is the i-th estimated parameter. See 232 sections 10.3 and 10.4 in Davidson and MacKinnon (2004) for a more 233 detailed description of the robust variance-covariance matrix. 234 235} 236 237 238\references{ 239 240 ATT (1984); 241 \emph{PORT Library Documentation}, 242 http://netlib.bell-labs.com/netlib/port/. 243 244 Bera A.K., Higgins M.L. (1993); 245 \emph{ARCH Models: Properties, Estimation and Testing}, 246 J. Economic Surveys 7, 305--362. 247 248 Bollerslev T. (1986); 249 \emph{Generalized Autoregressive Conditional Heteroscedasticity}, 250 Journal of Econometrics 31, 307--327. 251 252 Bollerslev T., Wooldridge J.M. (1992); 253 \emph{Quasi-Maximum Likelihood Estimation and Inference in Dynamic 254 Models with Time-Varying Covariance}, 255 Econometric Reviews 11, 143--172. 256 257 Byrd R.H., Lu P., Nocedal J., Zhu C. (1995); 258 \emph{A Limited Memory Algorithm for Bound Constrained Optimization}, 259 SIAM Journal of Scientific Computing 16, 1190--1208. 260 261 Davidson R., MacKinnon J.G. (2004); 262 \emph{Econometric Theory and Methods}, 263 Oxford University Press, New York. 264 265 Engle R.F. (1982); 266 \emph{Autoregressive Conditional Heteroscedasticity with Estimates 267 of the Variance of United Kingdom Inflation}, 268 Econometrica 50, 987--1008. 269 270 Nash J.C. (1990); 271 \emph{Compact Numerical Methods for Computers}, 272 Linear Algebra and Function Minimisation, 273 Adam Hilger. 274 275 Nelder J.A., Mead R. (1965); 276 \emph{A Simplex Algorithm for Function Minimization}, 277 Computer Journal 7, 308--313. 278 279 Nocedal J., Wright S.J. (1999); 280 \emph{Numerical Optimization}, 281 Springer, New York. 282 283} 284 285 286\author{ 287 288 Diethelm Wuertz for the Rmetrics \R-port,\cr 289 R Core Team for the 'optim' \R-port,\cr 290 Douglas Bates and Deepayan Sarkar for the 'nlminb' \R-port,\cr 291 Bell-Labs for the underlying PORT Library,\cr 292 Ladislav Luksan for the underlying Fortran SQP Routine, \cr 293 Zhu, Byrd, Lu-Chen and Nocedal for the underlying L-BFGS-B Routine. 294 295} 296 297 298\examples{ 299## UNIVARIATE TIME SERIES INPUT: 300 # In the univariate case the lhs formula has not to be specified ... 301 302 # A numeric Vector from default GARCH(1,1) - fix the seed: 303 N = 200 304 x.vec = as.vector(garchSim(garchSpec(rseed = 1985), n = N)[,1]) 305 garchFit(~ garch(1,1), data = x.vec, trace = FALSE) 306 307 # An univariate timeSeries object with dummy dates: 308 x.timeSeries = dummyDailySeries(matrix(x.vec), units = "GARCH11") 309 garchFit(~ garch(1,1), data = x.timeSeries, trace = FALSE) 310 311\dontrun{ 312 # An univariate zoo object: 313 x.zoo = zoo(as.vector(x.vec), order.by = as.Date(rownames(x.timeSeries))) 314 garchFit(~ garch(1,1), data = x.zoo, trace = FALSE) 315} 316 317 # An univariate "ts" object: 318 x.ts = as.ts(x.vec) 319 garchFit(~ garch(1,1), data = x.ts, trace = FALSE) 320 321## MULTIVARIATE TIME SERIES INPUT: 322 # For multivariate data inputs the lhs formula must be specified ... 323 324 # A numeric matrix binded with dummy random normal variates: 325 X.mat = cbind(GARCH11 = x.vec, R = rnorm(N)) 326 garchFit(GARCH11 ~ garch(1,1), data = X.mat) 327 328 # A multivariate timeSeries object with dummy dates: 329 X.timeSeries = dummyDailySeries(X.mat, units = c("GARCH11", "R")) 330 garchFit(GARCH11 ~ garch(1,1), data = X.timeSeries) 331 332\dontrun{ 333 # A multivariate zoo object: 334 X.zoo = zoo(X.mat, order.by = as.Date(rownames(x.timeSeries))) 335 garchFit(GARCH11 ~ garch(1,1), data = X.zoo) 336} 337 338 # A multivariate "mts" object: 339 X.mts = as.ts(X.mat) 340 garchFit(GARCH11 ~ garch(1,1), data = X.mts) 341 342## MODELING THE PERCENTUAL SPI/SBI SPREAD FROM LPP BENCHMARK: 343 344 X.timeSeries = as.timeSeries(data(LPP2005REC)) 345 X.mat = as.matrix(x.timeSeries) 346 \dontrun{X.zoo = zoo(X.mat, order.by = as.Date(rownames(X.mat)))} 347 X.mts = ts(X.mat) 348 garchFit(100*(SPI - SBI) ~ garch(1,1), data = X.timeSeries) 349 # The remaining are not yet supported ... 350 # garchFit(100*(SPI - SBI) ~ garch(1,1), data = X.mat) 351 # garchFit(100*(SPI - SBI) ~ garch(1,1), data = X.zoo) 352 # garchFit(100*(SPI - SBI) ~ garch(1,1), data = X.mts) 353 354## MODELING HIGH/LOW RETURN SPREADS FROM MSFT PRICE SERIES: 355 356 X.timeSeries = MSFT 357 garchFit(Open ~ garch(1,1), data = returns(X.timeSeries)) 358 garchFit(100*(High-Low) ~ garch(1,1), data = returns(X.timeSeries)) 359} 360 361 362\keyword{models} 363 364