/*
  bootstrap

*!  VERSION 2.1.7  28sep2010

  keyword:  eclass

*/

VERSION 12.0

INCLUDE _std_large
DEFINE _dlght 440
INCLUDE header
HELP hlp1, view("help bootstrap")
RESET res1

DIALOG main, label("bootstrap - Bootstrap sampling and estimation") 	///
	tabtitle("Main")
BEGIN
  SPINNER  sp_reps	_lft2	_top	80	.,			///
	label("Replications")						///
	min(2) max(10000000) default(50)				///
	option(reps)
  TEXT     tx_reps	+85	@	_spr2	.,			///
	label("Replications")

  DEFINE _y +5
  INCLUDE _cmd_exp_list
END

DIALOG opt, tabtitle("Options")
BEGIN
  GROUPBOX gb_design	_lft	_top	_iwd	_ht9,			///
	label("Sampling design")

  TEXT tx_strata	_indent	_ss	_cwd2	.,			///
	label("Strata variables:")

  DEFINE x @x
  DEFINE y @y
  VARLIST  vl_strata	@	_ss	_cwd4	.,			///
	label("Strata variables")					///
	option(strata)
  CHECKBOX ck_size	x	_xls	_ckwd	.,			///
	onclickon(opt.sp_size.enable)					///
	onclickoff(opt.sp_size.disable)
  SPINNER  sp_size	_cksep	@	_spwd	.,			///
	label("Sample size")						///
	min(1) max(c(N)) default(c(N))					///
	option(size)
  TEXT     tx_size	_spsep	@	_spr2b	.,			///
	label("Sample size")

  TEXT  tx_clust	_lft2	y	_cwd2	.,			///
	label("Cluster variables:")
  VARLIST  vl_clust	@	_ss	_cwd2	.,			///
	label("Cluster variables")					///
	option(cluster)

  TEXT     tx_clid	@	_ms	@	.,			///
	label("New cluster ID variable: (optional)")
  EDIT     ed_clid	@	_ss	@	.,			///
	label("New cluster ID variable")				///
	option(idcluster)

  DEFINE _y _xxls
  INCLUDE _saving

  CHECKBOX ck_bca	_lft	+45	_iwd	.,			///
	label("Compute acceleration for BCa confidence intervals")	///
	option(bca)
  CHECKBOX ck_mse	@	_ms	@	.,			///
	label("Use MSE formula for variance estimation")		///
	option(mse)
END

INCLUDE _saving_sc

SCRIPT rpt_POSTINIT
BEGIN
	create STRING rpt_bu_fmtcoefResults
	program rpt_bu_fmtcoef_ckResults

	create STRING rpt_bu_eformResults
	program rpt_bu_eform_ckResults
END

DIALOG rpt, tabtitle("Reporting")
BEGIN

  DEFINE _x _lft
  DEFINE _cx _spr2
  DEFINE _y _top
  INCLUDE _sp_level

  DEFINE _x _lft
  DEFINE _y _ls
  DEFINE _xwd _cwd1
  INCLUDE _coef_table_common

  TEXT     tx_title	_lft	_ls	_iwd	.,			///
	label("Title:")
  EDIT     ed_title	@	_ss	@	.,			///
	label("Title")							///
	option(title)

  DEFINE _x _lft
  DEFINE _y _ls
  DEFINE _cx _iwd
  INCLUDE _noomitted

  DEFINE _x _lft
  DEFINE _y _ms
  DEFINE _cx _iwd
  INCLUDE _vsquish

  DEFINE _x _lft
  DEFINE _y _ms
  DEFINE _cx _iwd
  INCLUDE _factor_vars_reporting
  
  DEFINE _x _lft
  DEFINE _y _xxxls
  INCLUDE _bu_coef_table_reporting

  DEFINE _x _lft2
  DEFINE _y @
  INCLUDE _bu_eform_opts_reporting

  DEFINE _x _lft2
  DEFINE _cx _cwd1
  DEFINE _y _top
  DEFINE _cy _ht6
  INCLUDE _output_reps
END

INCLUDE fmt_coef_table_reporting_pr
INCLUDE _coef_table_common_report_pr
INCLUDE eform_option_reporting_pr

DIALOG adv, tabtitle("Advanced")
BEGIN
  CHECKBOX ck_nodrop	_lft	_top	_iwd	.,			///
	label("Do not drop observations")				///
	option(nodrop)
  CHECKBOX ck_nowarn	@	_ms	_iwd	.,			///
	label("Do not warn when e(sample) is not set")			///
	option(nowarn)
  CHECKBOX ck_force	@	_ms	_iwd	.,			///
	label("Do not check for weights or svy commands")		///
	option(force)

  TEXT     tx_reject	@	_ls	@	.,			///
	label("Identify invalid results:")
  EDIT     ed_reject	@	_ss	@	.,			///
	label("Identify invalid results")				///
	option(reject)

  TEXT     tx_seed	@	_ls	@	.,			///
	label("Random-number seed:")
  EDIT     ed_seed	@	_ss	_en14wd	.,			///
	label("Random-number seed")					///
	option(seed)
END

PROGRAM bs_options
BEGIN
	put "bootstrap "
	option main.ck_b
	option main.ck_se
	put " " main.ed_explst
	beginoptions
		optionarg main.sp_reps
		option rpt.ck_qui
		option rpt.ck_noi
		option rpt.ck_trace
		optionarg opt.vl_strata
		optionarg opt.sp_size
		if opt.ed_clid {
			require opt.vl_clust
		}
		optionarg opt.vl_clust
		optionarg opt.ed_clid
		INCLUDE _saving_pr
		option opt.ck_bca
		option opt.ck_mse
		put /program _coef_table_common_cmd
		optionarg /hidedefault rpt.sp_level
		optionarg rpt.ed_title
		INCLUDE _noomitted_pr
		INCLUDE _vsquish_pr
		INCLUDE _factor_vars_reporting_pr
		put " " rpt_bu_fmtcoefResults
		put " " rpt_bu_eformResults
		option adv.ck_nodrop
		option adv.ck_nowarn
		option adv.ck_force
		optionarg adv.ed_reject
		optionarg adv.ed_seed
	endoptions
END

PROGRAM command
BEGIN
	put /program bs_options
	put " " ": "	/* end of prefix, begin command */
		require main.vl_cmd
		put main.vl_cmd
END
