1

I fitted a linear mixed model using lme function of nlme package in R. My goal is to find a p-value of a linear combination of coefficients of fixed effects part.

                 Value   Std.Error    DF   t-value p-value
(Intercept) -1.5897634 0.019578359 41547 -81.20004  0.0000
group_k      0.0866493 0.027662455   594   3.13238  0.0018
x1           0.1621744 0.006963385 41547  23.28960  0.0000

For example, p-value of the hypothesis $ \beta_1 = 0 $ is provided in this result (0.0018). But if I want to find a p-value of a hypothesis such as $ \beta_1 + 3 * \beta_2 = $, what should I do? Is there any ready-made command to do this calculation?

user67275
  • 1
  • 9
  • 38
  • 64

1 Answers1

6

It would be nice to have a reproducible example. It's not very hard to set up your own test for this:

ct <- c(0,1,3)        ## set up contrast (linear comb. of coefficients)
m <- fixef(m) %*% ct  ## mean of contrast
v <- c(t(ct) %*% vcov(m) %*% ct)   ## variance of contrast
stder <- sqrt(v)      ## standard error
tstat <- m/stder      ## t statistic
2*pt(abs(tstat),df=594,lower.tail=FALSE)

I'm not sure about the degrees of freedom calculation, but all of the df are so large that it won't make any practical difference; you can use pnorm() instead of pt.

If you want the theory, take a look at e.g. the section on Wald tests of contrasts in Dobson and Barnett Generalized Linear Models.

You might also take a look at the effects, lsmeans, and/or multcomp packages.

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453