当前位置:文档之家› 医学统计学孙振球(第三版)SAS程序及结果

医学统计学孙振球(第三版)SAS程序及结果


若p>0.05,齐用F检验 若<0.05,不齐用Welch's ANOVA for x 非参:Kruskal-Wallish H检验 H0:总体分布位置相同 proc npar1way wilcoxon; var x; class c; run; Kruskal-Wallis Test 2)随机区组设计 H0:μ 1=μ 2=μ 3 input x a b @@; cards; proc anova; class a b; model x=a b; means a/snk; run; 注意: SS组间=SS处理间+SS区组间 非参:Friedman M检验 proc freq; tables b*a*x /scores=rank cmh2; run; 注:区组*处理*指标 3)两阶段交叉 H0:μ 1=μ 2 input r time treat $ x @@; cards; proc anova; class r time treat; model x=r time treat; means r time treat/snk; run; 4)析因设计方差分析 2× 2析因 data f22; input a b x@@; cards; 0 0 0.80 0 0 0.90 0 0 0.70 1 0 1.30 1 0 1.20 1 0 1.10 0 1 0.90 0 1 1.10 0 1 1.00 1 1 2.10 1 1 2.20 1 1 2.00 ; proc print; proc anova; class a b; model x=a b a*b; means a b a*b; run; H0:A因素效应=0,B因素效应=0 A*B因素效应=0 a:F=168 .75 p< .001拒绝H b:F=90 .75 p<0 .001拒绝H a*b: F=36 p=0.0003拒绝Ho :.甲有效,乙有效,甲乙有交互作 用,甲乙都用时血红细胞增加数 最多。 3× 3析因设计 data ex11_2; input x a b @@;
1.两独立样本 input c x@@; proc univariate normal; var x; class c; 时间资料、百分率资料不服从正 态分布 T检验(正态) proc ttest; var x; class c; run; The TTEST Procedure 均数、标准 差、标准误 T-Tests: Pooled(方差齐,t) Satterthwaite(方差不齐,近似t) Equality of Variances方差齐性检 验 非参(非正态) proc npar1way wilcoxon; var x; class c; run; Wilcoxon Two-Sample Test Z One-Sided Pr > Z Two-Sided Pr > |Z| 2.配对样本 t检验 input x1 x2 @@; d=x1-x2; cards; proc univariate data=ex3_6; var d; run; 非参(非正态) 单样本中位数与总体中位数 input x1 @@; median=45.30; d=x1-median; cards; proc univariate normal; var d; run; proc means p50; var x1; run; Moments Basic Statistical Measures Std Deviation 标准偏差 Tests for Location: Mu0=0 Student's t t检验 Sign Signed Rank非参 (非正态时) Quantiles (Definition 5) Extreme Observations 3.方差分析 1)完全随机 proc anova; class c; model x=c; means c/lsd snk dunnett; means c/hovtest welch; run; 方差齐性检验: Levene's Test for Homogeneity of x Variance ANOVA of Squared Deviations from Group Means
residual>2 或 cook’SD>0.05为极端点*/ plot y*x; output out=a p=yp r=yr; data a; set a; abse=abs(yr);/*取绝对值*/ proc corr spearman; var x abse;/*P<0.05存在异 方差性*/ proc print data=a; data p144; set p144; logy=log10(y); proc reg data=p144; model logy=x;plot logy*x; proc print data=p144; run; 序列自相关 proc reg data=p158; model y=x/dw; plot r.*obs.; run; Durbin-Watson D 小结: 1如果有共线性 删除与y偏相关系数最小的 删vif,vp值最大的 2异方差性 删极端点student residual>2 或 cook’SD>0.05为极端点 对y做变换 3序列自相关:做差商 4残差非正态:对y做变换 曲线拟合 proc nlin; parms a=4 b=0.03; model y=exp(a+b*x); run; 变换y input x y; y2=log(y); proc reg; model y2=x; plot y2*x; run; -------------------proc nlin; parms a=0 b=0; model y=a+b*log10(x); run; 变换x input x y; x2=log10(x); cards; proc gplot; plot y*x; proc reg; model y=x2; plot y*x2; run; ----------------proc nlin; parms a=0 b=0 c=0; model y=a*x*x+b*x+c; run; 变换x input x y; x2=x*x; cards; proc reg;
1
hospital*trt*effect/ cmh nopercent nocol; weight f; run; 非参数检验 回归与相关 相关: H0:ρ =0,即x,y之间无线性相 关关系 P<0.05拒绝, 存在线性相关关系 proc univariate normal; var x y; x、y正态:proc corr; var x y; 非正态:proc corr spearman; var x y; run; 条件:①相关性检验P《0.05②r 不应太小,最好大于0.5,0-0.4 弱0.4-0.7一般0.7-1强 回归: proc plot; plot y*x; proc reg; model y=x; plot y*x; run; 多元线性回归 proc reg; model y=x1-x4/stb;/*标准 化处理*/ run; proc reg; model y=x1 x2 x3 x4/ selection=stepwise sle=0.10 sls=0.15; run;/*逐步回归*/ proc corr nosimple; var x1 x2 x3 x4 y; run; proc corr nosimple; var x1 y;/*除去x2x3x4,x1 与y的偏相关*/ partial x2 x3 x4; run; 回归系数的检验 H0:β 1=0 P《0.05拒绝,β 1≠0,方程保 留x1 >0.05, β 1=0,去掉x1. 如果有几个x的β =0没有拒绝, 剔 除1个x(F最小,p值最大),余 下的m-1个x再做回归,重复上述 检验。 线性回归模型的诊断 多重共线性: proc reg data=p122; model y=x1-x5/tol vif collin; run; tolerance,variance inflation Eigenvalue特征根 Proporation of variztion 异方差性: H0:ρ =0 P≤0.05存在异方差性 proc reg data=p144; model y=x/p r; plot r.*p.;/*student
cards; proc anova; class a b; model x=a b a*b; means a b a*b/snk; run; 5*2*2析因设计 proc anova; class a b c x@@; model x=a b c a*b a*c b*c a*b*c; run; snk中只有5和4只对一个字母说 明5.4差异大,1. 2. 3介于之 问 5)正交实验设计 有空白列,无重复 data ex11_4; input a b ab c n1 n2 d x @@; cards; 1 1 1 1 1 1 1 86 1 1 1 2 2 2 2 95 1 2 2 1 1 2 2 91 1 2 2 2 2 1 1 94 2 1 2 1 2 1 2 91 2 1 2 2 1 2 1 96 2 2 1 1 2 2 1 83 2 2 1 2 1 1 2 88 ; proc print; proc anova; class a b c d; model x=a b c a*b d; means a b c d a*b; run; 结果 误差是由空白列造成的,一级分 解中p>0.05不用看 只有C a*b的p<0.05,看F值,F 越大作用越大, c为主ab为次 因x越大越好, 看x的mean值选择 较大者,所以a2b1c2d2最优 无空白列,有重复 data ex1_2; input a b c d x@@; cards; 1 1 1 1 1 2 2 2 1 3 3 3 2 1 2 3 2 2 3 1 2 3 1 2 3 1 3 2 3 2 1 3 3 3 2 1; proc anova; class a b c d; model x=a b c d; means a b c d; run; 有空白列,有重复 data ex1_2; input a b ab c ac bc n x @@; cards; …… proc print; proc anova; class a b c; model x=a b c a*b a*c b*c;
相关主题