[R-sig-ME] Multilevel weighted regression

Viechtbauer Wolfgang (STAT) Wolfgang.Viechtbauer at STAT.unimaas.nl
Mon Oct 27 10:12:37 CET 2008


Hi Brant,

This is not a direct answer to your question, but something that still may be useful for you. Using the normal approximation to the log relative risk:

yi    <- c(-0.89, -1.59, -1.35, -1.44, -0.22, -0.79, 
           -1.62,  0.01, -0.47, -1.37, -0.34,  0.45, -0.02)
vi    <- c(0.326, 0.195, 0.415, 0.020, 0.051, 0.007, 
           0.223, 0.004, 0.056, 0.073, 0.012, 0.533, 0.071)
ablat <- c(44, 55, 42, 52, 13, 44, 19, 13, 27, 42, 18, 33, 33)
year  <- c(1948, 1949, 1960, 1977, 1973, 1953, 
           1973, 1980, 1968, 1961, 1974, 1969, 1976)

source("http://www.wvbauer.com/downloads/mima.ssc")

mima(yi, vi, mods=cbind(ablat, year), method="REML")

This is for the random-effects model. To get the same results as your model f1 (without having to go through the adjustment step for the SEs):

mima(yi, vi, mods=cbind(ablat, year), fe="yes")

There is a short tutorial about the function at: http://www.wvbauer.com/downloads.html

I am curious as well to hear how lmer can be used in this context.

Best,

-- 
Wolfgang Viechtbauer
 Department of Methodology and Statistics
 University of Maastricht, The Netherlands
 http://www.wvbauer.com/



----Original Message----
From: r-sig-mixed-models-bounces at r-project.org
[mailto:r-sig-mixed-models-bounces at r-project.org] On Behalf Of Brant
Inman Sent: Monday, October 27, 2008 02:17 To:
r-sig-mixed-models at r-project.org Subject: [R-sig-ME] Multilevel
weighted regression 

> Hi,
> 
> I would like to use lmer to perform a meta-regression using a
> multilevel weighted regression.  I am having difficulty understanding
> how to use weights appropriately with lmer.  I have attached some code
> to demonstrate the type of problem that I will be modeling.
> 
> ---------------
> 
>  > sessionInfo()
> R version 2.7.2 (2008-08-25)
> i386-apple-darwin8.11.1
> 
> locale:
> en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
> 
> other attached packages:
>   [1] nlme_3.1-89        foreign_0.8-29     car_1.2-8
> arm_1.1-15
>   [5] R2WinBUGS_2.1-8    coda_0.13-2        MASS_7.2-44
> lme4_0.999375-24
>   [9] Matrix_0.999375-11 lattice_0.17-13    meta_0.8-2
> 
> loaded via a namespace (and not attached):
> [1] grid_2.7.2
> 
> --------------
> 
> Here is the example code for the BCG dataset of Colditz.
> 
> --------------
> 
> # Get dataset and format it appropriately into wide (BCG) and long
> (BCG.long) datasets
> 
> data('BCG', package='HSAUR')
> 
> logrr      <- log((BCG[,2] / BCG[,3]) / (BCG[,4] / BCG[,5]))
> logrr.var  <- (1/BCG[,2]) + (1/BCG[,4]) - (1/BCG[,3]) - (1/BCG[,5])
> logor	   <- log((BCG[,2]*(BCG[,5]-BCG[,4])) / (BCG[,4]*(BCG[,3]-BCG[,
> 2])))
> logor.var  <- sqrt((1/BCG[,2]) + (1/BCG[,4]) + (1/(BCG[,3]-BCG[,2])) +
> (1/(BCG[,5]-BCG[,4])))
> 
> BCG.long		 <- rbind(BCG[,c(1,6,7)], BCG[,c(1,6,7)])
> 	BCG.long$vaccine <- c(rep(1,13), rep(0,13))
> 	BCG.long$event	 <- c(BCG[,2], BCG[,4])
> 	BCG.long$atrisk	 <- c(BCG[,3], BCG[,5])
> 
> # Fixed effects model using 'lm', RR scale, 2 explanatory variables
> 	f1 <- lm(logrr ~ Latitude + Year, weights = (1/logrr.var), data=BCG)
> 	summary(f1) mse <- sqrt(sum(f1$weights * f1$residuals^2) /
> 	f1$df.residual) sqrt(diag(vcov(f1))) / mse			# Adjust parameter SEs
> for weighting 
> 
> # Fixed effects model using 'lmer', OR scale, no explanatory
> variables f2 <- lmer(cbind(event,atrisk) ~ vaccine + (1 | study),
> 	data=BCG.long, family=binomial) summary(f2)
> 
> # Random effects model using 'lmer', OR scale, no explanatory
> variables f3 <- lmer(cbind(event,atrisk) ~ vaccine + (vaccine |
> 	study), data=BCG.long, family=binomial) summary(f3)
> 
> ---------------
> 
> What I would like to ask help for is:
> 1) How do I do write a weighted model like model 'f1' but using lmer
> so that I can fit a random effects model with covariates on RR scale?
> 
> 2) How do I correctly specify the random effects model 'f3' to
> incorporate the covariates 'Latitude' and 'Year' on the OR scale?
> 
> 
> I appreciate any time that any of you spare for this.
> 
> Brant Inman
> Chapel Hill, NC




More information about the R-sig-mixed-models mailing list