Testing for inverse correlation in grouped data

30 views
Skip to first unread message

Christoph Ruehlemann

unread,
Jul 15, 2023, 8:03:59 AM7/15/23
to statforli...@googlegroups.com
Hi All,

I have data on word frequencies (column `f_0`) in speech turns (`Turnid`), pupil sizes during these turns (`p_0`); the turns are grouped in terms of the number of words they contain (column `size`). I hypothesize that `f_0` and `p_0` are inversely correlated. How can I test this hypothesis?

My hunch is that a mixed-effects model is required to control for `size`which would perhaps best be considered a fixed effect) but am unsure as to how to run the test.

Help is much appreciated.

Chris

    df <- structure(list(Turnid = c(2L, 2L, 2L, 7L, 7L, 7L, 8L, 8L, 8L,
    8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L,
    10L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
    35L, 35L, 35L, 35L, 35L, 36L, 36L, 36L, 38L, 38L, 38L, 41L, 41L,
    41L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 47L, 47L, 47L, 52L, 52L,
    52L, 52L, 52L, 55L, 55L, 55L, 56L, 56L, 56L, 56L, 56L, 60L, 60L,
    60L, 61L, 61L, 61L, 62L, 62L, 62L, 64L, 64L, 64L, 74L, 74L, 74L,
    74L, 74L, 74L, 74L, 77L, 77L, 77L, 77L, 77L, 77L, 77L, 78L, 78L,
    78L, 78L, 78L, 79L, 79L, 79L, 79L, 79L, 83L, 83L, 83L, 83L, 83L,
    83L, 83L, 84L, 84L, 84L, 84L, 84L, 84L, 84L, 87L, 87L, 87L, 89L,
    89L, 89L, 89L, 89L, 90L, 90L, 90L, 92L, 92L, 92L, 95L, 95L, 95L,
    96L, 96L, 96L, 96L, 96L, 96L, 96L, 98L, 98L, 98L, 99L, 99L, 99L,
    99L, 99L, 101L, 101L, 101L, 102L, 102L, 102L, 103L, 103L, 103L,
    105L, 105L, 105L, 111L, 111L, 111L, 119L, 119L, 119L, 122L, 122L,
    122L, 122L, 122L, 125L, 125L, 125L, 125L, 125L, 132L, 132L, 132L,
    132L, 132L, 132L, 132L, 134L, 134L, 134L, 134L, 134L, 137L, 137L,
    137L), f_0 = c(0L, 0L, 0L, 0L, -305L, -302L, 0L, -4932L, -5898L,
    -5969L, -4342L, -5412L, -5165L, 0L, -657L, 3517L, -693L, -813L,
    -847L, -693L, 0L, -1660L, 6367L, -2160L, -2221L, 0L, -8534L,
    -8077L, -7727L, -8113L, 0L, -7004L, -6211L, -8563L, -8077L, -7727L,
    -8295L, 0L, 828L, -190L, -368L, -14L, 0L, 2713L, 2155L, 0L, 23L,
    -5L, 0L, -7655L, -4982L, 0L, -693L, 1530L, -314L, 1402L, -467L,
    1439L, 0L, 2845L, -938L, 0L, 2611L, -5044L, -2371L, -5730L, 0L,
    -8624L, -7471L, 0L, 92L, -784L, 3609L, -576L, 0L, -54L, -170L,
    0L, -7879L, -8572L, 0L, -4245L, -3472L, 0L, 3015L, -521L, 0L,
    85L, 242L, 5823L, 37L, 23L, 1161L, 0L, 1340L, -141L, 1198L, 238L,
    -342L, -336L, 0L, -1481L, -1679L, 2143L, -1681L, 0L, 839L, 1108L,
    12L, 1041L, 0L, 1511L, -5L, 555L, 250L, -2L, -27L, 0L, -7095L,
    -8547L, -8634L, -6625L, -2928L, -8558L, 0L, 2218L, -2327L, 0L,
    -1082L, 711L, -993L, -1134L, 0L, 5928L, -95L, 0L, -575L, -1632L,
    0L, 6998L, -1275L, 0L, -19L, 992L, 1L, 30L, 133L, 15L, 0L, -3472L,
    -758L, 0L, -317L, -317L, -5684L, -4179L, 0L, 696L, 2914L, 0L,
    -3645L, -3823L, 0L, 103L, -50L, 0L, -574L, -1178L, 0L, 172L,
    -3598L, 0L, 6023L, 1681L, 0L, -5982L, -4139L, -3695L, -2159L,
    0L, -7996L, -6618L, -7527L, -8635L, 0L, 799L, 8415L, -54L, 86L,
    987L, -217L, 0L, 1468L, 3686L, -645L, -687L, 0L, 0L, 0L), pp_0 = c(0,
    -10.2489999999999, -76.742, 0, -84.3345, -52.9315, 0, -86.1054999999999,
    -202.575, -345.8325, -365.4495, -111.11, -283.1155, 0, -74.1494999999999,
    113.13, -24.8049999999998, -226.261, -150.2925, -65.6869999999999,
    0, 211.1485, 283.7575, 293.5085, 298.5055, 0, -3.16000000000008,
    -20.6205, -26.8615000000001, -23.2415000000001, 0, -24.9465,
    -11.634, 28.2910000000001, -12.6045, 16.0475, 9.73900000000003,
    0, -512.149, 160.531, 193.6885, 100.648, 0, 43.2165, 27.6395,
    0, -60.3140000000001, -48.638, 0, -144.267, -86.039, 0, 0.774499999999989,
    -6.91149999999993, 11.1030000000001, -242.4975, -1032.6445, 11.5074999999999,
    0, 83.5169999999999, -323.5835, 0, 154.5645, 185.205, 195.114,
    138.33, 0, -28.8835000000001, -77.9325000000001, 0, 6.3195, 23.904,
    38.377, 48.04, 0, 68.8395, -26.1135, 0, 89.5195, 255.0685, 0,
    -43.836, 19.4335, 0, 1.16800000000001, -485.191, 0, 481.2175,
    388.632, 388.112, 401.2195, 399.2115, 419.231, 0, 463.162, 526.033,
    430.1505, 446.2375, 492.2975, 513.056, 0, 56.345, 113.49, 113.5155,
    13.1170000000001, 0, 77.8774999999999, -161.1495, -146.4085,
    -42.6850000000001, 0, -11.521, -3.27750000000003, 55.6655000000001,
    175.6055, 251.2075, 297.9085, 0, 57.3505, 100.587, -46.7595,
    70.2015, -47.6215, -56.2139999999999, 0, -174.103, -144.221,
    0, 27.5314999999999, 73.886, 45.2545, 91.1875, 0, -173.5105,
    -227.9105, 0, 9.3195, -8.06299999999999, 0, -553.3095, 8.58849999999995,
    0, -128.128, -159.1975, -15.4515, 52.7515, 10.034, 14.779, 0,
    14.4200000000001, 52.1495, 0, 189.742166666667, -413.083833333333,
    320.036666666667, 392.994166666667, 0, -11.6709999999998, 36.393,
    0, -40.0230000000001, -14.4065, 0, -69.534, -79.6719999999999,
    0, -38.3870000000001, 13.0965, 0, -2.3694999999999, -30.6329999999999,
    0, -1.24400000000003, -24.101, 0, -471.8995, -61.6135000000002,
    -2.09300000000007, -41.8605, 0, 388.6835, 365.561, 321.0135,
    300.5315, 0, 11.213, -36.5010000000001, -103.36, -158.2555, -192.485,
    -172.593, 0, -411.262, -48.3770000000001, -41.6995000000001,
    -40.2965, 0, 140.4955, 139.6195), size = c(3L, 3L, 3L, 3L, 3L,
    3L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 5L,
    5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
    5L, 5L, 5L, 5L, 5L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 7L, 7L,
    7L, 7L, 7L, 7L, 7L, 3L, 3L, 3L, 5L, 5L, 5L, 5L, 5L, 3L, 3L, 3L,
    5L, 5L, 5L, 5L, 5L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
    3L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 5L,
    5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
    7L, 7L, 7L, 7L, 7L, 7L, 7L, 3L, 3L, 3L, 5L, 5L, 5L, 5L, 5L, 3L,
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 3L,
    3L, 3L, 5L, 5L, 5L, 5L, 5L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
    5L, 5L, 5L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 5L, 5L, 5L, 5L, 5L, 3L,
    3L, 3L)), row.names = c(NA, -199L), class = c("tbl_df", "tbl",
    "data.frame"))

--
Albert-Ludwigs-Universität Freiburg
Projekt-Leiter DFG-Forschungsprojekt "Multimodale Turn-Abschlusssignale"

ἰχθύς

Christoph Ruehlemann

unread,
Jul 15, 2023, 8:20:15 AM7/15/23
to statforli...@googlegroups.com
Hi All,

Here's my question again in **edited** form:

I have data on word frequencies (column f_0) in speech turns (Turnid), pupil sizes during these turns (pp_0); the turns are grouped in terms of number of words they contain (column size). I hypothesize that f_0 and pp_0 are inversely correlated. How can I test this hypothesis?

My hunch is that a mixed-effects model is required to control for size (which would perhaps best be considered a fixed effect) but am unsure as to how to run the test.

EDIT:

Is this the right way to go?

library(lme4)
# Fit the mixed-effects model

model <- lmer(pp_0 ~ f_0 + Turnid +(1 | size), data = F_PP)
Warning message:
Some predictor variables are on very different scales: consider rescaling 

If this is the right way to define the model, what does the summary output (for my actual data, not just the data in df) mean? How can it be interpreted? Does it support the hypothesis?

# Check the model summary
summary(model)
Linear mixed model fit by REML ['lmerMod']
Formula: pp_0 ~ f_0 + Turnid + (1 | size)
   Data: F_PP

REML criterion at convergence: 2453971

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-20.5629  -0.1791  -0.0117   0.1804  21.3419 

Random effects:
 Groups   Name        Variance Std.Dev.
 size     (Intercept)    273.2  16.53  
 Residual             194249.0 440.74  
Number of obs: 163432, groups:  size, 23

Fixed effects:
              Estimate Std. Error t value
(Intercept) 12.2150152  4.1253068   2.961
f_0          0.0013172  0.0003139   4.196
Turnid      -0.0003027  0.0002107  -1.437

Correlation of Fixed Effects:
       (Intr) f_0   
f_0     0.116       
Turnid -0.465 -0.052
fit warnings:
Some predictor variables are on very different scales: consider rescaling

Data:

Reply all
Reply to author
Forward
0 new messages