DATA Step, Macro, Functions and more

Wilson estimator.- method for calculating the confidence interval

Reply
Contributor
Posts: 31

Wilson estimator.- method for calculating the confidence interval

Data propns;
	seed = 123475;
	nr = 10000; nc = 12;
	array x[20];
	zstar = abs ( probit(0.025) );
	ppop = 0.5;
	do r = 1 to nr;
		do c = 1 to nc;
			x[c] = ranbin(seed, 1, ppop);
			nh = sum(of x[*]);
			phat = nh / nc;
			se_phat = sqrt( phat * (1-phat) / nc);
			pcurl = (nh + 2)/(nc + 4);
			se_pcurl = sqrt( pcurl * (1-pcurl) / (nc+4) );
			zhat = (phat - ppop)/se_phat;
			zcurl = (pcurl - ppop)/se_pcurl;
			if abs(zhat) <= zstar then cv_hat = 1;
				else cv_hat = 0;
			if abs(zcurl) <= zstar then cv_curl = 1;
				else cv_curl = 0;
		end;
		output;
	end;
	keep phat se_phat pcurl se_pcurl zhat zcurl cv_hat cv_curl;
run;




PROC print data = propns;
run;

PROC means data = propns n mean stderr;
	var cv_hat cv_curl;
run;

PROC chart data = propns;
	vbar zhat zcurl;
run;quit;

PROC plot data = propns;
	plot cv_hat*nr = '^';
	plot cv_curl*nr = '~';
run;
quit;

I did estimaton (EXACT and adjusted Wald method)

Question how to do Wilson estimation 

Thank you

I need code, pls

Ask a Question
Discussion stats
  • 0 replies
  • 192 views
  • 0 likes
  • 1 in conversation