# [R-sig-ME] A complex mixed model

Bernardo Rangel Tura tura at centroin.com.br
Sun Nov 30 16:06:37 CET 2008

```Hi R-Masters!

I need create a model for predicting a risk of death in heart surgery in
my country. The problem is a very complex nature of the problem.

Essentially the model of risk of death is

Risk(death) ~ risk(patient) + risk(surgery) + risk(site) + error1

but

Risk(patient) ~ clinical variables + error2

Risk(surgery) ~ procedure variables + (Risk(patient)|type) + error3

Risk(site) ~ site + (Risk(surgery)|site)+ (Risk(patient)|site) + error4

A fake database is

site<-sample(rep(LETTERS[1:4],500))
death<-factor(rbinom(2000,1,.16))
cirR<-ifelse(death==1,rbinom(2000,1,.05),rbinom(2000,1,.6))
cirV<-ifelse(cirR==1,rbinom(2000,1,.07),rbinom(2000,1,.7))
type<-factor(cirR+2*cirV)
age<-ifelse(death==1,rpois(2000,55),rpois(2000,30))
sex<-factor(ifelse(death==1,rbinom(2000,1,.4),rbinom(2000,1,.1)))
urg<-factor(ifelse(death==1,rbinom(2000,1,.5),rbinom(2000,1,.01)))
surg<-data.frame(site,cirR,cirV,type,age,sex,urg,death)

in this case

Risk(death) ~ risk(patient) + risk(surgery) + risk(site) + error1

Risk(patient) ~ age + sex + error2

Risk(surgery) ~ type + urg + (Risk(patient)|type) + error3

Risk(site) ~ site + (Risk(surgery)|site) + (Risk(patient)|site) + error4

I am having trouble to write a correct formula for this model. It would
be nice to count with your help.

--
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil

```