全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
4414 7
2012-10-19
求教各位高手,我现在用bootstrap找confidence interval,
我的code如下
data spatial;
      input a b @@;
   cards;
   48 42 36 33 20 16 29 39 42 38 42 36 20 15 42 33 22 20 41 43 45 34
   14 22  6  7  0 15 33 34 28 29 34 41  4 13 32 38 24 25 47 27 41 41
   24 28 26 14 30 28 41 40
   ;
  
/*To use the %JACK or %BOOT macros, you must write a macro called %ANALYZE to do the data analysis
   that you want to bootstrap. The %ANALYZE macro must have two arguments:

   DATA=   the name of the input data set to analyze
   OUT=    the name of the output data set containing the statistics
           for which you want to compute bootstrap distributions.
*/
   %macro analyze(data=,out=);
      proc means noprint data=&data vardef=n;
         output out=&out(drop=_freq_ _type_) var=var_a var_b;
         var a b;
         *%bystmt;
      run;
   %mend;

/* %analyze(data=spatial,out=temp); proc print data=temp;run;*/

   title2 'Normal ("Standard") Confidence Interval with Bias Correction';
   %boot(data=spatial,alpha=.10,samples=100,random=123);

   title2 'Normal ("Standard") Confidence Interval without Bias Correction';
   %bootse(alpha=.10,biascorr=0);

   title2 'Efron''s Percentile Confidence Interval';
   %bootci(percentile,alpha=.10);

   title2 'BC Confidence Interval';
   %bootci(bc,alpha=.10);

   title2 'BCa Confidence Interval';
   %bootci(bca,alpha=.10);


   title2 'Resampling with Computation of Studentizing Statistics';
   %macro analyze(data=,out=);
      proc means noprint data=&data vardef=n;
         output out=&out(drop=_freq_ _type_)
            var=var_a var_b kurtosis=kurt_a kurt_b;
         var a b;
         %bystmt;
      run;
      data &out;
         set &out;
         stud_a=var_a*sqrt(kurt_a+2);
         stud_b=var_b*sqrt(kurt_b+2);
         drop kurt_a kurt_b;
      run;
   %mend;

   %boot(data=spatial,stat=var_a var_b,samples=100,random=123);

   title2 'T Confidence Interval';
   %bootci(t,stat=var_a var_b,student=stud_a stud_b,alpha=.10)

我最后得到的var b 90%的 bootstrap confidence interval是70到150,我dataset里面的var b竟然全不在90% confidence interval,所以求问是什么情况。我即使用t-distribution算90%  confidence interval  117 到228。
所以我不是很明白,为什么我dataset里面的data 全不在我的confidence interval

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2012-10-19 14:41:07
帮顶!还没到这个水平
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-10-20 01:35:24
what you are bootstrapping is about variance, not mean. I don't think you can easily see variance from data value itself. Jingju
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-10-21 05:41:10
jingju11 发表于 2012-10-20 01:35
what you are bootstrapping is about variance, not mean. I don't think you can easily see variance fr ...
谢谢你,
我后来也发现这个问题,后来我自己把code 改成mean_a 和mean_b了,算出来的就是mean的confidence interval。但是后来又有了个新问题,就是我想算exponential的lambda的confidence interval,lambda是个常数,这个时候code应该怎么写。我原来算的confidence interval都是变量。这个是我的算confidence interval的code,怎么进行变化可以让他算lambda的confidence interval。
谢谢。
%let lambda = 2;
data exp;
do i=1 to 20;
E=ranexp(2345)/λ
output;
end;
run;
Proc print; run;
%include 'C:\Users\shengrong\Documents\Wash U\2012 Fall\math 475\Note and Sample\jackboot.sas';
  %macro analyze(data=,out=);
      proc means noprint data=&data vardef=n;
         output out=&out(drop=_freq_ _type_) var=mean_i mean_E;
         var i E;
      
      run;
   %mend;

%analyze(data=exp,out=temp); proc print data=temp;run;
title "Bootstrap Confidence Interval";
   %boot(data=exp,stat=mean_i mean_E,samples=200,random=123,alpha=0.10);
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-10-21 06:04:55
first of all, I suggest you read sas doc about proc means.
to estimate mean, you should write mean =mean_i mean_e, or so. because mean= option tells sas to compute the mean.

you are generating a distribution of exponential with mean of 1/lambda, right?
now you are going to estimate lambda, that is 1/mean. as my understanding, in %analyze adding a code like:
data &out; set &out; lambda =1/mean_e; keep mean_i lambda;
run;
really, you are bootstrapping a function of statistics and keep in mind the property of that function.
jingju
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-10-21 06:28:29
jingju11 发表于 2012-10-21 06:04
first of all, I suggest you read sas doc about proc means.
to estimate mean, you should write mean ...
十分感谢,我刚才还在您的博客上给你发纸条也问同样的问题了,真是很抱歉打扰您了,这个问题困扰了我好几天,网上查了各种方法,也挺着急的。
谢谢您。  我再去自己琢磨琢磨去。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群