SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 810|回复: 0
打印 上一主题 下一主题

MCPOWER: a Flexible Macro Suite for Generating Monte Carlo P

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2011-7-9 22:38:02 | 只看该作者

MCPOWER: a Flexible Macro Suite for Generating Monte Carlo P

From LCChien's blog on blogspot

原文載點:<a href="http://support.sas.com/resources/papers/proceedings11/430-2011.pdf"><!-- m --><a class="postlink" href="http://support.sas.com/resources/papers/proceedings11/430-2011.pdf">http://support.sas.com/resources/papers ... 0-2011.pdf</a><!-- m --></a><br /><br />哈佛的一位統計分析師分享了一個名為 %mcpower 的巨集程式,能夠輕鬆的完成在線性迴歸、羅吉斯迴歸以及卜瓦松迴歸的蒙地卡羅檢定力模擬與估計。<br /><br /><a name='more'></a>%mcpower 主要包含 %glmpower 和 %manypower 兩個巨集程式。程式可從此處下載:<br /><div><br /></div><div><a href="http://www.kenkleinman.net/home/index.php/sas-and-r-code/sas-macros.html"><!-- m --><a class="postlink" href="http://www.kenkleinman.net/home/index.php/sas-and-r-code/sas-macros.html">http://www.kenkleinman.net/home/index.p ... acros.html</a><!-- m --></a></div><div><br />其中,%glmpower 是無法直接被執行的,所有的參數都是定義在 %manypower 裡面,格式如下:<br /><pre><code>%macro manypower(alt1=.,&nbsp;alt2=.,&nbsp;alt3=.,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;n1=.,n2=.,n3=.,n4=.,n5=.,n6=.,n7=.,n8=.,n9=.,n10=.,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;outcomedist = "NORMAL", null=0, scaley=1,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xdist="NORMAL", xloc=., xscale =.,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nreps=,plotrows=2, descending = desc, intercept = 0,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plotstyle=graphic, outputpower=YES, outputnsubs=YES, test=FALSE);</code></pre><br />不意外地,巨集變數很多,但因為模擬本來就是一件即為複雜的工作,所以參數多也是很正常的。這些參數主要可以分類為三大群:<br /><br /><b>假設巨集變數</b>:<br /><ul><li>null:所要檢定之虛無假設的值。預設值為 0。</li><li>alt1, alt2, alt3:所要檢定之對立假設(Ha)的數值。若是線性迴歸,則檢定的項目是斜率,若是羅吉斯迴歸,則檢定的項目是odds ratio。若是卜瓦松迴歸,則檢定的項目是risk ratio。無預設值。</li><li>n1, n2, ..., n10:每個模擬資料集裡面的樣本個數。最多可設定十個。無預設值。</li></ul><b>分配巨集變數</b>:<br /><ul><li>outcomedist:依變數的分配。可填入 "NORMAL"、"BERNOULLI" 和 "POISSON"。預設值為 "NORMAL"。(注意,雙引號要寫上)</li><li>scaley:殘差變異數。若使用線性迴歸(即outcomedist = "NORMAL"),則可以省略這個參數的設定。預設值為 1。</li><li>intercept:模擬的模型裡面的截距項。預設值為 0。</li><li>xdist:應變數的分配。預設值是 "NORMAL"。</li><li>xloc:應變數分配的第一個參數值。若 xdist = "NORMAL" 時,此值表示平均數。若 xdist = "POISSON" 時,則此值表示 lambda。若 xdist = "BERNOULLI" 時,則此值表示 p。</li><li>xscale:應變數分配的第二個參數值。若 xdist 為 "POISSON" 或 "BERNOULLI" 時,則此值要省略,因為這兩個分配只有一個參數值。若 xdist = "NORMAL" 時,則可設定變異數。</li></ul><b>輸出巨集變數:</b><br /><ul><li>outputpower:輸出檢定力表格。預設值為 YES。</li><li>outputnsubs:輸出樣本數表格。預設值為 YES。</li><li>plotstyle:輸出表格的格式。如果設定為 sg,則圖形會用 PROC SGPLOT 程序來畫。如果設定為 graphic,則圖形會用 PROC GPLOT &nbsp;來畫。如果沒有設定,則圖形就不會輸出。預設值為 graphic。</li><li>plotrows:若 plotstyle = sg 時,則可設定圖形要有幾行。預設值為 2。</li></ul><div>範例:</div><pre><code>%manypower(null = 0, scaley=1,xdist = "bernoulli", xloc=.5, xscale=.,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nreps = 100, n1=1000,n2=1100,n3=1200,n4=1400,n5=1700,n6=2000,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;alt1 = 1.15, alt2 = 1.20, alt3 = 1.25,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plotrows=2,plotstyle=graphic, outcomedist="poisson", intercept = 1);</code></pre><br />結果:</div><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-5Ej8iN6EYls/TgSzAaHF43I/AAAAAAAAF80/RrFo2WMS5Y0/s1600/1308930817870.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="424" src="http://2.bp.blogspot.com/-5Ej8iN6EYls/TgSzAaHF43I/AAAAAAAAF80/RrFo2WMS5Y0/s640/1308930817870.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-APFgbfHFsXE/TgSxzCjURrI/AAAAAAAAF8c/-6NeUsHdF_4/s1600/1308930508385.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="326" src="http://3.bp.blogspot.com/-APFgbfHFsXE/TgSxzCjURrI/AAAAAAAAF8c/-6NeUsHdF_4/s640/1308930508385.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-jTRzRSxTkHk/TgSx6myXvYI/AAAAAAAAF8g/8J1eOpbF-TI/s1600/1308930538395.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="148" src="http://2.bp.blogspot.com/-jTRzRSxTkHk/TgSx6myXvYI/AAAAAAAAF8g/8J1eOpbF-TI/s640/1308930538395.png" width="640" /></a></div><br /><b>CONTACT INFORMATION</b><br />Your comments and questions would be welcome and valued. &nbsp;Contact the author at:<br />Ken Kleinman<br />Harvard Medical School and Harvard Pilgrim Health Care<br />133 Brookline Ave.<br />Boston, MA 02215<br /><!-- e --><a href="mailto:ken.kleinman@gmail.com">ken.kleinman@gmail.com</a><!-- e --><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6268919072942670865-3460027840021288645?l=sugiclub.blogspot.com' alt='' /></div>
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2025-6-10 05:12 , Processed in 0.069191 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表