/*
   tssmooth dexponential

*! VERSION 1.0.2  03mar2005

*/

VERSION 8.0
INCLUDE _std_large
INCLUDE _ht340
INCLUDE header
HELP hlp1, view("help tssmooth_dexponential")
RESET res1

DIALOG main, label("tssmooth dexponential - Double-exponential smoothing")/*
		*/ tabtitle("Main")
BEGIN
  /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+*/

  DEFINE _x _xsetbu
  DEFINE _y _top
  INCLUDE _bu_tsset

  TEXT     tx_gener    _lft	 _ms	   _cwd3_1   .,			/*
  		*/label("New variable:")

  TEXT     tx_exp      _lft3_2	 @	   _comb3_1  .,			/*
  		*/label("Expression to smooth or forecast: ")

  EDIT     ed_gener    _lft      _ss	   _vnwd     .,			/*
  		*/label("New variable ")

  TEXT     tx_equals   _eqxpos	 @	   _eqwd     .,			/*
  		*/center						/*
  		*/label("=")

  EXP      ex_exp      _lft3_2	 @	   _comb3_1  .,			/*
  		*/label("Create ...")					/*
  		*/error("Expression to smooth or forecast")


DEFINE _x _lft
DEFINE _y _ls
DEFINE _cx _cwd1
INCLUDE _type
DEFINE holdy1 @y

  CHECKBOX ck_replace  _lft3_2   holdy1	   _cwd2     .,			/*
		*/ option(replace) nomem				/*
		*/ label("Replace existing variable")


  GROUPBOX gb_opts     _lft      _ls       _iwd	     _ht16h,		/*
		*/ label("Options")

  RADIO    rb_parms1   _ilft     _ss       _cwd2     .,			/*
  		*/ label("Choose smoothing parameter to ")		/*
		*/ clickon(gaction main.ed_parms.disable)		/*
		*/ first

  DEFINE holdy2 @y

  TEXT     tx_next1    _indent2  _vss      _inwd     .,			/*
  		*/label("minimize sum-of-squared forecast")
  TEXT     tx_next1a   @         _vss      @         .,			/*
  		*/label("errors")

  RADIO    rb_parms2   _lft4_3   holdy2    _cwd2     .,			/*
  		*/ label("Specify smoothing parameter:")		/*
		*/ clickon(gaction main.ed_parms.enable)		/*
		*/ last

  TEXT     tx_next2    _indent2  _vss      _cwd4     .,			/*
  		*/label("(Parameter must be in (0,1))")

  EDIT     ed_parms    @         _ss	   _en7wd    .,	numonly		/*
  		*/ option(parms)					/*
  		*/ error("Smoothing parameter")

  CHECKBOX ck_samp0    _ilft     _ms       _cwd2     .,			/*
		*/ label("# of observations to be used to")		/*
		*/ clickon(script main_samp0_on)			/*
  		*/ clickoff(script main_samp0_off)

  DEFINE holdy3 @y

  TEXT     tx_next3    _indent2  _vss      _inwd     .,			/*
  		*/label("obtain initial values for recursions:")

  SPINNER  sp_samp0    @         _ss	   _spwd     .,			/*
  		*/ option(samp0)					/*
		*/ min(2)						/*
		*/ max(c(N))						/*
		*/ default(2)						/*
		*/

  RADIO    rb_for1     _ilft     _ms       _cwd2     .,                 /*
		*/ label("Do not make out-of-sample")                   /*
		*/ clickon(gaction main.sp_for.disable)                 /*
		*/ first

  DEFINE holdy5 @y

  TEXT     tx_for1     _indent2  _vss      _inwd     .,                 /*
		*/label("forecasts")

  RADIO    rb_for2     _lft4_3   holdy5    _cwd2     .,                 /*
		*/ label("Periods for out-of-sample forecast:")         /*
		*/ clickon(gaction main.sp_for.enable)                  /*
		*/ last

  SPINNER  sp_for      _indent2  _ss       _spwd     .,                 /*
		*/ option(forecast)                                     /*
		*/ min(1)                                               /*
		*/ max(500)                                             /*
		*/ default(1)                                           /*
		*/

  CHECKBOX ck_s0       _ilft4_3  holdy3	   _cwd2    .,			/*
		*/ label("Initial values for the recursions:")		/*
		*/ clickon(script main_s0_on)				/*
  		*/ clickoff(script main_s0_off)

  EDIT 	   ed_s01      _indent2  _ss       _spwd     ., numonly		/*
		*/ label("First box for initial value for recursions")

  EDIT     ed_s02      +80       @         _en7wd    .,	numonly		/*
      		*/ label("Second box for initial value for recursions")

END


INCLUDE ifin
INCLUDE _type_list_fd

SCRIPT main_samp0_on
BEGIN
	gaction main.ck_s0.disable
	gaction main.sp_samp0.enable

END

SCRIPT main_samp0_off
BEGIN
	gaction main.sp_samp0.disable
	gaction main.ck_s0.enable
END

SCRIPT main_s0_on
BEGIN
	gaction main.ck_samp0.disable
	gaction main.tx_next3.disable
	gaction main.ed_s01.enable
	gaction main.ed_s02.enable
END

SCRIPT main_s0_off
BEGIN
	gaction main.ed_s01.disable
	gaction main.ed_s02.disable
	gaction main.ck_samp0.enable
	gaction main.tx_next3.enable
END


PROGRAM command
BEGIN
	put "tssmooth dexponential "
	INCLUDE _type_pr
	require main.ed_gener
	put main.ed_gener
	put " "
	put "= "
	require main.ex_exp
	put main.ex_exp
	INCLUDE _ifin_pr
	beginoptions
		if main.rb_parms2 {
			require main.ed_parms
			optionarg main.ed_parms
		}
		if main.ck_samp0 {
			optionarg main.sp_samp0
		}
		if main.ck_s0 {
		   	require main.ed_s01
		   	require main.ed_s02
			put "s0("
			put main.ed_s01
			put " "
			put main.ed_s02
			put ")"
			put " "
		}
		if main.rb_for2 {
			optionarg main.sp_for
		}
		option main.ck_replace
	endoptions

END




