==============================================================================
tDCS GLM report -- scenario: unmerged_full
==============================================================================
merge key: unmerged   day window: 0..26   observations: 185
==============================================================================
DESCRIPTIVES
==============================================================================
group                  n_subj n_sessions  mean_success  mean_rate  max_day
--------------------------------------------------------------------------
Electrode-Box-B2            3         40          77.0      0.591       14
Electrode-Box-A             1         15          70.7      0.557       14
Electrode-Box-A2            3         31          55.4      0.448       13
Naive                       4         76          59.6      0.492       26
Right-Electrode             1         23          85.8      0.627       22

==============================================================================
(A) LEVEL / COUNT -- Poisson GLMM (subject random intercept)
==============================================================================

Generalized linear mixed-effects model fit by PL

Model information:
    Number of observations             185
    Fixed effects coefficients           7
    Random effects coefficients         12
    Covariance parameters                1
    Distribution                    Poisson
    Link                            Log   
    FitMethod                       MPL   

Formula:
    success ~ 1 + group + day_c + day_c2 + (1 | subject)

Model fit statistics:
    AIC       BIC       LogLikelihood    Deviance
    567.38    593.14    -275.69          551.38  

Fixed effects coefficients (95% CIs):
    Name                              Estimate      SE            tStat      DF 
    {'(Intercept)'           }            4.5636      0.062818     72.648    178
    {'group_Electrode-Box-A' }          -0.16366        0.1251    -1.3082    178
    {'group_Electrode-Box-A2'}          -0.16301      0.090874    -1.7939    178
    {'group_Naive'           }          -0.41017      0.083133    -4.9339    178
    {'group_Right-Electrode' }          -0.15781       0.12382    -1.2745    178
    {'day_c'                 }           0.10084     0.0023114     43.629    178
    {'day_c2'                }        -0.0064669    0.00024857    -26.016    178


    pValue         Lower         Upper     
    3.0937e-134        4.4397        4.6876
        0.19249      -0.41052      0.083214
       0.074534      -0.34234      0.016314
     1.8418e-06      -0.57422      -0.24612
        0.20416      -0.40216      0.086543
     5.5938e-97      0.096281        0.1054
     1.4969e-62    -0.0069574    -0.0059764

Random effects covariance parameters:
Group: subject (12 Levels)
    Name1                  Name2                  Type           Estimate
    {'(Intercept)'}        {'(Intercept)'}        {'std'}        0.10379 

Group: Error
    Name                        Estimate
    {'sqrt(Dispersion)'}        1       


==============================================================================
(B) LEVEL / RATE -- Binomial GLMM (subject random intercept)
==============================================================================

Generalized linear mixed-effects model fit by PL

Model information:
    Number of observations             183
    Fixed effects coefficients           7
    Random effects coefficients         12
    Covariance parameters                1
    Distribution                    Binomial
    Link                            Logit 
    FitMethod                       MPL   

Formula:
    success ~ 1 + group + day_c + day_c2 + (1 | subject)

Model fit statistics:
    AIC       BIC       LogLikelihood    Deviance
    664.34    690.01    -324.17          648.34  

Fixed effects coefficients (95% CIs):
    Name                              Estimate      SE           tStat       DF 
    {'(Intercept)'           }           0.67246      0.11921      5.6411    176
    {'group_Electrode-Box-A' }           -0.2656      0.23687     -1.1213    176
    {'group_Electrode-Box-A2'}          -0.42592      0.16928     -2.5161    176
    {'group_Naive'           }          -0.69483      0.15707     -4.4236    176
    {'group_Right-Electrode' }          -0.19395      0.23547    -0.82369    176
    {'day_c'                 }           0.12539    0.0034255      36.605    176
    {'day_c2'                }        -0.0069542    0.0003534     -19.678    176


    pValue        Lower         Upper     
    6.6327e-08        0.4372       0.90772
       0.26369      -0.73306       0.20187
      0.012762      -0.75999     -0.091839
    1.6969e-05       -1.0048      -0.38484
       0.41123      -0.65866       0.27075
    3.2383e-84       0.11863       0.13215
    2.5332e-46    -0.0076517    -0.0062568

Random effects covariance parameters:
Group: subject (12 Levels)
    Name1                  Name2                  Type           Estimate
    {'(Intercept)'}        {'(Intercept)'}        {'std'}        0.19922 

Group: Error
    Name                        Estimate
    {'sqrt(Dispersion)'}        1       


==============================================================================
(C) LEARNING RATE -- Poisson GLMM (group x day interaction)
==============================================================================

Generalized linear mixed-effects model fit by PL

Model information:
    Number of observations             185
    Fixed effects coefficients          11
    Random effects coefficients         12
    Covariance parameters                1
    Distribution                    Poisson
    Link                            Log   
    FitMethod                       MPL   

Formula:
    success ~ 1 + day_c2 + group*day_c + (1 | subject)

Model fit statistics:
    AIC       BIC       LogLikelihood    Deviance
    566.35    604.99    -271.17          542.35  

Fixed effects coefficients (95% CIs):
    Name                                    Estimate      SE            tStat   
    {'(Intercept)'                 }            4.5639      0.066952      68.167
    {'group_Electrode-Box-A'       }           -0.1538       0.13339     -1.1531
    {'group_Electrode-Box-A2'      }          -0.16353      0.097941     -1.6697
    {'group_Naive'                 }           -0.4286      0.088752     -4.8292
    {'group_Right-Electrode'       }          -0.10141       0.13294    -0.76285
    {'day_c'                       }          0.084832     0.0050395      16.833
    {'day_c2'                      }        -0.0071091    0.00030673     -23.177
    {'group_Electrode-Box-A:day_c' }          0.015434     0.0094241      1.6377
    {'group_Electrode-Box-A2:day_c'}          0.010314     0.0089464      1.1529
    {'group_Naive:day_c'           }          0.031147     0.0065742      4.7377
    {'group_Right-Electrode:day_c' }          0.011613      0.007034       1.651


    DF     pValue         Lower         Upper     
    174    1.9324e-127        4.4318        4.6961
    174        0.25047      -0.41707       0.10946
    174       0.096774      -0.35684      0.029772
    174     2.9893e-06      -0.60377      -0.25343
    174        0.44659       -0.3638       0.16097
    174     2.3384e-38      0.074885      0.094778
    174     4.4285e-55    -0.0077145    -0.0065037
    174        0.10329    -0.0031665      0.034034
    174        0.25055    -0.0073435      0.027971
    174     4.4703e-06      0.018171      0.044122
    174        0.10054    -0.0022698      0.025496

Random effects covariance parameters:
Group: subject (12 Levels)
    Name1                  Name2                  Type           Estimate
    {'(Intercept)'}        {'(Intercept)'}        {'std'}        0.11116 

Group: Error
    Name                        Estimate
    {'sqrt(Dispersion)'}        1       


Per-animal OLS slope test (Box-B2 vs Box-A2), cluster-honest:
Per-subject OLS slope of success vs day: Box-B2 mean=7.96, Box-A2 mean=8.19
  Welch two-sided p=0.896, Mann-Whitney p=1.000 (nB=3, nA=3)  -> parallel learning (no slope difference detected)
(Reference only: the GLMM group x day_c joint F-test gives p=0.0000, but with just
 observation-level DF (df2=174) it is ANTICONSERVATIVE for this few-subject design and is
 NOT the basis for the conclusion above.)

==============================================================================
INTERPRETATION
==============================================================================
Note: these are subject-level GLMMs (Laplace-approximated fitglme), not the
Python reference's population-average GEE -- directions/magnitudes should agree,
exact ratios and p-values will differ.

Anchor check -- H2: Box-B2 BETTER than Box-A2 (the two anchors must differ)
  [count/level] Box-B2 = 1.18x Box-A2  (one-sided p=0.0364)  -> SUPPORTED
  [rate/level ] Box-B2 = 1.53x Box-A2  (one-sided p=0.0059)  -> SUPPORTED

Per-animal (Box-B2 n=3 vs Box-A2 n=3), pure stats (no GLME):
  count (per-subject mean success): Welch two-sided p=0.0552, Mann-Whitney one-sided (B2>A2) p=0.0500
  rate  (per-subject pooled success/total): Welch two-sided p=0.0722, Mann-Whitney one-sided (B2>A2) p=0.0500

Classification -- is each UNKNOWN condition A2-like or B2-like?
(ratio >1 = above that anchor; p = differs from that anchor)

  Electrode-Box-A:
    [count/level] vs Box-A2: 1.00x p=0.996   vs Box-B2: 0.85x p=0.192
                 -> AMBIGUOUS (nearer Electrode-Box-A2)
    [rate/level ] vs Box-A2: 1.17x p=0.501   vs Box-B2: 0.77x p=0.264
                 -> AMBIGUOUS (nearer Electrode-Box-A2)

  Right-Electrode:
    [count/level] vs Box-A2: 1.01x p=0.967   vs Box-B2: 0.85x p=0.204
                 -> AMBIGUOUS (nearer Electrode-Box-A2)
    [rate/level ] vs Box-A2: 1.26x p=0.328   vs Box-B2: 0.82x p=0.411
                 -> AMBIGUOUS (nearer Electrode-Box-B2)

  NOTE: each unknown has ONLY 1 subject. 'Matches' means 'not statistically
  distinguishable', weak evidence at n=1, not proof of equivalence.

==============================================================================
CAVEATS
==============================================================================
  - Tiny groups: each arm has only n=3-4 subjects (Naive n=4; anchor arms n=3-5
    depending on merge), and -- in unmerged scenarios -- each unknown condition
    (Electrode-Box-A, Right-Electrode) has only n=1 subject. Treat every group
    comparison here as preliminary.
  - Single-subject classification: for a 1-subject unknown, 'matches anchor X'
    means 'not statistically distinguishable from X', NOT proof of equivalence;
    inference with a single subject in a group is fragile.
  - Count vs rate: 'success' alone is a raw count; the rate model
    (success/attempts) is the fairer accuracy comparison when attempt counts differ
    between groups.
