/*
  pkequiv

*!  VERSION 1.0.3  16feb2007

*/

VERSION 10

INCLUDE _std_large
INCLUDE header

HELP hlp1, view("help pkequiv")
RESET res1

DIALOG main, label("pkequiv -- Perform bioequivalence testing for two treatments") /*
		*/ tabtitle("Main")
BEGIN
  /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+*/ 
  TEXT     tx_varo         _lft      _top      _cwd3_1   .,		/*
		*/label("Outcome variable:")
  TEXT     tx_vart         _lft3_2   @         @         .,		/*
  		*/label("Treatment variable:")				/*
  		*/
  TEXT     tx_varp         _lft3_3   @         @         .,		/*
  		*/label("Period variable:")				/*
  		*/
  VARNAME  vn_varo         _lft      _ss       _vnwd     .,             /*
  		*/label("Outcome variable") 	
  VARNAME  vn_vart         _lft3_2   @         @         .,		/*
  		*/label("Treatment variable")
  VARNAME  vn_varp         _lft3_3   @         _vnwd     .,		/*
  		*/label("Period variable")
  TEXT     tx_vars         _lft      _ls       _cwd3_1   .,		/*
		*/label("Sequence variable:")
  TEXT     tx_vari         _lft3_2   @         @         .,		/*
  		*/label("Identification variable:")			/*
  		*/
  VARNAME  vn_vars         _lft      _ss       _vnwd     .,             /*
  		*/label("Sequence variable") 	
  VARNAME  vn_vari         _lft3_2   @         @         .,		/*
  		*/label("Identification variable")
END

INCLUDE ifin

DIALOG opt, label("") tabtitle("Options")
  /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+*/ 
BEGIN
  CHECKBOX ck_comp         _lft      _top      _iwd     .,		/*
  	*/ label("Compare these two values of the treatment variable:")	/*
  		*/ option("NONE")				        /*
		*/ clickon(gaction opt.ed_comp.enable)			/*
		*/ clickoff(gaction opt.ed_comp.disable)
  EDIT	   ed_comp         _indent2  _ss       _vnwd     .,		/*
  	*/label("Compare these two values of the treatment variable")	/*
  		*/max(32)						/*
		*/option("compare")
  CHECKBOX ck_limit        _lft      _ls       _ckwd     .,		/*
  		*/ label("")						/*
  		*/ clickon(gaction opt.en_limit.enable)			/*
		*/ clickoff(gaction opt.en_limit.disable)
  EDIT     en_limit        _cksep    @         _en7wd     .,		/*
  		*/ label("Equivalence limit")				/*
  		*/ numonly						/*
		*/ option("limit")
  TEXT     tx_limit        _en7sep   @         _ckspr    .,		/*
  		*/ label("Equivalence limit (between 0.10 and 0.99)")
  COMBOBOX cb_level        _lft      _ls       _spwd     .,		/*
		*/ dropdown						/*
		*/ label("Confidence level")				/*
		*/ default(c(level))					/*
		*/ contents(levels)					/*
		*/ option(level)					/*
		*/

  TEXT 	   tx_level        _spsep    @         _spr      _ht0,		/*
                */ label("Confidence level")                            /*
		*/
		  
DEFINE holdx @x
  TEXT     tx_conf         _lft      _ls       _iwd      .,		/*
  		*/label("Confidence interval calculated by:")
  RADIO    rb_class        @         _ss       _cwd3_1   .,		/*
  		*/label("Classic method")				/*
  		*/option("NONE")					/*
		*/first							/*
		*/clickon("script at_on")
  RADIO    rb_fieller      _lft3_2   @         @         .,		/*
  		*/label("Fieller's theorem")				/*
  		*/option("fieller")					/*
		*/clickon("script at_off")
  RADIO    rb_symm         _lft3_3   @         @         .,		/*
  		*/label("Symmetric eq. int.")				/*
  		*/option("symmetric")					/*
		*/clickon("script at_off")				/*
		*/last
  TEXT     tx_bio           _lft     _ls       _iwd      .,		/*
  		*/label("Bioequivalence test:")
  RADIO    rb_none          @        _ss       _cwd3_1   .,		/*
  		*/option("NONE")					/*
  		*/label("None")						/*
		*/first							
  RADIO    rb_and           _lft3_2  @         _comb3_1  .,		/*
  		*/label("Anderson and Hauck hypothesis test")		/*
  		*/option("anderson")					
  RADIO    rb_tost          _lft     _ss       _cwd1     .,		/*
  		*/label("Two one-sided hypothesis tests")		/*
  		*/option("tost")					/*
		*/last							
  CHECKBOX ck_noboot        @        _ls       _iwd      .,		/*
		*/option("noboot")					/*
		*/label("Do not estimate the probability that the CI lies within the confidence limits")
END

SCRIPT at_on
  BEGIN
    opt.rb_none.enable
    opt.rb_and.enable
    opt.rb_tost.enable
    opt.tx_bio.enable
    opt.ck_noboot.enable
  END

SCRIPT at_off
  BEGIN
    opt.rb_none.disable
    opt.rb_and.disable
    opt.rb_tost.disable
    opt.tx_bio.disable
    opt.ck_noboot.disable
  END
  

PROGRAM command
BEGIN
	put "pkequiv "
	varlist main.vn_varo
	varlist main.vn_vart
	varlist main.vn_varp
	varlist main.vn_vars
	varlist main.vn_vari
	INCLUDE _ifin_pr
	beginoptions
		if opt.ck_comp {
			require opt.ed_comp
			optionarg opt.ed_comp
		}
		if opt.ck_limit {
			require opt.en_limit
			optionarg opt.en_limit
		}
		option radio(opt rb_class rb_fieller rb_symm)
		if opt.rb_class {
			option radio(opt rb_none rb_and rb_tost)
			option opt.ck_noboot
		}
		optionarg /hidedefault opt.cb_level
	endoptions
END

