上海交大醫(yī)學(xué)院統(tǒng)計學(xué)上機(jī)重點_第1頁
上海交大醫(yī)學(xué)院統(tǒng)計學(xué)上機(jī)重點_第2頁
上海交大醫(yī)學(xué)院統(tǒng)計學(xué)上機(jī)重點_第3頁
上海交大醫(yī)學(xué)院統(tǒng)計學(xué)上機(jī)重點_第4頁
上海交大醫(yī)學(xué)院統(tǒng)計學(xué)上機(jī)重點_第5頁
已閱讀5頁,還剩20頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、H0:不同組男女構(gòu)成比相等,1=2;H1:。統(tǒng)計結(jié)論,P>0.05,按=0.05水平不拒絕H0,無統(tǒng)計學(xué)差異,可認(rèn)為。相等。程序解釋:MEAN過程常用的主要統(tǒng)計量關(guān)鍵詞包括:N(樣本量)SUM(和)MEAN(均數(shù)) RANGE(全距) MIN(最小值) MAX(最大值) STD(標(biāo)準(zhǔn)差) CV(變異系數(shù)) VAR(方差) STDERR(標(biāo)準(zhǔn)誤) LCLM(總體均數(shù)可信區(qū)間下限) UCLM(上限) T(檢驗=0時的T值) PRT(t值對應(yīng)的雙側(cè)概率)data student;input sex $ age height weight birth yymmdd10.; index=weigh

2、t/height*2;cards;male 18 1.74 71.3 1981-3-21female 19 . 54.2 1982-12-4female 18 1.62 58.9 1981-5-6male 18 1.78 75.2 1980-1-4female 18 1.62 61.8 1981-7-12male 19 1.76 72.6 1981-9-23;proc print data=student;var sex age height weight index birth;format birth mmddyy10.;run;proc means data=student;var ag

3、e height weight index ;run;從已建立的SAS數(shù)據(jù)集中讀入數(shù)據(jù)建立新的SAS數(shù)據(jù)集libname course 'd:data'data course.student;set student;run;data a;set course.student;proc print;run;Data b;Set a;Run;數(shù)據(jù)集的拆分data male;set student;if sex='male' then output;run;data female;set student;if sex='male' then delet

4、e;run;data male female;set student;if sex='male' then output male;else output female;run;data height;set student;keep sex age height index;run;proc print ;run;data weight;set student;drop height birth;run;proc print ;run;多個SAS數(shù)據(jù)集縱向合并data one;input name $ pid group age;cards;Liming 111 1 54Wa

5、ngli 112 2 49Xiaoli 113 1 34;data two;input name $ pid drug $ sex;cards;Yaohong 211 A 1Zhaohong 212 B 2Mixue 213 A 2;data total;set one two;proc print data=one;proc print data=two;proc print data=total;run;多個SAS數(shù)據(jù)集橫向合并data one;input pid sex age;cards;101 1 54102 2 45103 2 42105 1 34;data two;input p

6、id weight height;cards;104 45 162102 64 171103 54 165101 51 160;proc sort data=one;by pid;proc sort data=two;by pid;data total;merge one two;by pid;proc print data=total;run;Means過程計算各統(tǒng)計量(std標(biāo)準(zhǔn)差)data shg;input x ;cards;108.0 97.6 103.4 101.6 104.4 98.5 110.5 103.8 109.7109.8104.5 99.5 104.0 103.9 97

7、.2 106.3 106.2 107.6 108.397.6102.7 103.7 107.6 103.2 103.6 103.3 102.8 102.3 102.2103.3101.2 107.5 106.3 109.7 99.5 107.4 103.4 106.6 105.7107.4103.0 109.6 106.4 107.3 100.6 112.3 100.5 101.9 98.899.7104.3 110.2 105.3 95.2 105.8 105.2 106.1 103.6 106.6105.1105.5 113.5 107.7 106.8 106.2 109.8 99.7 1

8、07.9 104.8103.9106.8 106.4 108.3 106.5 103.3 107.7 106.2 100.4 102.6102.1110.6 112.2 110.2 103.7 102.3 112.1 105.4 104.2 105.7104.4102.8 107.8 102.5 102.3 105.8 103.7 103.1 101.6 106.5100.0103.2 109.3 105.8 106.1 104.9 105.9 105.3 103.7 99.6106.2102.5 108.1 106.1 108.3 99.8 108.3 104.0 100.6 112.6 1

9、03.7;proc means data= shg n mean std cv min max;var x;run;分組計算各統(tǒng)計量“結(jié)果保留三位小數(shù)”data a; input group VA VB1;cards;1 1.8 1.4 2 1.7 1.1 1 2.2 1.5 3 1.9 1.2 2 2.5 1.0 1 2.7 1.6 2 2.3 1.3 2 2.8 0.9 3 3.0 1.1 1 2.6 1.4 1 2.4 1.2 2 1.9 1.3 3 2.9 0.8 1 3.2 1.7 3 3.1 1.5 2 2.6 1.9 3 3.5 1.6 3 3.3 1.5;proc sort d

10、ata=a ;by group;proc means mean std max min maxdec=3;by group;var VA VB1;run;計算幾何均數(shù)(頻數(shù)表)data a;input f x ;y=log10(x);cards;1 4 3 8 8 16 13 3221 64 9 128 4 256 1 512;proc means noprint;var y;freq f;output out=b mean=meany;run;data c;set b;meanx=10*(meany);run;proc print;run;程序解釋:FREQ<變量名>:規(guī)定該變量

11、的值為分析變量的頻數(shù)。OUTPUT<OUT=數(shù)據(jù)集名>:指定MEANS過程產(chǎn)生的統(tǒng)計量的輸出數(shù)據(jù)集名。統(tǒng)計量關(guān)鍵字=<新變量名列>···:指明在輸出數(shù)據(jù)集中想要的統(tǒng)計量,且指定這些統(tǒng)計量對應(yīng)的新變量名。univariate過程輸出3種數(shù)據(jù)圖(莖葉圖、盒式圖、正態(tài)概率圖),頻數(shù)表(變量值Value頻數(shù)Count百分?jǐn)?shù)Cell累計百分?jǐn)?shù)Cum),正態(tài)性檢驗結(jié)果data shg; input x ;cards;108.097.6103.4101.6104.498.5110.5103.8109.7109.8104.599.5104.0103.997

12、.2106.3106.2107.6108.397.6102.7103.7107.6103.2103.6103.3102.8102.3102.2103.3101.2107.5106.3109.799.5107.4103.4106.6105.7107.4103.0109.6106.4107.3100.6112.3100.5101.998.899.7104.3110.2105.395.2105.8105.2106.1103.6106.6105.1105.5113.5107.7106.8106.2109.899.7107.9104.8103.9106.8106.4108.3106.5103.3107.

13、7106.2100.4102.6102.1110.6112.2110.2103.7102.3112.1105.4104.2105.7104.4102.8107.8102.5102.3105.8103.7103.1101.6106.5100.0103.2109.3105.8106.1104.9105.9105.3103.799.6106.2102.5 108.1 106.1108.3 99.8 108.3 104.0 100.6 112.6103.7;proc univariate data=shg plot freq normal;var x;run;程序解釋:1、 Tests for Nor

14、mality為正態(tài)性檢驗,檢驗結(jié)果P>0.05,可認(rèn)為是正態(tài)分布。2、 Uncorrected SS為平方和;corrected SS為離均差平方和;Interquartile Range四分位數(shù)間距??傮w均數(shù)的區(qū)間估計(計算總體均數(shù)的置信區(qū)間,99%的置信區(qū)間)data shg; input x ;cards;108.097.6103.4101.6104.498.5110.5103.8109.7109.8104.599.5104.0103.997.2106.3106.2107.6108.397.6102.7103.7107.6103.2103.6103.3102.8102.3102.2

15、103.3101.2107.5106.3109.799.5107.4103.4106.6105.7107.4103.0109.6106.4107.3100.6112.3100.5101.998.899.7104.3110.2105.395.2105.8105.2106.1103.6106.6105.1105.5113.5107.7106.8106.2109.899.7107.9104.8103.9106.8106.4108.3106.5103.3107.7106.2100.4102.6102.1110.6112.2110.2103.7102.3112.1105.4104.2105.7104.4

16、102.8107.8102.5102.3105.8103.7103.1101.6106.5100.0103.2109.3105.8106.1104.9105.9105.3103.799.6106.2102.5108.1 106.1108.3 99.8 108.3 104.0 100.6 112.6103.7;proc means data=shg n mean std clm alpha=0.01; var x;run;T檢驗:(1)樣本均數(shù)與總體均數(shù)比較的T檢驗(總體均數(shù)72 ;t(檢驗=0時的T值); prt(t值對應(yīng)的雙側(cè)概率)data mb; input x ; d=x-72;card

17、s;74 73 68 75 75 82 80 69 72 74 83 72 71 74 76 79 67 73 81 70 67 70 78 69 70 72 67 74 80 66;proc means data=mb mean std stderr t prt;var x d;run;主要看d的t;prt也可以使用univariate過程proc univariate data=mb normal;var x d;run;(2) 配體設(shè)計樣本的T檢驗data ch4_7; input after before ; d=after-before;cards;70.5564.2988.6064

18、.0768.4445.8861.6445.2364.7350.4074.6861.5969.1551.8560.5160.1365.5964.2969.0451.93;proc means data=ch4_7 mean std stderr t prt; var d;run;(3) 成組設(shè)計兩樣本均數(shù)比較的t檢驗(ttest過程進(jìn)行成組t檢驗;class group表示分組變量為group;X為血紅蛋白的增加量)(3)-1data hb; input group x ; cards; 1 26 1 32 1 25 1 22 1 20 1 28 1 24 1 19 1 29 1 17 1 34

19、 1 21 1 20 1 23 1 27 2 21 2 23 2 18 2 24 2 23 2 19 2 16 2 22 2 20 2 25 2 23 2 17 2 15 2 26 2 22 ;proc ttest data=hb;class group;var x;run;結(jié)果解釋:先看方差齊性檢驗(Equality of Variances),P>0.05,方差齊;然后看t Value和對應(yīng)的P值,P<0.05,因此按=0.05水準(zhǔn)拒絕H0,故可認(rèn)為兩組貧血兒童的血紅蛋白的增加量不同,新藥組兒童的血紅蛋白增加量均數(shù)比常規(guī)藥組大。(3)-2:變量變換后成組比較的t檢驗(抗體滴度求

20、對數(shù))data ktdd; input group x ; y=log10(x);cards;1 50 1 30 1 40 1 60 1 60 1 35 1 70 1 20 1 70 1 35 1 40 1 50 1 252 40 2 30 2 25 2 10 2 25 2 30 2 35 2 15 2 20 2 40 2 15 2 30 2 20;proc ttest; class group; var y;run;單因素三水平的方差分析1、 使用循環(huán)語句建立SAS數(shù)據(jù)集:(非常重要)data dat5_1; do group=1 to 3; input n; do i=1 to n; in

21、put x;output; end; end; cards; 15 40 10 35 25 20 15 35 15 -5 30 25 70 65 45 50 15 50 20 45 55 20 15 80 -10 105 75 10 60 45 60 30 10 60 30 100 85 20 55 45 30 77 105 ; run;2、 正態(tài)性檢驗:proc sort data=dat5_1;by group;run;proc univariate data=dat5_1 normal;var x;by group;run;3、 方差齊性檢驗:使用Levene檢驗,程序包含在glm和AN

22、OVA過程中。4、 方差分析:proc glm data=dat5_1;class group;model x=group;means group/hovtest;means group;run;結(jié)果解釋:1用glm過程進(jìn)行方差分析。2首先用class語句指定分組變量,此為group。3 然后用model語句指定所用模型。等號左邊為因變量,右邊為分組變量。4 MEANS關(guān)鍵詞后面是分組變量名,后面跟著一個斜杠,接著是這種選擇項。hovtest 做方差齊性檢驗(P>0.05方差齊)4、均數(shù)間的多重比較:proc glm data=dat5_1; class group; model x=g

23、roup; means group/hovtest; means group/snk bon dunnett('1'); means group/snk alpha=0.01; contrast '1 2 vs 3' group -0.5 -0.5 1; contrast '1 vs 2' group 1 -1 0; run;結(jié)果解釋:SAS中使用GLM過程步或ANOVA過程步中means語句后的選項來實現(xiàn)各種兩兩比較,程序中為幾種不同的比較方法。隨機(jī)區(qū)組設(shè)計方差分析:4個種系(區(qū)組);3個處理data dat2; do block=1 to 4

24、; do treat=1 to 3; input x ; output; end; end;cards;76861151238854081103123357;proc glm data=dat2; class treat block; model x=treat block/p;output out=r R=RES; means treat block / snk; run; proc univariate data=r normal;var res;run;結(jié)果解釋:“/p”要求輸出預(yù)測值和殘差;output out將預(yù)測值和殘差輸?shù)綌?shù)據(jù)集r; RES為殘差的變量名;normal為對殘差進(jìn)行

25、正態(tài)性檢驗。拉丁方設(shè)計方差分析:data dat3; do person=1 to 5; do stress=1 to 5; input cloth $ x ; output; end; end;cards;B 103A 121C 100D 92 E 95C 102B 129D 98E 124 A 115D 118C 133E 103A 109 B 90E 99 D 122A 99 B 84 C 100A 102E 139B 103C 104 D 95;proc anova; class person stress cloth; model x=person stress cloth;run;

26、quit;相關(guān)分析:A藥在血中和尿中的半衰期:1、 建立數(shù)據(jù)集data dat1;input x1 x2;cards;9.9 7.911.28.99.4 8.58.4 9.414.81212.411.513.114.513.412.311.29.29.5 1110.78.39.2 8.5;run;2、繪制散點圖proc plot data=dat1;plot x1*x2='*'/haxis=by 3 vaxis=by 3;run;過程解釋:使用過程步plot進(jìn)行繪制散點圖。'*'定義散點的符號為*haxis vaxis說明間隔的距離*前為縱坐標(biāo),后為橫坐標(biāo)。2、

27、 檢驗雙變量的二元正態(tài)分布proc reg data=dat1;model x2=x1/p;output out=r R=RES;run;proc univariate data=dat1 normal;var x1;run;proc univariate data=r normal;var res;run;過程解釋:Reg:做回歸方程估計,回歸分析Model 因變量=自變量/p對殘差和X1做正態(tài)性檢驗,若兩者的P值皆>0.05,表明符合二元正態(tài)分布。3、進(jìn)行相關(guān)分析proc corr data=dat1;var x1;with x2;run;過程解釋:使用過程步corr進(jìn)行相關(guān)分析。v

28、ar x1;with x2;指定欲分析的相關(guān)變量。0.72048是相關(guān)系數(shù),0.0082是t檢驗的P值回歸分析:data dat2;input x y;cards;18.03314.97519.23727.83936.23;proc plot data=dat2;plot y*x='*'run;proc reg data=dat2;model y=x/p;plot y*x;run;intercept 截距為a(3.94300);3.46300為b四格表卡方檢驗:題:西藥治療79例,有效63人;中藥治療54例,有效47人,問兩種藥物治療有效率?data dat1; do r=1

29、to 2; do c=1 to 2; input freq ; output; end; end;cards;63 1647 7;run;proc freq data=dat1; tables r*c/chisq; weight freq;run;過程解釋:freq 頻數(shù)過程步用FREQ,TABLES語句定義列表的格式:行變量*列變量,斜杠后面是選擇項,chisq表示要卡方檢驗。Weight語句指定頻數(shù)變量。結(jié)果解釋: 4行分別代表頻數(shù),總百分比,行百分比和列百分比proc freq data=dat1;tables r*c/chisq nopercent nocol expected; we

30、ight freq;run;過程解釋:nopercent nocol去掉總百分比和列百分比;expected計算每小格的理論頻數(shù)。K×2表卡方檢驗:題目:增加中西結(jié)合組68例,有效65,三種療法是否有差異?data dat2; do r=1 to 3; do c=1 to 2; input freq ; output; end; end;cards;63 1647 765 3;run;proc freq data=dat2; tables r*c/chisq nopercent nocol; weight freq;run;proc freq data=dat2; tables r*

31、c/chisq nopercent nocol exact; weight freq;run;過程解釋:這里沒有校正,如需進(jìn)行確切檢驗,可在TABLES語句后加上選擇項“exact”R×C表行列無序:data dat3; do r=1 to 3; do c=1 to 4; input freq ; output; end; end;cards;112 150 205 40200 112 135 73362 219 310 69;run;proc freq data=dat3; tables r*c/chisq nopercent nocol; weight freq;run;cmh輸

32、出結(jié)果,看,結(jié)果同上。proc freq data=dat3; tables r*c/noprint cmh; weight freq;run;R×C表行無序列有序:data dat4; do r=1 to 2; do c=1 to 3; input freq ; output; end; end;cards;13 10 621 7 4;proc freq data=dat4; tables r*c/nopct nocol chisq cmh; weight freq;run;過程解釋:TABLES語句后加入CMH選項,意在輸出CMH-卡方統(tǒng)計量的相關(guān)結(jié)果。結(jié)果解釋:看CMH卡方的輸

33、出結(jié)果,在行變量無序列變量有序的情況下,看中的Row Mean Scores DifferR×C表行有序列無序:data dat5; do r=1 to 3; do c=1 to 2; input freq ; output; end; end;cards;59 25169 29196 9;run;proc freq data=dat5; tables r*c/nopct nocol trend; weight freq;run;過程解釋:Trend為趨勢檢驗結(jié)果解釋:趨勢檢驗統(tǒng)計量Z和P,其中Z2=卡方。R×C表行列皆有序:data dat6; do r=1 to 4;

34、do c=1 to 4; input freq ; output; end; end;cards;4 11 143 4119 37 317 118339 22 182 355147 94 139 160;run;proc freq data=dat6; tables r*c/nopct nocol norow chisq cmh; weight freq;run;結(jié)果解釋:CMH中看Nonzero Correlation卡方檢驗看Mantel-Haenszel Chi-Square方表的一致性檢驗:data dat7; do r=1 to 2; do c=1 to 2; input freq

35、; output; end; end;cards;160 265 48;run;proc freq data=dat7; tables r*c/nopct nocol norow agree; weight freq;run;非參數(shù)統(tǒng)計:符號檢驗:data dat1; input a b; d=a-b;cards;1 01 01 00 11 01 01 01 01 0;proc univariate data=dat1; var d;run;結(jié)果解釋:看其中的Sign;表示符號統(tǒng)計量。符號秩和檢驗:data dat2; input before after; d=before-after;ca

36、rds;336 258371 291386 300364 285377 298292 303288 312304 260333 339302 290;proc univariate data=dat2 normal; var d;run;結(jié)果解釋:看其中的Signed Rank;表示符號秩和統(tǒng)計量(S)。兩獨立樣本秩和檢驗:data dat4; do group=1 to 2; input n; do i=1 to n; input x ; output; end; end;cards;80.32 0.47 0.57 2.21 0.64 3.08 0.67 2.13100.26 0.24 0.

37、59 0.37 0.58 0.21 0.33 0.42 0.67 0.45;run;proc univariate data=dat4 normal;class group;var x;run;proc npar1way data=dat4 wilcoxon; class group; var x;run;結(jié)果解釋:先正態(tài)性檢驗;然后看NPAR1WAY的運行結(jié)果。秩和(Sum of Scores);平均秩和(Mean Score)。Statistic較小樣本的秩和;正態(tài)近似檢驗結(jié)果Z(=U),P雙側(cè);同時還給出近似t檢驗和卡方檢驗的結(jié)果。多個獨立樣本秩和檢驗:data dat8; do group=1 to 3; inp

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論