==============================================================================
tDCS GLM report -- scenario: mergeB2_full
==============================================================================
merge key: mergeB2   day window: 0..26   observations: 185
==============================================================================
DESCRIPTIVES
==============================================================================
group                  n_subj n_sessions  mean_success  mean_rate  max_day
--------------------------------------------------------------------------
Electrode-Box-B2            5         78          78.4      0.596       22
Electrode-Box-A2            3         31          55.4      0.448       13
Naive                       4         76          59.6      0.492       26

==============================================================================
(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           5
    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
    565.84    585.16    -276.92          553.84  

Fixed effects coefficients (95% CIs):
    Name                              Estimate     SE            tStat      DF 
    {'(Intercept)'           }           4.4986      0.054066     83.206    180
    {'group_Electrode-Box-A2'}        -0.096187       0.09052    -1.0626    180
    {'group_Naive'           }         -0.34448      0.080981    -4.2538    180
    {'day_c'                 }          0.10082     0.0023113     43.621    180
    {'day_c2'                }         -0.00647    0.00024877    -26.008    180


    pValue         Lower         Upper     
    1.3263e-145        4.3919        4.6053
        0.28939       -0.2748       0.08243
     3.3739e-05      -0.50427      -0.18468
     1.2306e-97      0.096261       0.10538
     7.2052e-63    -0.0069609    -0.0059791

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

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           5
    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
    661.88    681.14    -324.94          649.88  

Fixed effects coefficients (95% CIs):
    Name                              Estimate      SE            tStat      DF 
    {'(Intercept)'           }           0.57975      0.098046      5.913    178
    {'group_Electrode-Box-A2'}          -0.33262       0.16122    -2.0631    178
    {'group_Naive'           }          -0.60174       0.14641    -4.1098    178
    {'day_c'                 }           0.12534     0.0034238     36.607    178
    {'day_c2'                }        -0.0069519    0.00035349    -19.666    178


    pValue        Lower         Upper     
    1.6792e-08       0.38627       0.77323
      0.040554      -0.65077     -0.014466
    6.0348e-05      -0.89067      -0.31281
    9.0274e-85       0.11858       0.13209
    1.6927e-46    -0.0076494    -0.0062543

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

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           7
    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
    560.22    585.99    -272.11          544.22  

Fixed effects coefficients (95% CIs):
    Name                                    Estimate     SE            tStat  
    {'(Intercept)'                 }            4.516      0.055699     81.079
    {'group_Electrode-Box-A2'      }         -0.11558      0.094376    -1.2247
    {'group_Naive'                 }         -0.38342      0.083677    -4.5821
    {'day_c'                       }         0.092386     0.0030001     30.794
    {'day_c2'                      }        -0.006943    0.00027446    -25.297
    {'group_Electrode-Box-A2:day_c'}        0.0036285     0.0081693    0.44417
    {'group_Naive:day_c'           }         0.022361     0.0042611     5.2476


    DF     pValue        Lower         Upper     
    178    1.781e-142        4.4061        4.6259
    178       0.22231      -0.30182      0.070658
    178    8.6367e-06      -0.54854      -0.21829
    178    3.1867e-73      0.086466      0.098307
    178    7.6668e-61    -0.0074846    -0.0064014
    178       0.65746     -0.012493       0.01975
    178    4.3478e-07      0.013952       0.03077

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

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=6.98, Box-A2 mean=8.19
  Welch two-sided p=0.508, Mann-Whitney p=0.786 (nB=5, 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=178) 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.10x Box-A2  (one-sided p=0.1440)  -> not supported
  [rate/level ] Box-B2 = 1.39x Box-A2  (one-sided p=0.0196)  -> SUPPORTED

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

(No unknown groups -- they were merged into the anchors; only the H2 anchor
contrast applies.)

==============================================================================
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.
