在一组数据满足对数正态分布时,我们需要用到几何平均数来评估这组数据的“中心”,计算方法为这组数据的连乘积开项数次方根,计算公式如下。
Gn=n√∏ni=1xi=n√x1x2x3⋯xnGn=ni=1∏nxi=nx1x2x3⋯xn
我们这里介绍几种方法供大家参考。
1
2
3
4
5
6
7
8
9
|
*** 1. 对数据列(aval)求对数 ***
logaval = log(aval);
*** 2. proc means 计算logaval的均值 ***
proc means data=adis n mean lclm uclm noprint;
by trtan avisitn;
var logaval;
output out=gmt1 n=n mean=mean lclm=lclm uclm=uclm;
run;
*** 3. 10的次幂取回, 10**mean ***
|
1
2
3
4
5
6
|
*** 1. 对数据列(aval)求对数 ***
logaval = log(aval);
*** 2. 采用proc sql衍生几何均值***
proc sql noprint;
create table gmt2 as select distinct trtan, avisitn, exp(mean(logaval)) as gmean from adis group by trtan, avisitn;
quit;
|
1
2
3
4
5
6
|
*** proc ttest, dist 选项指定为lognormal, 即对数正态分布 ***;
ods output ConfLimits=gmt3;
proc ttest data=adis dist=lognormal;
by trtpn avisitn;
var aval;
run;
|
1
2
3
4
5
6
|
*** proc surveymeans, 添加geomean gmclm等keywords ***;
ods output GeometricMeans=gmt4;
proc surveymeans data=adis geomean gmclm ;
by trtpn avisitn;
var aval;
run;
|
1
2
3
4
5
|
*** proc univariate, 输出数据集中取_GEOMEAN_ ***;
proc univariate data=adis outtable=DescStats noprint;
by trtpn avisitn;
var aval;
run;
|
文章作者
阿Q
上次更新
2023-03-21
许可协议
原创文章,如需转载请注明文章作者和出处。谢谢!