/*
  xtgee_common.idlg

*!  VERSION 1.1.1  28may2009

  // SCRIPTS and PROGRAMS for external use

  	* SCRIPT corr_setForceVisible
	* SCRIPT corr_setForceNotVisible
	* PROGRAM xtgee_common_output
*/

DIALOG corr, label("") tabtitle("Correlation")
BEGIN
  /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+*/
  GROUPBOX gb_corr   _lft      _top      _iwd      _ht17h,		/*
		*/ label("Within-group correlation structure for PA model") /*
		*/
  RADIO    rb_ex     _indent   _ss       _cwd1     .,			/*
		*/ label("Exchangeable")				/*
		*/ clickon("script geenone")				/*
		*/ first						/*
		*/ option("corr(exchangeable)")				/*
		*/
  RADIO    rb_ind    @         _ms       @         .,			/*
		*/ label("Independent")					/*
		*/ clickon("script geenone")				/*
		*/ option("corr(independent)")				/*
		*/
  RADIO    rb_unstr  @         _ms       @         .,			/*
		*/ label("Unstructured")				/*
		*/ clickon("script geenone")				/*
		*/ option("corr(unstructured)")				/*
		*/
  RADIO    rb_fixed  _ilft     _ms       _rbwd     .,			/*
		*/ clickon("script gee_fixed")				/*
		*/ option(NONE)						/*
		*/
  COMBOBOX cb_fixed  _rbsep    @         _vnwd     .,			/*
		*/ dropdown						/*
		*/ contents(square)					/*
		*/ label("Correlation matrix")				/*
		*/
  TEXT     tx_fixed _vnsep     @         _vnwd     .,			/*
  		*/ label("Correlation matrix")
  RADIO    rb_ar     _ilft     _ms       _rbwd     .,			/*
		*/ clickon("script gee_ar")				/*
		*/ option(NONE)						/*
		*/
  DEFINE y @y
  SPINNER  sp_ar     _rbsep    @         _en7wd    .,			/*
		*/ label("Autoregressive order")			/*
		*/ min(1)						/*
		*/ max(c(N))						/*
		*/ default(1)						/*
		*/
  TEXT     tx_ar     _en7sep   @         _rben7r2b  .,			/*
		*/ label("Autoregressive order")			/*
		*/
  RADIO    rb_sta    _ilft     _ms       _rbwd     .,			/*
		*/ clickon("script gee_sta")				/*
		*/ option(NONE)						/*
		*/
  SPINNER  sp_sta    _rbsep    @         _en7wd    .,			/*
		*/ label("Stationary order")				/*
		*/ min(1)						/*
		*/ max(c(N))						/*
		*/ default(1)						/*
		*/
  TEXT     tx_sta    _en7sep   @         _rben7r2b  .,			/*
		*/ label("Stationary order")				/*
		*/
  RADIO    rb_nsta   _ilft     _ms       _rbwd     .,			/*
		*/ clickon("script gee_nsta")				/*
		*/ last							/*
		*/ option(NONE)						/*
		*/
  SPINNER  sp_nsta    _rbsep    @         _en7wd    .,			/*
		*/ label("Nonstationary order")				/*
		*/ min(1)						/*
		*/ max(c(N))						/*
		*/ default(1)						/*
		*/
  TEXT     tx_nsta   _en7sep   @         _rben7r2b  .,			/*
		*/ label("Nonstationary order")				/*
		*/

  CHECKBOX ck_force  _lft      _xxls      _iwd       .,			/*
  		*/option("force")					/*
		*/label("Force estimation if unequally spaced in time [force] (advanced)")
END

SCRIPT corr_PREINIT
BEGIN
	corr.ck_force.hide
END


SCRIPT geenone
BEGIN
	corr.cb_fixed.disable
	corr.sp_ar.disable
	corr.sp_sta.disable
	corr.sp_nsta.disable
END

SCRIPT gee_fixed
BEGIN
	corr.cb_fixed.enable
	corr.sp_ar.disable
	corr.sp_sta.disable
	corr.sp_nsta.disable
END

SCRIPT gee_ar
BEGIN
	corr.cb_fixed.disable
	corr.sp_ar.enable
	corr.sp_sta.disable
	corr.sp_nsta.disable
END

SCRIPT gee_sta
BEGIN
	corr.cb_fixed.disable
	corr.sp_ar.disable
	corr.sp_sta.enable
	corr.sp_nsta.disable
END

SCRIPT gee_nsta
BEGIN
	corr.cb_fixed.disable
	corr.sp_ar.disable
	corr.sp_sta.disable
	corr.sp_nsta.enable
END

PROGRAM disable_xtgee_common
BEGIN
	call program disable_corr
END

PROGRAM enable_xtgee_common
BEGIN
	call program enable_corr
END

PROGRAM disable_corr
BEGIN
	call gaction corr.gb_corr.disable
	call gaction corr.rb_ex.disable
	call gaction corr.rb_ind.disable
	call gaction corr.rb_unstr.disable
	call gaction corr.rb_fixed.disable
	call gaction corr.cb_fixed.disable
	call gaction corr.tx_fixed.disable
	call gaction corr.rb_ar.disable
	call gaction corr.sp_ar.disable
	call gaction corr.tx_ar.disable
	call gaction corr.rb_sta.disable
	call gaction corr.sp_sta.disable
	call gaction corr.tx_sta.disable
	call gaction corr.rb_nsta.disable
	call gaction corr.sp_nsta.disable
	call gaction corr.tx_nsta.disable
	call gaction corr.ck_force.disable
END

PROGRAM enable_corr
BEGIN
	call gaction corr.gb_corr.enable
	call gaction corr.rb_ex.enable
	call gaction corr.rb_ind.enable
	call gaction corr.rb_unstr.enable
	call gaction corr.rb_fixed.enable
	call gaction corr.tx_fixed.enable
	if corr.rb_fixed {
		call script gee_fixed
	}
	call gaction corr.rb_ar.enable
	call gaction corr.tx_ar.enable
	if corr.rb_ar {
		call script gee_ar
	}
	call gaction corr.rb_sta.enable
	call gaction corr.tx_sta.enable
	if corr.rb_sta {
		call script gee_sta
	}
	call gaction corr.rb_nsta.enable
	call gaction corr.tx_nsta.enable
	if corr.rb_nsta {
		call script gee_nsta
	}
	call gaction corr.ck_force.enable
END

SCRIPT corr_setForceVisible
BEGIN
	corr.ck_force.show
END
SCRIPT corr_setForceNotVisible
BEGIN
	corr.ck_force.hide
END

PROGRAM xtgee_common_output
BEGIN
	if ! H(corr.rb_ex) {
		option radio(corr /*
		*/ rb_ex rb_ind rb_unstr rb_fixed rb_ar rb_sta rb_nsta)
		if corr.rb_fixed {
			require corr.cb_fixed
			put " " "corr(fixed " corr.cb_fixed ")"
		}
		if corr.rb_ar {
			put " " "corr(ar " corr.sp_ar ")"
		}
		if corr.rb_sta {
			put " " "corr(stationary " corr.sp_sta ")"
		}
		if corr.rb_nsta {
			put " " "corr(nonstationary " corr.sp_nsta ")"
		}
	}
	option corr.ck_force

END
