2

I'm currently running a time series analysis which requires me to fit lmer models to each of my data points. Here is my code :

# import data
dt <- h5read('file.h5', 'd1/table')
dt$cond <- as.factor(dt$cond)
dt$sub <- as.factor(dt$sub)

# close file
H5close()

# apply model to each time point
fitted <- by(dt, dt$tp, function(x) lmer(size ~ cond + (1 + cond | sub), data = x))

In this model, cond is a 2 levels fixed effect factor and sub is a 14 levels random effect factor. For some reason, the model doesn't yield a t-value in its ouput :

> fitted[1]
$`0`
Linear mixed model fit by REML ['lmerMod']
Formula: size ~ cond + (1 + cond | sub)
   Data: x
REML criterion at convergence: -7694.797
Random effects:
 Groups   Name        Std.Dev.  Corr 
 sub      (Intercept) 1.388e-02      
          cond1       1.169e-05 -1.00
 Residual             7.922e-02      
Number of obs: 3467, groups:  sub, 14
Fixed Effects:
(Intercept)        cond1  
   0.023743    -0.001154

Is it the output I should have expected? It seems that R doesn't take the difference between both levels of cond into account.

Robert Long
  • 53,316
  • 10
  • 84
  • 148
Crolle
  • 123
  • 2
  • 1
    Possible duplicate of [Getting P value with mixed effect with lme4 package](http://stats.stackexchange.com/questions/118416/getting-p-value-with-mixed-effect-with-lme4-package) – Tim May 18 '16 at 10:13

1 Answers1

3

You can obtain t statistics for the fixed effects estimates by using the summary() function. For example:

require(lme4) 
fm1 <- lmer ( Reaction ~ Days + ( Days | Subject ), sleepstudy )
summary(fm1)

Linear mixed model fit by REML ['lmerMod']
Formula: Reaction ~ Days + (Days | Subject)
   Data: sleepstudy

REML criterion at convergence: 1743.6

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-3.9536 -0.4634  0.0231  0.4634  5.1793 

Random effects:
 Groups   Name        Variance Std.Dev. Corr
 Subject  (Intercept) 612.09   24.740       
          Days         35.07    5.922   0.07
 Residual             654.94   25.592       
Number of obs: 180, groups:  Subject, 18

Fixed effects:
            Estimate Std. Error t value
(Intercept)  251.405      6.825   36.84
Days          10.467      1.546    6.77

Correlation of Fixed Effects:
     (Intr)
Days -0.138
Robert Long
  • 53,316
  • 10
  • 84
  • 148
  • The output above is already a summary. But for some reason, I have no t-value in mine. – Crolle May 18 '16 at 11:36
  • 1
    @Crolle, no your code just outputs the model object itself. `summary()` is different. Use `summary(fitted[1])` instead – Robert Long May 18 '16 at 12:04
  • actually you were almost there : `summary(fitted[[1]])` works just fine. Not used to these brackets yet! – Crolle May 18 '16 at 12:21