proc (1)=cwdecomp(res,ar,ma,trend_int);
/*
cwdecomp.src is written by Kristian Jönsson (April 10, 2003), Department of Economics, Lund University.
Contact info:  kristian.jonsson@nek.lu.se

This procedure calculates the trend innovation to a ARIMA(p,1,q) process according to Cuddington and Winters (1987, JME).


Inputs: 
  res 		: A Tx1 vector with residuals from the fitted ARMA process.
  ar		: A px1 vector with AR coefficients.
  ma		: A qx1 vector with MA coefficients.
  trend_int	: The intercept for the fitted ARMA process (scalar).

Output:
  tr_innov	: A Tx1 vector containing the trend innovations.

Note:
This code can be used freely as long as proper reference is given.
No performance guarantee is made.
Bugreports are welcome.
*/
local lr_ar,lr_ma;
local tr_innov;
local trend;

lr_ar=1-sumc(ar);
lr_ma=1+sumc(ma);

tr_innov=trend_int+(lr_ma/lr_ar)*res;

retp(tr_innov);
endp;
