Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Stata 幂二均值:均值必须包含数字_Stata - Fatal编程技术网

Stata 幂二均值:均值必须包含数字

Stata 幂二均值:均值必须包含数字,stata,Stata,我正在尝试使用ttest命令中存储的结果在Stata中进行功耗分析 我所做的具体如下: . ttest r, by(predictor) Two-sample t test with equal variances ------------------------------------------------------------------------------ Group | Obs Mean Std. Err. Std. Dev. [95%

我正在尝试使用ttest命令中存储的结果在Stata中进行功耗分析

我所做的具体如下:

. ttest r, by(predictor)
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |       8         .49    .0368394    .1041976    .4028886    .5771114
       1 |       8        .595    .0547396    .1548271    .4655613    .7244387
---------+--------------------------------------------------------------------
combined |      16       .5425     .034635      .13854    .4686772    .6163228
---------+--------------------------------------------------------------------
    diff |               -.105    .0659816               -.2465165    .0365165
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  -1.5914
Ho: diff = 0                                     degrees of freedom =       14

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0669         Pr(|T| > |t|) = 0.1339          Pr(T > t) = 0.9331

. display r(mu_1),r(mu_2),r(sd_1),r(sd_2),r(p_l)
.49 .595 .10419762 .1548271 .06692561
我总是收到以下错误:

方法必须包含数字

我以为存储结果rmu_1等是数字

以自动数据集为例:

sysuse auto, clear
ttest mpg, by(foreign)

Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
Domestic |      52    19.82692     .657777    4.743297    18.50638    21.14747
 Foreign |      22    24.77273     1.40951    6.611187    21.84149    27.70396
---------+--------------------------------------------------------------------
combined |      74     21.2973    .6725511    5.785503     19.9569    22.63769
---------+--------------------------------------------------------------------
    diff |           -4.945804    1.362162               -7.661225   -2.230384
------------------------------------------------------------------------------
    diff = mean(Domestic) - mean(Foreign)                         t =  -3.6308
Ho: diff = 0                                     degrees of freedom =       72

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0003         Pr(|T| > |t|) = 0.0005          Pr(T > t) = 0.9997

谢谢你的回答,这很有帮助!否则,这里的power不会在运行中进行数值计算。答案中的语法要求Stata将对r类结果的类似宏的引用替换为相应的数值。注意,说r类值有一个本地宏角色更接近实际情况;你不是在这里评估一个严格意义上的本地宏。这是一个在Stata中不一致的行为,我从来没有真正理解过。所有命令都应该识别r项,并根据需要展开它们。这似乎没有一个合乎逻辑的原因。很明显,人们通常希望即时进行评估,而Stata为您提供了一种语法。否则,我认为这归结为名称和值之间的区别。您可能不经常想显示rmean is 42,但Stata允许您这样说。如果42是42,你会很沮丧。可能还有更好的例子。
sysuse auto, clear
ttest mpg, by(foreign)

Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
Domestic |      52    19.82692     .657777    4.743297    18.50638    21.14747
 Foreign |      22    24.77273     1.40951    6.611187    21.84149    27.70396
---------+--------------------------------------------------------------------
combined |      74     21.2973    .6725511    5.785503     19.9569    22.63769
---------+--------------------------------------------------------------------
    diff |           -4.945804    1.362162               -7.661225   -2.230384
------------------------------------------------------------------------------
    diff = mean(Domestic) - mean(Foreign)                         t =  -3.6308
Ho: diff = 0                                     degrees of freedom =       72

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0003         Pr(|T| > |t|) = 0.0005          Pr(T > t) = 0.9997
power twomeans `r(mu_1)' `r(mu_2)', sd1(`r(sd_1)') sd2(`r(sd_2)')

Performing iteration ...

Estimated sample sizes for a two-sample means test
Satterthwaite's t test assuming unequal variances
Ho: m2 = m1  versus  Ha: m2 != m1

Study parameters:

        alpha =    0.0500
        power =    0.8000
        delta =    4.9458
           m1 =   19.8269
           m2 =   24.7727
          sd1 =    4.7433
          sd2 =    6.6112

Estimated sample sizes:

            N =        46
  N per group =        23