1
$\begingroup$

Say we have this:

x <- c(993.354165847643, 1055.48537986726, 4003.32907924129, 494.21057245789, 4662.29695447144, 1395.13557275882, 1695.5747710304, 3622.32128274203, 4063.4847568296, 2287.35662116521, 4456.96939812236, 3929.71358024154, 1321.26970668235, 959.859904005188, 1603.04363403031, 771.34718619393, 4629.33336664729, 2926.47839689164, 618.50690152634, 3033.26379133148, 4044.42403633577, 1265.59998369787, 2790.26210957826, 4726.54044861499, 3859.63959322805, 713.827526848569, 3728.54267565127, 4105.45274632, 3695.95167122361, 3475.14471956252, 2562.88641254128, 1175.4886523273, 1541.75447052156, 915.832407495865, 547.673007369953, 2236.59291645992, 3146.57449432257, 1670.87100263699, 2482.51233266087, 4034.63492270761, 1504.03599814317, 941.986204651309, 4386.59394614236, 822.726642401517, 4694.44151337787, 4639.524036903, 1947.25926415882, 2082.9447133529, 1370.96973022059, 4065.12647993175, 3601.55660358343, 4306.7958250248, 2350.39170539696, 3983.03451820313, 3714.81427862702, 490.958533071285, 828.668876473295, 4277.73742268773, 4737.23358080266, 2559.49398515138, 1514.14896559722, 899.589848826677, 2879.26834281265, 707.436631036836, 1267.86705992644, 1456.02338405603, 3820.59709748663, 685.699352434722, 768.627494521916, 2261.18861570379, 3016.82216301372, 3665.24842754188, 1014.93406045042, 4057.44987862074, 3354.80205926634, 4379.51865630041, 3950.33150960694, 4298.62743764328, 1424.43884388634, 699.620422073228, 4650.82249781165, 2459.16668767922, 3119.16788276332, 3198.41731320632, 4380.46344770071, 1214.57226688602, 4773.93561238519, 1461.68163936954, 4076.41971845327, 4481.25959795584, 2779.16920368152, 1566.36645019419, 651.550578452552, 1180.84630356349, 1085.66035328584, 897.070174665921, 791.310827530615, 567.723239449041, 826.476263553536, 1811.53654504956, 3492.62018264507, 1115.68007513428, 3383.24442617197, 961.855945143232, 4069.8814239134, 4709.55997173359, 3756.41538322972, 2145.80891494233, 3677.48933344669, 840.104995983564, 2796.51787745579, 4167.27928087036, 4601.85525836751, 1821.2034900383, 2189.72791435169, 3042.30535389526, 2807.6043315874, 3503.01431953652, 3388.13238117821, 2313.12951730274, 2467.59594581105, 4330.00215695838, 1549.09273602756)
y <- c(920.68690954229, 1137.84149285619, 3714.79810142198, 525.975683495926, 4670.69955143504, 1493.68495554182, 1501.53384921405, 3588.98207281835, 3968.37860894073, 2296.76763280149, 4330.12427328142, 3765.98857808619, 1284.3150461877, 873.118502077055, 1483.53008725903, 815.412154986151, 4463.78018136535, 2968.50399111329, 698.224125591837, 2940.85602751641, 3878.15548230943, 1328.25283484688, 2784.55159286978, 4636.50519901311, 3881.31120249873, 817.73342724717, 3722.86686406547, 4002.31245250477, 3768.33450527414, 3154.10688698431, 2411.51176866728, 866.917134460099, 1396.35278812964, 818.293453576186, 722.016829126236, 2238.2347563775, 3138.27049629683, 1740.86153966934, 2525.9497400303, 4047.11508784272, 1569.12864914224, 1012.76266425136, 4322.80049028206, 981.94215394408, 4365.69066136564, 4532.95964795538, 1866.39445736013, 2121.89400568623, 1246.87146006084, 3985.44742807864, 3685.63400604974, 4105.59891177828, 2412.62820598686, 3828.64123889846, 3713.07718546435, 540.391421247504, 855.176561671193, 4137.8647389367, 4617.94816803374, 2632.57925475935, 1430.77932102484, 585.260671542401, 2791.60379735544, 662.995878839343, 1086.17685213414, 1508.33363397105, 3797.49220034402, 718.455348037237, 821.418280929054, 2320.73366733089, 3037.01065805153, 3744.25557757166, 1137.14346908283, 4043.14398706236, 3384.74681201601, 4193.99080611911, 3956.45258813361, 3960.0950899025, 1500.17773405924, 719.345768310553, 4665.91832227831, 2294.35505152451, 3130.20953126254, 3249.86842440019, 4185.34445315494, 1281.99666198422, 4702.59737079202, 1442.59945303309, 4104.62639132807, 4449.65179752112, 2649.72501474236, 1382.85732689515, 670.466846126166, 1200.25959688326, 930.085277226521, 900.999779024878, 802.132645649877, 683.43691692694, 873.658520876257, 1650.64502017811, 3418.34949699146, 1222.13071728263, 3409.402375469, 843.630081307405, 3998.21173386675, 4683.80520819962, 3676.33980631904, 2177.49853170284, 3325.67118471741, 862.401958786781, 2875.04148289356, 3926.44223954175, 4464.43685925494, 1705.96137858541, 2228.58688259817, 2858.88711631399, 2722.96159936358, 3465.44676305098, 3393.12321104936, 2179.31626722578, 2417.29268343776, 4306.71687173042, 1467.19383715601)

mean.se <- function(x) sqrt(var(x)/length(x)) # std. error of the mean, https://stackoverflow.com/a/2677859/684229

where elements of x and y correspond to each other.

Then we have group means and their standard errors:

> mean(x)
[1] 2583.535
> mean.se(x)
[1] 125.6576
> mean(y)
[1] 2537.709
> mean.se(y)
[1] 122.4061

Now, if we look at the pairwise difference and try to compare it to zero:

> mean(x-y)
[1] 45.82627
> sd(x-y)
[1] 112.3571
> mean.se(x-y)
[1] 10.1309

we see that if we use the standard error of the difference (sd(x-y)), the difference is not significant; whereas if we use the standard error of the mean of the difference (mean.se(x-y)), then it is significant.

Is this difference in direct correspondence to the unpaired vs paired t-test, respectively? Because what I see from t-test looks pretty similar (see below), I am just not sure if statistically and principially these things are linked together:

> t.test(x, y, paired = FALSE)

        Welch Two Sample t-test

data:  x and y
t = 0.26123, df = 243.83, p-value = 0.7941
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -299.7108  391.3633
sample estimates:
mean of x mean of y 
 2583.535  2537.709 

> t.test(x, y, paired = TRUE)

        Paired t-test

data:  x and y
t = 4.5234, df = 122, p-value = 1.422e-05
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 25.77114 65.88139
sample estimates:
mean of the differences 
               45.82627
$\endgroup$
0
$\begingroup$

The answer for the second part is YES: the paired t-test corresponds to the standard error of the mean of the difference. Proof: the formula for paired t-test is

$$t = {{E(x - y) - 0}\over{s_{x-y}\over \sqrt n}}$$ and the denominator is exactly the standard error of the mean of the x - y.

The answer for the question if unpaired t-test corresponds to the standard error of the difference (sd(x - y)) is that it is more complicated. The formula for independent two-sample unpaired t-test (see wikipedia):

$$t = {{E(x) - E(y)}\over {\sqrt{{s^2_x + s^2_y} \over n}}}$$

suggests that the relationship here is slightly different and more complicated.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.