62
Motivation Extended GLMM models Some new models Future directions Extended multivariate generalised linear and non-linear mixed eects models Stata UK Meeting Cass Business School 7th September 2017 Michael J. Crowther Biostatistics Research Group, Department of Health Sciences, University of Leicester, UK, [email protected] @Crowther MJ Funding: MRC (MR/P015433/1) Michael J. Crowther megenreg 7th September 2017 1 / 44

Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Embed Size (px)

Citation preview

Page 1: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Extended multivariate generalised linear

and non-linear mixed effects models

Stata UK MeetingCass Business School7th September 2017

Michael J. Crowther

Biostatistics Research Group,Department of Health Sciences,University of Leicester, UK,

[email protected]@Crowther MJ

Funding: MRC (MR/P015433/1)

Michael J. Crowther megenreg 7th September 2017 1 / 44

Page 2: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Outline

• Motivation for this work

• Extended multivariate generalised linear and non-linearmixed effects models

• megenreg

• Methods development using megenreg

• Future directions

Michael J. Crowther megenreg 7th September 2017 2 / 44

Page 3: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Motivation

• More data → more questions

need for appropriate statistical modelling techniques,and implementations

• Growth in access to EHR

biomarkers < patients < GP practice area <geographical regions...

• More challenges

time-dependent effects, non-linear covariate effects

We need modelling frameworks that can accommodatea lot of different things

Michael J. Crowther megenreg 7th September 2017 3 / 44

Page 4: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Motivation

• More data → more questions

need for appropriate statistical modelling techniques,and implementations

• Growth in access to EHR

biomarkers < patients < GP practice area <geographical regions...

• More challenges

time-dependent effects, non-linear covariate effects

We need modelling frameworks that can accommodatea lot of different things

Michael J. Crowther megenreg 7th September 2017 3 / 44

Page 5: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Motivation

• More data → more questions

need for appropriate statistical modelling techniques,and implementations

• Growth in access to EHR

biomarkers < patients < GP practice area <geographical regions...

• More challenges

time-dependent effects, non-linear covariate effects

We need modelling frameworks that can accommodatea lot of different things

Michael J. Crowther megenreg 7th September 2017 3 / 44

Page 6: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Motivation

• More data → more questions

need for appropriate statistical modelling techniques,and implementations

• Growth in access to EHR

biomarkers < patients < GP practice area <geographical regions...

• More challenges

time-dependent effects, non-linear covariate effects

We need modelling frameworks that can accommodatea lot of different things

Michael J. Crowther megenreg 7th September 2017 3 / 44

Page 7: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Motivation

Joint longitudinal-survival models

0.0

0.2

0.4

0.6

0.8

1.0

Survival probability

0

50

100

150

200B

iom

arke

r

0 2 4 6 8 10 12 14Follow-up time

Patient 98

0.0

0.2

0.4

0.6

0.8

1.0S

urvival probability

0

50

100

150

200

Bio

mar

ker

0 2 4 6 8 10 12 14Follow-up time

Patient 253

Longitudinal response Longitudinal fitted valuesPredicted conditional survival 95% Confidence interval

Linking via - current value, gradient, AUC, random effects...

Michael J. Crowther megenreg 7th September 2017 4 / 44

Page 8: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Motivation

Joint longitudinal-survival models - extensions

• Competing risks [1]

• Different types of outcomes [2]

• Multiple continuous outcomes [3]

• Delayed entry [4]

• Recurrent events and a terminal event [5]

• Prediction [6]

• Many others...

Michael J. Crowther megenreg 7th September 2017 5 / 44

Page 9: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Motivation

Joint longitudinal-survival models - software

• stjm in Stata [7]

• gsem in Stata, see Yulia’s talk from last year

• frailtypack in R [8]

• joineR in R [9]

• JM and JMBayes in R [10, 11]

• Many others...

Michael J. Crowther megenreg 7th September 2017 6 / 44

Page 10: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Motivation

(My) Methods development - software

• stjm - joint longitudinal-survival models

• stmixed - multilevel survival models

• stgenreg - general parametric survival models

• ...

Each new project brings a new code base to maintain...could Imake my life easier?

Michael J. Crowther megenreg 7th September 2017 7 / 44

Page 11: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Motivation

(My) Methods development - software

• stjm - joint longitudinal-survival models

• stmixed - multilevel survival models

• stgenreg - general parametric survival models

• ...

Each new project brings a new code base to maintain...could Imake my life easier?

Michael J. Crowther megenreg 7th September 2017 7 / 44

Page 12: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

The goal

A general framework for the analysis of data of all types

• Multiple outcomes of varying types

• Measurement schedule can vary across outcomes

• Any number of levels and random effects

• Sharing and linking random effects between outcomes

• Sharing functions of the expected value of other outcomes

• A reliable estimation engine

• Easily extendable by the user

• ...

I think I made my life more difficult!

Michael J. Crowther megenreg 7th September 2017 8 / 44

Page 13: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

The goal

A general framework for the analysis of data of all types

• Multiple outcomes of varying types

• Measurement schedule can vary across outcomes

• Any number of levels and random effects

• Sharing and linking random effects between outcomes

• Sharing functions of the expected value of other outcomes

• A reliable estimation engine

• Easily extendable by the user

• ...

I think I made my life more difficult!

Michael J. Crowther megenreg 7th September 2017 8 / 44

Page 14: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

The goal

Extended multivariate generalised linear and non-linearmixed effects models

megenreg

• Much of what megenreg can do, can be done (better)with gsem

• Much of what megenreg can do, cannot be done withgsem

Michael J. Crowther megenreg 7th September 2017 9 / 44

Page 15: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

The goal

Extended multivariate generalised linear and non-linearmixed effects models

megenreg

• Much of what megenreg can do, can be done (better)with gsem

• Much of what megenreg can do, cannot be done withgsem

Michael J. Crowther megenreg 7th September 2017 9 / 44

Page 16: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

The goal

Extended multivariate generalised linear and non-linearmixed effects models

megenreg

• Much of what megenreg can do, can be done (better)with gsem

• Much of what megenreg can do, cannot be done withgsem

Michael J. Crowther megenreg 7th September 2017 9 / 44

Page 17: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

A general level likelihood

Straight from the Stata manual...for a one-level model with nresponse variables:

p(y|x, b,β) =n∏i=1

pi(yi|x, b,β)

For a two-level model:

p(y|x, b,β) =n∏i=1

t∏j=1

pi(yij|x, b,β)

Michael J. Crowther megenreg 7th September 2017 10 / 44

Page 18: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

A general level likelihood

The log likelihood is obtained by integrating out theunobserved random effects

ll(β) = log

∫Rr

p(y|x, b,β)φ(b|Σb) db

we assume φ() is the multivariate normal density for b, withmean vector 0 and variance-covariance matrix Σb. We haveΣb becoming block diagonal with further levels, with a blockfor each level

Michael J. Crowther megenreg 7th September 2017 11 / 44

Page 19: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

A general level likelihood

Alternatively, exploiting conditional independence amongstlevel l − 1 units, given the random effects at higher levels,

ll(β) = log

∫φ(b(L)|Σ(L))

∏p(L−1)(y|x, bL,β) db(L)

where, for l = 2, . . . , L

p(l)(y|x,Bl+1,β) =

∫φ(b(l)|Σ(l))

∏p(l−1)(y|x,Bl,β) db(l)

Michael J. Crowther megenreg 7th September 2017 12 / 44

Page 20: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Estimation challenges

• At each level, we need to integrate out our normallydistributed random effects

• Generally this is done using Gauss-Hermite numericalquadrature

intmethod(mvaghermite | ghermite)

• Issue with GH quadrature is it doesn’t scale up well:

- 7-point quadrature; for 1 random effect we evaluate ourfunction at 7-points

- 7-point quadrature; for 6 random effects, we evaluate itat 76 = 117, 649 points

Michael J. Crowther megenreg 7th September 2017 13 / 44

Page 21: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Estimation challenges - alternatives

• An alternative is Monte Carlo integration

• Also known for its use in maximum simulated likelihood -see the special issue in the Stata Journal Vol 6 No 2

• This is a rather brute force approach, but it’s usefulness isin it’s simplicity

L(θ) =

∫f(y|θ, b)φ(b)∂b =

1

m

m∑u=1

f(y|θ, bu)

The important thing to note is m doesn’t have to changewhen extra random effects are added.

Michael J. Crowther megenreg 7th September 2017 14 / 44

Page 22: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Estimation challenges - alternatives

Monte Carlo integration can be improved by:

• antithetic sampling [12]

• Halton sequences [13]

• an adaptive procedure just like adaptive GH quadrature,resulting in an importance sampling approximation

Michael J. Crowther megenreg 7th September 2017 15 / 44

Page 23: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Extensions - level-specific random effect distributions

ll(θ) = log

∫φL(b(L)|Σ(L))

∏p(L−1)(y|x, bL,β) db(L)

where, for l = 2, . . . , L

p(l)(y|x,Bl+1,β) =

∫φl(b

(l))|Σ(l)∏

p(l−1)(y|x,Bl,β) db(l)

Michael J. Crowther megenreg 7th September 2017 16 / 44

Page 24: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Extensions - level-specific random effect distributionsand integration techniques

• This formulation now allows us to specify differentdistributions at each level

• Assess robustness using the t-distribution

• Issue of which integration techniques to apply at eachlevel• e.g. one random effect at level 1, many at level 2, then

use AGHQ at level 3, and MCI at level 2

intmethod(mvaghermite mcarlo)

redistribution(normal t) df(3)

Michael J. Crowther megenreg 7th September 2017 17 / 44

Page 25: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Standard linear predictor

The standard linear predictor for a general level model can bewritten as follows,

η = Xβ +L∑l=2

X lbl

where subscripts are omitted. We have X our vector ofcovariates, which could vary at any level, with associated fixedeffect coefficient vector β, and X l the vector of covariateswith random effects bl at level l.

Michael J. Crowther megenreg 7th September 2017 18 / 44

Page 26: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Extended linear predictor

ηi = gi(E[yi|X, b]) =

Ri∑r=1

Sir∏s=1

ψirs

where gi() is the link function for the ith outcome. Tomaintain generality, ψirs(t) can take many forms, including,

ψirs(t) = X

ψirs(t) = β

ψirs(t) = b

ψirs(t) = q(t)

ψirs(t) = drs(E[yj]), where j = 1, . . . , k, j 6= i

Michael J. Crowther megenreg 7th September 2017 19 / 44

Page 27: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Michael J. Crowther megenreg 7th September 2017 20 / 44

Page 28: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

megenreg in Stata

• Everything I’ve talked about will be available in themegenreg package in Stata

• It is a simplified/modified version of Stata’s official gsem

• megenreg will have many extensions, such as• Alternative models, such as spline based survival models• Extending sharing between outcomes, motivated by joint

modelling• User-defined likelihood functions• Other things...

Michael J. Crowther megenreg 7th September 2017 21 / 44

Page 29: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Distributional choices

• Gaussian, Poisson, binomial, beta, negative binomial

• exponential, Weibull, Gompertz, log-normal, log-logistic,gamma, Royston-Parmar

• Non-linear outcome models

• User-defined hazard functions

• More to add...

Michael J. Crowther megenreg 7th September 2017 22 / 44

Page 30: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

1. A general level parametric survival model

The Royston-Parmar survival model uses restricted cubicsplines of log time, on the log cumulative hazard scale, i.e.,

logH(yi) = s(log(yi)|βk) + ηi

. list patient time infect age female in 1/4, noobs

patient time infect age female

1 8 1 28 01 16 1 28 02 13 0 48 12 23 1 48 1

. megenreg (time age female M1[patient], ///> family(rp, failure(infect) scale(h) df(3)))

Michael J. Crowther megenreg 7th September 2017 23 / 44

Page 31: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

1. A general level parametric survival model

Relax the normally dist. random effects assumption;. megenreg (time age female M1[patient], family(rp, failure(infect) scale(h) df(3))) ///> , redistribution(t) df(3)

Higher levels of clustering;. megenreg (time trt M1[trial] M2[trial>patient], ...)

Random coefficients;. megenreg (time trt M1[trial] trt#M1[trial] M2[trial>patient], ... )

Time-dependent effects;. megenreg (stime trt trt#{log(&t)} M1[id1] M2[id1>id2], ... timevar(stime))

Non-linear covariate effects. gen age2 = age^2. megenreg (stime trt trt#{log(&t)} age age2 M1[id1] M2[id1>id2], ... )

Michael J. Crowther megenreg 7th September 2017 24 / 44

Page 32: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

1. A general level parametric survival model

Relax the normally dist. random effects assumption;. megenreg (time age female M1[patient], family(rp, failure(infect) scale(h) df(3))) ///> , redistribution(t) df(3)

Higher levels of clustering;. megenreg (time trt M1[trial] M2[trial>patient], ...)

Random coefficients;. megenreg (time trt M1[trial] trt#M1[trial] M2[trial>patient], ... )

Time-dependent effects;. megenreg (stime trt trt#{log(&t)} M1[id1] M2[id1>id2], ... timevar(stime))

Non-linear covariate effects. gen age2 = age^2. megenreg (stime trt trt#{log(&t)} age age2 M1[id1] M2[id1>id2], ... )

Michael J. Crowther megenreg 7th September 2017 24 / 44

Page 33: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

1. A general level parametric survival model

Relax the normally dist. random effects assumption;. megenreg (time age female M1[patient], family(rp, failure(infect) scale(h) df(3))) ///> , redistribution(t) df(3)

Higher levels of clustering;. megenreg (time trt M1[trial] M2[trial>patient], ...)

Random coefficients;. megenreg (time trt M1[trial] trt#M1[trial] M2[trial>patient], ... )

Time-dependent effects;. megenreg (stime trt trt#{log(&t)} M1[id1] M2[id1>id2], ... timevar(stime))

Non-linear covariate effects. gen age2 = age^2. megenreg (stime trt trt#{log(&t)} age age2 M1[id1] M2[id1>id2], ... )

Michael J. Crowther megenreg 7th September 2017 24 / 44

Page 34: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

1. A general level parametric survival model

Relax the normally dist. random effects assumption;. megenreg (time age female M1[patient], family(rp, failure(infect) scale(h) df(3))) ///> , redistribution(t) df(3)

Higher levels of clustering;. megenreg (time trt M1[trial] M2[trial>patient], ...)

Random coefficients;. megenreg (time trt M1[trial] trt#M1[trial] M2[trial>patient], ... )

Time-dependent effects;. megenreg (stime trt trt#{log(&t)} M1[id1] M2[id1>id2], ... timevar(stime))

Non-linear covariate effects. gen age2 = age^2. megenreg (stime trt trt#{log(&t)} age age2 M1[id1] M2[id1>id2], ... )

Michael J. Crowther megenreg 7th September 2017 24 / 44

Page 35: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

1. A general level parametric survival model

Relax the normally dist. random effects assumption;. megenreg (time age female M1[patient], family(rp, failure(infect) scale(h) df(3))) ///> , redistribution(t) df(3)

Higher levels of clustering;. megenreg (time trt M1[trial] M2[trial>patient], ...)

Random coefficients;. megenreg (time trt M1[trial] trt#M1[trial] M2[trial>patient], ... )

Time-dependent effects;. megenreg (stime trt trt#{log(&t)} M1[id1] M2[id1>id2], ... timevar(stime))

Non-linear covariate effects. gen age2 = age^2. megenreg (stime trt trt#{log(&t)} age age2 M1[id1] M2[id1>id2], ... )

Michael J. Crowther megenreg 7th September 2017 24 / 44

Page 36: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

2. A general level relative survival model

Relative survival models are used widely, particularly inpopulation based cancer epidemiology [14]. They model theexcess mortality in a population with a particular disease,compared to a reference population.

h(y) = h∗(y) + λ(y)

where h∗(y) is the expected mortality in the referencepopulation. Any of the previous models can be turned into arelative survival model;

. megenreg (stime trt trt#log(&t) M1[id1] M2[id1>id2], ///> family(rp, failure(died) df(3) scale(h) bhazard(bhaz)))

Michael J. Crowther megenreg 7th September 2017 25 / 44

Page 37: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

3. General level joint frailty survival models

• An area of intense research in recent years is in the fieldof joint frailty survival models, for the analysis of jointrecurrent event and terminal event data

• Here I focus on the two most popular approaches,proposed by Liu et al. (2004) [15] and Mazroui et al.(2012) [16]

• In both, we have a survival model for the recurrent eventprocess, and a survival model for the terminal eventprocess, linked through shared random effects

Michael J. Crowther megenreg 7th September 2017 26 / 44

Page 38: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

3. General level joint frailty survival models

hij(y) = h0(y) exp(X1ijβ1 + bi)

λi(y) = λ0(y) exp(X1iβ2 + αbi)

where hij(y) is the hazard function for the jth event of the ithpatient, λi(y) is the hazard function for the terminal event,and bi ∼ N(0, σ2). We can fit such a model with megenreg,adjusting for treatment in each outcome model,

. megenreg (rectime trt M1[id1] , family(rp, failure(recevent) scale(h) df(5))) ///> (stime trt M1[id1]@alpha , family(rp, failure(died) scale(h) df(3)))

Michael J. Crowther megenreg 7th September 2017 27 / 44

Page 39: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

3. General level joint frailty survival models

hij(y) = h0(y) exp(X1ijβ1 + b1i + b2i)

λi(y) = λ0(y) exp(X1iβ2 + b2i)

where b1i ∼ N(0, σ21) and b2i ∼ N(0, σ2

2). We give an exampleof how to fit this model with megenreg, this time illustratinghow to use different distributions for the recurrent event andterminal event processes,

. megenreg (rectime trt M1[id1] M2[id1] , family(weibull, failure(recevent))) ///> (stime trt M2[id1] , family(rp, failure(died) scale(h) df(3)))

Michael J. Crowther megenreg 7th September 2017 28 / 44

Page 40: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

4. Generalised multivariate joint models

Multiple longitudinal biomarkers

Y1 ∼ Weib(λ, γ), Y2 ∼ N(µ2, σ22), Y3 ∼ N(µ3, σ

23)

The linear predictor of the survival outcome can be written asfollows,

η1(t) = Xβ0+E[y2(t)|η2(t)]β1 + E[y3(t)|η3(t)]β2+E[y2(t)|η2(t)]× E[y3(t)|η3(t)]β3

. megenreg (stime trt EV[logb]@beta1 EV[logp]@beta2 EV[logb]#EV[logp]@beta3 ,> family(weibull, failure(died)))> (logb {&t}@l1 {&t}#M2[id] M1[id] , family(gaussian) timevar(time))> (logp {&t}@l2 {&t}#M4[id] M3[id] , family(gaussian) timevar(time))> , covariance(unstructured)

Michael J. Crowther megenreg 7th September 2017 29 / 44

Page 41: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

4. Generalised multivariate joint models

Competing risks

. list id logb logp time trt stime diedpbc diedother if id==3, noobs

id logb logp time trt stime diedpbc diedother

3 .3364722 2.484907 0 D-penicil 2.77078 1 03 .0953102 2.484907 .481875 D-penicil . . .3 .4054651 2.484907 .996605 D-penicil . . .3 .5877866 2.587764 2.03428 D-penicil . . .

. megenreg (stime trt EV[logb]@a1 EV[logp]@a2 , family(weibull, failure(diedpbc)))> (stime trt EV[logb]@a3 EV[logp]@a4 , family(gompertz, failure(diedother)))> (logb {&t}@l1 {&t}#M2[id] M1[id] , family(gaussian) timevar(time))> (logp {&t}@l2 {&t}#M4[id] M3[id] , family(gaussian) timevar(time))

Michael J. Crowther megenreg 7th September 2017 30 / 44

Page 42: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

4. Generalised multivariate joint models

Joint frailty - The extensive frailtypack in R has recentlybeen extended to fit a joint model of a continuous biomarker,a recurrent event process, and a terminal event [5, 8]. We canuse megenreg,

. megenreg (canctime trt EV[logb]@a1 EV[logp]@a2 M5[id] , ... )> (stime trt EV[logb]@a4 EV[logp]@a5 M5[id]@alpha , ... )> (logb {&t}@l1 {&t}#M2[id] M1[id] , ... )> (logp {&t}@l2 {&t}#M4[id] M3[id] , ... )

Michael J. Crowther megenreg 7th September 2017 31 / 44

Page 43: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

4. Generalised multivariate joint models

. megenreg (canctime trt EV[logb]@a1 EV[logp]@a2 , family(weibull, failure(canc))) ///> (stimenocanc trt EV[logb]@a4 EV[logp]@a5 , ///> family(gompertz, failure(diednocanc) ltrunc(canctime)) ///> (stimecanc trt EV[logb]@a4 EV[logp]@a5 , family(gompertz, failure(diedcanc))) ///> (logb {&t}@l1 {&t}#M2[id] M1[id] , family(gaussian) timevar(time)) ///> (logp {&t}@l2 {&t}#M4[id] M3[id] , family(gaussian) timevar(time))

Michael J. Crowther megenreg 7th September 2017 32 / 44

Page 44: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

5. A user-defined model - utility functions

A Gaussian response model

y ∼ N(η, σ2)

real matrix gauss logl(transmorphic gml){

y = gml util depvar(gml) //dep. var.linpred = gml util xzb(gml) //lin. pred.sdre = exp(gml util xb(gml,1)) //anc. param.return(lnnormalden(y,linpred,sdre)) //logl

}

. megenreg (logb time time#M2[id] M1[id], family(user, loglf(gauss logl)) np(1))

Michael J. Crowther megenreg 7th September 2017 33 / 44

Page 45: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

6. A NLME example with multiple linear predictors

Consider Murawska et al. (2012), they developed a BayesianNL joint model, with Gaussian response variable, and multiplenon-linear predictors each with fixed effects and a randomintercept. The overall non-linear predictor is defined as,

f(t) = β1i + β2i exp−β3it

where each linear predictor was constrained to be positive,

β1i = exp(X1β1 + b1i)

β2i = exp(X2β2 + b2i)

β3i = exp(X3β3 + b3i)

and for the survival outcome

λ(t) = λ0(t) exp(α1b1i + α2b2i + α3b3i)

Michael J. Crowther megenreg 7th September 2017 34 / 44

Page 46: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

6. A NLME example with multiple linear predictors

We can fit this, and extend it, easily with megenreg

. megenreg (resp age female M1[id], family(user, loglf(nlme logl)) ///> np(1) timevar(time))> (age female M2[id], family(null))> (age female M3[id], family(null))> (stime age female EV[resp]@alpha1 EV[2]@alpha2 EV[3]@alpha3, ///> family(weibull, failure(died))),> covariance(unstructured)

real matrix nlme logl(transmorphic gml, real matrix t){

y = gml util depvar(gml) //dep.var.linpred1 = exp(gml util xzb(gml)) //main lin. pred.linpred2 = exp(gml util xzb mod(gml,2)) //extra lin. predslinpred3 = exp(gml util xzb mod(gml,3))sdre = exp(gml util xb(gml,1)) //anc. paramlinpred = linpred1 :+ linpred2:*exp(-linpred3:*t) //nonlin. predreturn(lnnormalden(y,linpred,sdre)) //logl

}

Michael J. Crowther megenreg 7th September 2017 35 / 44

Page 47: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

7. Mixed effects for the level 1 variance function

A recent paper by Goldstein et al. (2017) [17] proposed atwo-level model with complex level 1 variation, of the form,

yij = X1ijβ1 +Z1ijb1j + εij

εij ∼ N(0, σ2e)

log(σ2e) = X2ijβ2 +Z2ijb2j(

b1jb2j

)∼ N

[(00

),

(Σb1

Σb1b2 Σb2

)]

Michael J. Crowther megenreg 7th September 2017 36 / 44

Page 48: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

7. Mixed effects for the level 1 variance function

We can fit this, and extend it, easily with megenreg

real matrix lev1 logl(transmorphic gml, real matrix t){

y = gml util depvar(gml) //responselinpred1 = gml util xzb(gml) //lin. pred.varresid = exp(gml util xzb mod(gml,2)) //lev1 lin. predreturn(lnnormalden(y,linpred,sqrt(varresid))) //logl

}

. megenreg (resp female age age#M2[id] M1[id], family(user, loglf(lev1 logl)))(age female M3[id], family(null))covariance(unstructured)

Michael J. Crowther megenreg 7th September 2017 37 / 44

Page 49: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Summary

• I’ve presented a very general, and hopefully usable,implementation which can fit a lot of different and newmodels

• Through the complex linear predictor, we allow seamlessdevelopment of novel models, and crucially, a way ofmaking them immediately available to researchersthrough an accessible implementation• Realised it can fit multivariate network IPD

meta-analysis models this week

• I’ve incorporated level-specific random effect distributions,and integration techniques

Michael J. Crowther megenreg 7th September 2017 38 / 44

Page 50: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Summary

• I’ve presented a very general, and hopefully usable,implementation which can fit a lot of different and newmodels

• Through the complex linear predictor, we allow seamlessdevelopment of novel models, and crucially, a way ofmaking them immediately available to researchersthrough an accessible implementation• Realised it can fit multivariate network IPD

meta-analysis models this week

• I’ve incorporated level-specific random effect distributions,and integration techniques

Michael J. Crowther megenreg 7th September 2017 38 / 44

Page 51: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Summary

• I’ve presented a very general, and hopefully usable,implementation which can fit a lot of different and newmodels

• Through the complex linear predictor, we allow seamlessdevelopment of novel models, and crucially, a way ofmaking them immediately available to researchersthrough an accessible implementation• Realised it can fit multivariate network IPD

meta-analysis models this week

• I’ve incorporated level-specific random effect distributions,and integration techniques

Michael J. Crowther megenreg 7th September 2017 38 / 44

Page 52: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Stuff I didn’t show

• family(user, hazard(funcname)

cumhazard(funcname))

• fp() and rcs() as elements

• dEV[], d2EV[], iEV[] as elements

• Shell files - just like gsem

Michael J. Crowther megenreg 7th September 2017 39 / 44

Page 53: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Future directions

• Dynamic risk prediction, predictions will be a key focus ofthe megenreg engine

• location-scale models, multi-membership models...

• It’s so general, and hence it can be slow(er)

• score and Hessian - analytic derivatives will providesubstantial speed gains, so far I’ve implemented hybridanalytic and numeric derivatives.

• I should’ve released it by now...

• Crowther MJ. Extended multivariate generalised linearand non-linear mixed effects models. (Under review).

• Updates and tutorials here:www.mjcrowther.co.uk/software/megenreg

Michael J. Crowther megenreg 7th September 2017 40 / 44

Page 54: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Future directions

• Dynamic risk prediction, predictions will be a key focus ofthe megenreg engine

• location-scale models, multi-membership models...

• It’s so general, and hence it can be slow(er)

• score and Hessian - analytic derivatives will providesubstantial speed gains, so far I’ve implemented hybridanalytic and numeric derivatives.

• I should’ve released it by now...

• Crowther MJ. Extended multivariate generalised linearand non-linear mixed effects models. (Under review).

• Updates and tutorials here:www.mjcrowther.co.uk/software/megenreg

Michael J. Crowther megenreg 7th September 2017 40 / 44

Page 55: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Future directions

• Dynamic risk prediction, predictions will be a key focus ofthe megenreg engine

• location-scale models, multi-membership models...

• It’s so general, and hence it can be slow(er)

• score and Hessian - analytic derivatives will providesubstantial speed gains, so far I’ve implemented hybridanalytic and numeric derivatives.

• I should’ve released it by now...

• Crowther MJ. Extended multivariate generalised linearand non-linear mixed effects models. (Under review).

• Updates and tutorials here:www.mjcrowther.co.uk/software/megenreg

Michael J. Crowther megenreg 7th September 2017 40 / 44

Page 56: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Future directions

• Dynamic risk prediction, predictions will be a key focus ofthe megenreg engine

• location-scale models, multi-membership models...

• It’s so general, and hence it can be slow(er)

• score and Hessian - analytic derivatives will providesubstantial speed gains, so far I’ve implemented hybridanalytic and numeric derivatives.

• I should’ve released it by now...

• Crowther MJ. Extended multivariate generalised linearand non-linear mixed effects models. (Under review).

• Updates and tutorials here:www.mjcrowther.co.uk/software/megenreg

Michael J. Crowther megenreg 7th September 2017 40 / 44

Page 57: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Future directions

• Dynamic risk prediction, predictions will be a key focus ofthe megenreg engine

• location-scale models, multi-membership models...

• It’s so general, and hence it can be slow(er)

• score and Hessian - analytic derivatives will providesubstantial speed gains, so far I’ve implemented hybridanalytic and numeric derivatives.

• I should’ve released it by now...

• Crowther MJ. Extended multivariate generalised linearand non-linear mixed effects models. (Under review).

• Updates and tutorials here:www.mjcrowther.co.uk/software/megenreg

Michael J. Crowther megenreg 7th September 2017 40 / 44

Page 58: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

Future directions

• Dynamic risk prediction, predictions will be a key focus ofthe megenreg engine

• location-scale models, multi-membership models...

• It’s so general, and hence it can be slow(er)

• score and Hessian - analytic derivatives will providesubstantial speed gains, so far I’ve implemented hybridanalytic and numeric derivatives.

• I should’ve released it by now...

• Crowther MJ. Extended multivariate generalised linearand non-linear mixed effects models. (Under review).

• Updates and tutorials here:www.mjcrowther.co.uk/software/megenreg

Michael J. Crowther megenreg 7th September 2017 40 / 44

Page 59: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

References I

[1] Li N, Elashoff RM, Li G. Robust joint modeling of longitudinal measurementsand competing risks failure time data. Biom J Feb 2009; 51(1):19–30,doi:10.1002/bimj.200810491. URLhttp://dx.doi.org/10.1002/bimj.200810491.

[2] Rizopoulos D, Verbeke G, Lesaffre E, Vanrenterghem Y. A two-part joint modelfor the analysis of survival and longitudinal binary data with excess zeros.Biometrics 2008; 64(2):pp. 611–619. URLhttp://www.jstor.org/stable/25502097.

[3] Lin H, McCulloch CE, Mayne ST. Maximum likelihood estimation in the jointanalysis of time-to-event and multiple longitudinal variables. Stat Med Aug 2002;21(16):2369–2382, doi:10.1002/sim.1179. URLhttp://dx.doi.org/10.1002/sim.1179.

[4] Crowther MJ, Andersson TML, Lambert PC, Abrams KR, Humphreys K. Jointmodelling of longitudinal and survival data: incorporating delayed entry and anassessment of model misspecification. Statistics in medicine 2016;35(7):1193–1209.

Michael J. Crowther megenreg 7th September 2017 41 / 44

Page 60: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

References II

[5] Krol A, Ferrer L, Pignon JP, Proust-Lima C, Ducreux M, Bouche O, Michiels S,Rondeau V. Joint model for left-censored longitudinal data, recurrent events andterminal event: Predictive abilities of tumor burden for cancer evolution withapplication to the ffcd 2000–05 trial. Biometrics 2016; 72(3):907–916.

[6] Barrett J, Su L. Dynamic predictions using flexible joint models of longitudinaland time-to-event data. Statistics in Medicine 2017;:n/a–n/adoi:10.1002/sim.7209. URL http://dx.doi.org/10.1002/sim.7209,sim.7209.

[7] Crowther MJ, Abrams KR, Lambert PC, et al.. Joint modeling of longitudinaland survival data. Stata J 2013; 13(1):165–184.

[8] Krol A, Mauguen A, Mazroui Y, Laurent A, Michiels S, Rondeau V. Tutorial injoint modeling and prediction: a statistical software for correlated longitudinaloutcomes, recurrent events and a terminal event. arXiv preprintarXiv:1701.03675 2017; .

[9] Philipson P, Sousa I, Diggle P, Williamson P, Kolamunnage-Dona R, HendersonR. joineR - Joint Modelling of Repeated Measurements and Time-to-Event Data2012. URL http://cran.r-project.org/web/packages/joineR/index.html.

Michael J. Crowther megenreg 7th September 2017 42 / 44

Page 61: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

References III

[10] Rizopoulos D. JM: An R Package for the Joint Modelling of Longitudinal andTime-to-Event Data. J Stat Softw 7 2010; 35(9):1–33. URLhttp://www.jstatsoft.org/v35/i09.

[11] Rizopoulos D. Jmbayes: joint modeling of longitudinal and time-to-event dataunder a bayesian approach 2015.

[12] Henderson R, Diggle P, Dobson A. Joint modelling of longitudinal measurementsand event time data. Biostatistics 2000; 1(4):465–480.

[13] Drukker DM, Gates R, et al.. Generating halton sequences using mata. StataJournal 2006; 6(2):214–228.

[14] Dickman PW, Sloggett A, Hills M, Hakulinen T. Regression models for relativesurvival. Stat Med 2004; 23(1):51–64, doi:10.1002/sim.1597. URLhttp://dx.doi.org/10.1002/sim.1597.

[15] Liu L, Wolfe RA, Huang X. Shared frailty models for recurrent events and aterminal event. Biometrics 2004; 60(3):747–756.

[16] Mazroui Y, Mathoulin-Pelissier S, Soubeyran P, Rondeau V. General joint frailtymodel for recurrent event data with a dependent terminal event: application tofollicular lymphoma data. Statistics in medicine 2012; 31(11-12):1162–1176.

Michael J. Crowther megenreg 7th September 2017 43 / 44

Page 62: Extended multivariate generalised linear and non-linear ... · Extended multivariate generalised linear and non-linear mixed e ects models Stata UK Meeting Cass Business School 7th

Motivation Extended GLMM models Some new models Future directions

References IV

[17] Goldstein H, Leckie G, Charlton C, Tilling K, Browne WJ. Multilevel growthcurve models that incorporate a random coefficient model for the level 1 variancefunction. Statistical methods in medical research Jan 2017;:962280217706 728doi:10.1177/0962280217706728.

Michael J. Crowther megenreg 7th September 2017 44 / 44