I aim to estimate one populations mean blood pressure during different years. Here is the setting: (1) 7400 onservations; repeated measurements. Unbalanced. (2) measurements are undertaken anually from 2001 to 2012. Eachindividual maybe measured several times. (3) one can expect a time-bias, i.e as time progress, there will be made advances in therapy, which will lead to more efficient blood pressure lowering. These factors will not be taken into account. Deliberately.

Aim: estimate population mean blood pressure each year. Including confidence interval.

Methods: use lme4 package (linear outcome, blood pressure) to account for repeated measurements and lsmeans package to estimate the population mean each year.


fit <- lmer(bloodpressure ~ year + age + sex + (1 | patient_id), data=data)

'year' is the factor variable for which I'd like to obtsin the means.

lsmeans(fit, ~ year) # not tried

Questions - is this method OK? - will the covariance be respected by using lsmeans, or should I use lmerTest package which has a built in function for estimating lsmeans? - each individual has a random slope in the call above, should I adjust it to include random effects for year also?

Thanks for any advice on this

  • 1
    $\begingroup$ The lsmeans package DOES use the ccorrect ovariate matrix from the object. If you look in the vignettes, you'll find some examples with models fitted with lmer. $\endgroup$ – Russ Lenth Dec 28 '14 at 23:40
  • $\begingroup$ Thanks @rvl. And the results appear plausible after comparing with crude figures. I'm only using a random term for individual. Id you could provide your comment as answer instead I can approve the question as answered. $\endgroup$ – Adam Robinsson Dec 29 '14 at 16:22

The lsmeans package does produce the correct results with model objects from a number of packages, including lme4. If you have a fairly recent update of lsmeans installed, you can do ? models and see information on what model objects are supported, and details of any special provisions.

  • 2
    $\begingroup$ What's the difference between lmertest, mertools and lsmeans? $\endgroup$ – skan May 8 '17 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.