Formulas - PowerPoint PPT Presentation

About This Presentation
Title:

Formulas

Description:

Formulas A formula is a (possibly) nonlinear mathematical relationship. A SERIES is a vector of numbers Formulas versus SET: You can use SET to create the variable y as: – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 18
Provided by: WaltE181
Category:
Tags: formulas | garch | model

less

Transcript and Presenter's Notes

Title: Formulas


1
Formulas
  • A formula is a (possibly) nonlinear mathematical
    relationship. A SERIES is a vector of numbers
  • Formulas versus SET
  • You can use SET to create the variable y as
  • SET y 2 .5x2
  • This creates a new series equal to two plus ½ of
    the square of x
  • A FORMULA can be used to express the mathematical
    relationship
  • FRML y a bxr
  • No variable is createdthe three parameters can
    now be estimated

2
NNLS
  • There are 4 statements required for nonlinear
    least squares
  • indicate the coefficient to be estimated
  • Create the FRML to estimate
  • Initialize the coefficients
  • NLLS(FRMLname ,OPTIONS) depvar start end
    residuals coeffs
  • Standard Regression Options
  • METHODGAUSS/SIMPLEX/GENETIC
  • robusterrors
  • iterations
  • Defined Variables
  • Those of LINREG
  • FUNCVAL

3
Example 1
Example 1 Let x and y be series and suppose you
want to estimate a, b, and r. nonlin a b r frml
z a bxr compute a .4, b -.3, c
2 nlls(frmlz) y
4
Since the disturbance term is additive, you
cannot simply take the log of each side and
estimate the equation using OLS. However,
nonlinear least squares allows you to estimate ?
and ? without transforming the variables. In
RATS, you use the following structure to estimate
a model using nonlinear least squares   NONLIN
list of parameters to be estimated FRML formula
name the equation to be estimated COMPUTE
initial guesses for the parameters NNLS(FRMLformu
la name) dependent variable   For the example at
hand, you could use   nonlin alpha beta frml
equation_1 y alphaxbeta com alpha 1.0 ,
beta 0.5 nlls(frml equation_1) y If the
model had the form yt ?xt? ?t where ?t is
log-normal, it would be appropriate to estimate
the regression in logs using LINREG.
5
NLLS(frmlformula name, other options) depvar
start end residuals coeffs   where
depvar Dependent variable used on the FRML
instruction. start end Range to
estimate. residuals Series to store the
residuals (Optional). coeffs Series to store
the estimated coefficients (Optional).   The
principal options are   METHOD
GAUSS/SIMPLEX/GENETIC. GAUSS requires a twice
differential function. USE SIMPLEX if you have
convergence problems. It is possible to use
SIMPLEX or GENETIC to refine the initial guesses
before using GAUSS. iterations Maximum number
of iterations to use. ROBUSTERRORS/ As in LINREG,
this option calculates a NOROBUSTERRORS consi
stent estimate of the covariance matrix.
6
Example 2
Suppose that I want to estimate dxt 0.25a
xt-1 a sin1t b cos1t c dxt-1 This can be
done with LINREG lin dx x1 sin1 cos1
dx1 But suppose that I want to constrain a to
equal a2 b2
nonlin a b c frml z .25(aa bb)x1
asin1 bcos1 cdx1 compute a .4, b
-.3, c 2 nlls(frmlz) dx
7
Controlling the Estimation
NLPAR You will not need to use NLPAR unless you
experience convergence problems or want to obtain
more precise numerical answers. Numerical
optimization algorithms use iteration routines
that cannot guarantee precise solutions for ß.
NLPAR allows you to select the various criteria
RATS uses to determine when (and if) the solution
converges. There are two principal options the
syntax is   nlpar(options) CRITERION In the
default mode, CRITERIONCOEFFICIENTS. Here,
convergence is determined using the change in the
numerical value of the coefficients between
iterations. Setting CRITERIONVALUE means that
convergence is determined using the change in the
value of the function being maximized. CVCRIT
Converge is assumed to occur if the change in the
COEFFICIENTS or VALUE is less than the number
specified. The default is 0.00001.
8
Examples of NLPAR
1. nlpar(cvcrit0.0001)   Setting CVCRIT0.0001
means that RATS will continue to search for the
values of the coefficients that maximize f( )
until the change in the coefficients between
iterations is not more than 0.0001.   2.
nlpar(criterionvalue,cvcrit0.0000001)   Setting
CVCRIT0.0000001 and CRITERIONVALUE means that
RATS will continue to search for the values of
the coefficients that maximize f( ) until the
change in the value of f( ) between iterations is
less than 0.0000001.
9
Maximize
Suppose your data set contains T observations of
the variables yt and xt and you have used the
FRML instruction to define the function   L
f(yt , xt ß)   where xt and ß can be vectors
(and xt can represent a lagged value of yt).
 MAXIMIZE is able to find the value(s) of ß
that solve The syntax and principal options of
MAXIMIZE are   maximize(options) frml start end
funcval where frml A previously defined
formula start end The range of the series to use
in the estimation funcval (Optional) The series
for the computed values of f(yt, xt ß)
10
Options for MAXIMIZE
The key options for our purposes are METHOD
RATS is able to use any one of three different
algorithms to find the maximum BFGS, BHHH, or
SIMPLEX. The technical details of each
maximization algorithm are provided in the RATS
manual. Use either the default BFGS method or
the BHHH method for twice-differentiable
functions and SIMPLEX in other cases. If you have
convergence problems with BFGS, try BHHH. Note
that SIMPLEX is extremely slow and often requires
many iterations. ITERATIONS The upper limit of
the number of iterations used in the
maximization. RECURSIVE Use this option if the
formula must be solved recursively. It is
necessary to use RECURSIVE if the value of the
value of f( ) depends on the value of a
variable at t-i.   Note You can use TEST and
RESTRICT with the BFGS and BHHH options.
Coefficients are numbered by their position in
the NONLIN statement.
11
Maximum Likelihood
Under the usual normality assumption, the log
likelihood of observation t is
With T independent observations
We want to select b and s2 so as to maximize L
12
ML II
We want to select b and s2 so as to maximize L
Note that this is the same as maximizing
Which we would have obtained by writing the
likelihood for obs. t as
13
Maximum Likelihood in RATS
As in NLLS, to use MAXIMIZE, you must first 1.
List the name(s) of the parameters over which
RATS is to perform the maximization. This is
done using the NONLIN command. 2. Define the
likelihood function f( ) using a FRML
statement. 3. Set the initial values of the
parameters using the COMPUTE command.   Consider
the following RATS statements used to estimate
the linear regression y a bx   NONLIN b
var FRML L -log(var) - (y - bx)2/var COMPUTE
b initial guess, var initial guess MAXIMIZE
L start end OR, you can use to formulas frml e
y - bx frml L -log(var) - e2/var
14
Subformulas
yt ?t ?1?t-1   Since the ?t sequence is
unobserved, it is not possible to use LINREG or
NLLS to estimate the process. To estimate ?1
using maximum likelihood techniques, it is
necessary to construct a formula of the form ?t
yt - ?1?t-1. However, the following is an illegal
statement because et is defined in terms of its
own lagged value (a nonresolvable recursive
expression)   frml e y b1e1 The way to
circumvent this problem is to create a
placeholder series using the SET instruction.
Then, define the desired formula in terms of the
placeholder series. Finally, use a SUBFORMULA to
equate the placeholder and the desired series.
For example, a simple way to create the formula
for the MA(1) process is   set temp
0.0 nonlin b1 var frml e y - btemp1 frml L
(temp e), -log(var) - e2/var)
15
Subformulas (cont.)
drst ?1drst-1 ?7drst-7 ?t ?1?t-1
?2?t-2   Now, the NONLIN instruction contains the
coefficient b2. The first FRML instruction uses
temp1 and temp2 as placeholders for et-1 and
et-2. The second FRML instruction creates the
desired log likelihood and the COMPUTE
instruction provides the initial guesses. Notice
that the start date can remain at 9 since no
usable observations are lost from the MA terms.
  set temp 0. nonlin a1 a7 b1 b2 var frml e
drs - a1drs1 - a7drs7 - b1temp1 -
b2temp2 frml L (tempe), -log(var) -
(e)2/var com a1 0.4, a7 -.3, b1 .5, b2
0.3, var 1. max L 9
16
The GARCH Likelihood Function
17
ARMA(1,1)-IGARCH(1,1)
set temp 0. nonlin a0 a1 a2 a3 b0 b1 c1
b0.ge.0. b1.ge.0. c1.ge.0. frml e spread - a0
- a1spread1 - a2spread2 - a3spread3 frml
h b0 b1e12 c1temp1 frml L (temp
h), -log(temp) - (e)2/temp   After
initializing the parameters with the LINREG and
COMPUTE instructions, the first MAXIMIZE
instruction refines the initial guesses with the
SIMPLEX method. The second obtains the final
estimates using to BFGS method   lin(noprint)
spread constant spread1 to 3 com a0
beta(1), a1 beta(2) , a2 beta(3), a3
beta(4) , b0 seesq, b1 0.2, c1
0.5 max(methodsimplex,iters5) L 7
max(iters200) L 7
Write a Comment
User Comments (0)
About PowerShow.com