[R] Comparing two diagnostic tests with lme4

Michael Dewey lists at dewey.myzen.co.uk
Mon Jul 4 09:44:05 CEST 2016


Dear Keno

I am not sure from your description what your scientific question is but 
if you want to bring together a number of diagnostic test results and 
then see the influence of moderator variables you might want to 
investigate packages directed at meta-analysis. I have used mada but 
there are others mentioned in the CRAN Task View on MetaAnalysis.

Apologies if I have misunderstood you.

On 03/07/2016 19:27, Keno Kyrill Bressem wrote:
> Dear R experts,
>
> I compare two diagnostic tests. Therfore, I collected patient data from
> several studies. The dataframe is similar to this one:
>
> set.seed(10)
> data = data.frame( test1 = rbinom(1000, 1, 0.6),
>                    test2 = rbinom(1000, 1, 0.4),
>                    reference = rbinom(1000, 1, 0.7),
>                    study = sort(paste("study_", round(runif(1000, 1, 20),0)
> ,sep = "")),
>                    id = 1:1000,
>                    age = round(rnorm(1000, 60, 10), 0))
>
> I did a lot of research on how to use hierarchical models for calculating
> the respective sensitivities and specifities for my tests and tried a lot
> of variations in the formula of  glmer. However, I don't have sufficient
> statistical knowledge for interpreting these models. So I don't know if my
> approach is correct. Therfore I am showing you my latest model.
>
> First, I would like to calculate the logit sensitivity and specifity for
> each test. In a paper by Genders et al.
> <http://pubs.rsna.org/doi/suppl/10.1148/radiol.12120509> (appendices)
> <http://pubs.rsna.org/doi/suppl/10.1148/radiol.12120509/suppl_file/12120509appendices.pdf>
> a Stata code to calculate the logit sensitivity and specifity is provided.
> I transferred this code to "R", but I am not sure if it's correct this way.
>
>
> m.sen <- glmer(test1 ~ ( 1 | study) + ( 1 | id ), data = subset(data,
> reference == 1), family = binomial(link = "logit"),
> control = glmerControl(optimizer = "bobyqa"), nAGQ = 1)
>
> # require("useful")
> m.spe <-  glmer(binary.flip(test1) ~ ( 1 | study) + ( 1 | id ), data =
> subset(data, reference == 0), family = binomial(link = "logit"),
>  control = glmerControl(optimizer = "bobyqa"), nAGQ =
>
> logit.sen = fixef(m.sen)
> logit.spe = fixef(m.spe)
>
>
> My first question is if it is possible to calculate the logit sensitivity
> and specifity of a diagnostic test like this. The next step would be to
> adjust for different patient characteristics, such as age.
>
> data <- within(data, {age = as.factor(round(age, -1))})
> m.sen.age <- glmer(test1 ~ age + ( 1 | study) + ( 1 | id ), data =
> subset(data, reference == 1),
> family = binomial(link = "logit"), control = glmerControl(optimizer =
> "bobyqa"), nAGQ = 1)
> fix <- fixef(m.sen.age)
>
> Now I add the estimates. For example, to determine the logit sensitivity of
> test1 in patients aged between 55 and 65: sen.50 = fix[1] + fix[5]
> As an alternative, I thought about further defining the data subset, which
> produces nearly identically results.
>
> m.sen.age <- glmer(test1 ~ ( 1 | study) + ( 1 | id ), data = subset(data,
> reference == 1 & age == 60),
> family = binomial(link = "logit"), control = glmerControl(optimizer =
> "bobyqa"), nAGQ = 1)
> sen.age50 = fixef(m.sen.age)
>
> Thank you very much in advance
> kb
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Michael
http://www.dewey.myzen.co.uk/home.html



More information about the R-help mailing list