/*
  pac_9

*!  VERSION 1.1.2  15jun2011  (deprecated)

*/

VERSION 9.0

INCLUDE graph_header
INCLUDE header
HELP hlp1, view("help pac")
RESET res1

DIALOG main, label("pac - Partial autocorrelations and confidence intervals") /*
		*/ tabtitle("Main")
BEGIN
  DEFINE _x _xsetbu
  DEFINE _y _top
  INCLUDE _bu_tsset
  TEXT     tx_var          _lft      _top      _cwd2     .,		/*
		*/label("Variable:")
  VARNAME  vn_var          @         _ss       _vnwd     .,             /*
  		*/label("Variable")

  GROUPBOX gb_opt          @         +35       _iwd      _ht20,		/*
  		*/label("Options")
  RADIO    rb_lags1        _indent   _ss       _inwd     .,             /*
  		*/clickon(gaction main.sp_lags2.disable)                /*
		*/first							/*
		*/label("Use default number of autocorrelations -- min([n/2]-2,40)")
  RADIO    rb_lags2        @         _ss       @         .,             /*
  		*/clickon(gaction main.sp_lags2.enable)                 /*
		*/last							/*
		*/label("Use specified number of autocorrelations")
  DEFINE _x @x
  SPINNER  sp_lags2        _indent2  _ss       _spwd     .,        	/*
  		*/min(1)						/*
		*/max(100)						/*
		*/default(1)						/*
		*/option(lags)

  CHECKBOX ck_gen          _ilft     _ls       _ibwd     .,		/*
  		*/ clickon(script graph_off)				/*
  		*/ clickoff(script graph_on)				/*
		*/ label("Generate a variable to hold the partial autocorrelations: (suppresses the graph)")
  EDIT     ed_gen  	   _indent2  _ss       _vnwd     .,             /*
  		*/max(32)						/*
  		*/option("nograph generate")				/*
		*/label("Variable to hold estimated partial autocorrelation")
  TEXT     tx_gen          _vnsep    @         200       .,		/*
  		*/label("New variable name")

  CHECKBOX ck_srv          _ilft     _ls       _ibwd     .,             /*
  		*/ option(srv)						/*
  		*/ onclickon(script main_srv_on)			/*
  		*/ onclickoff(script main_srv_off)			/*
  		*/ label("Include standardized residual variances in graph (SRV)")
  CHECKBOX ck_yw           @         _ms       @         .,		/*
  		*/ option(yw)						/*
  		*/ onclickon(main.ck_srv.disable)			/*
  		*/ onclickoff(main.ck_srv.enable)			/*
  		*/ label("Calculate partial autocorrelations using Yule-Walker equations")

  DEFINE _x _ilft
  DEFINE _y _ls
  DEFINE _cx _sprb
  INCLUDE _sp_level
END

SCRIPT main_srv_on
BEGIN
	main.ck_yw.disable
	script p3_opts_enable
END

SCRIPT main_srv_off
BEGIN
	main.ck_yw.enable
	script p3_opts_disable
END

SCRIPT graph_off
BEGIN
	main.ed_gen.enable
	main.tx_gen.enable

	script p1_opts_disable
	script p2_opts_disable
	script addplot_disable
	script gr_twoway_disable
END

SCRIPT graph_on
BEGIN
	main.ed_gen.disable
	main.tx_gen.disable

	script p1_opts_enable
	script p2_opts_enable
	script addplot_enable
	script gr_twoway_enable
END

INCLUDE ifin

INCLUDE p1_opts
INCLUDE p2_opts
INCLUDE p3_opts
INCLUDE addplot
INCLUDE gr_twoway

SCRIPT PREINIT
BEGIN
	script p1_opts_createAsNoRange
	script p1_opts_setDefaultDropline
	script p2_opts_createAsRange
	script p2_opts_default_rarea
	script p3_opts_createAsNoRange
	script p3_opts_setDefaultScatter
END

SCRIPT POSTINIT
BEGIN
	script p2_opts_setTabtitleCi
	p3_opts.settabtitle "SRV plot"
END

PROGRAM command
BEGIN
	put "pac "
	varlist main.vn_var
	INCLUDE _ifin_pr
	beginoptions
		if main.rb_lags2 {
			optionarg main.sp_lags2
		}
		if main.ck_gen {
			require main.ed_gen
			optionarg main.ed_gen
		}
		INCLUDE _level_main_pr
		option main.ck_srv
		option main.ck_yw

		put " " /program p1_opts_recast_output
		put " " /program p2_opts_ci_output
		call    p3_opts_specialOutput.setstring "srvopts"
		put " " /program p3_opts_special_output
		put " " /program addplot_output
		put " " /program gr_twoway_output

	endoptions
END
/* end */
