Transformation of a system of equations into a matrix vector
[x,boundsvarb,prests]=eq2xcol(grocer_a,listeq,uneven,dropna)
* grocer_a = the vector of coefficients where the equations must be evaluated
* listeq = the list of equations in string form
* uneven = a boolean indicating whether the equations should keep their time bounds or must have common bounds
* dropna = a boolean indicating whether the program should keep only lines of matrices y and x with non NA values
* x = the X matrix in the regression represented by the system of equations embedded in listeq
* boundsvarb = the bounds of the regressions (if any)
* prests = a boolean indicating whether there is a ts in the equations
load(GROCERDIR+'/data/bdhenderic.dat'); rols=ols('lm1','ly','lp','rnet','const') [grocer_x,grocer_boundsvarb,grocer_prests]=eq2xcol(-rols('beta'),'lm1-grocer_a(1)*ly-grocer_a(2)*lp-grocer_a(3)*rnet-grocer_a(4)',%f,%f) // this example stores in a vector the residuals of the first stage cointegration relationship between lm1, ly, lp and rnet, // as well as the corresponding time bounds and the presence of a ts x=-numz0(eq2xcol,ones(grocer_ncoef,1),grocer_ncoef,... ones(grocer_ncoef,grocer_totalnobs),1,grocer_listeq,grocer_unequal,grocer_dropna)' // This last example is taken from explosys and cannot be run alone, but shows a useful application. Eq2xcol is // given as an entry in function numz0 in order to calculate the x matrix as the first derivative // of the vector of equations with respect to the coefficients: it is evaluated at vector ones(grocer_ncoef,1). | ![]() | ![]() |