models for counts - analysis of repeated measurements, nfa

59
university of copenhagen department of biostatistics Faculty of Health Sciences Models for counts Analysis of repeated measurements, NFA 2016 Julie Lyng Forman & Lene Theil Skovgaard Department of Biostatistics, University of Copenhagen

Upload: others

Post on 28-Dec-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Faculty of Health Sciences

Models for countsAnalysis of repeated measurements, NFA 2016

Julie Lyng Forman & Lene Theil SkovgaardDepartment of Biostatistics, University of Copenhagen

Page 2: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Contents

Repetition of generalized linear models (GLMs).I with emphais on log-linear models for count data.

Extensions to repeated measurements.I Marginal models and generalized estimating equations (GEE).I Generalized linear mixed models.I Comparison of the two types of models.

Case studies with data from randomized clinical trials:I Effect of antibiotics on leprosy bacilliI Epileptic seizures.

Suggested reading: Fitzmaurice et al. (2011): chapters 11–16.2 / 59

Page 3: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Outline

Repetition of generalized linear models

Marginal models

Generalized linear mixed models

Comparison of Marginal models and GLMMs

3 / 59

Page 4: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Repetition: Generalized linear modelsFor outcomes that are binary, interger valued, or always positive alinear model may not be reasonable since the mean is constrainedto the [0; 1]-interval or the positive numbers.

A generalized linear model is specified by:

1. A distributional assumption: binomial (especially binary),poisson, negative binomial, gamma, normal (!!), etc(There is a large selection in PROC GENMOD).

2. A link function g that links the expected value µi = E(Yi) tothe covariates on an apropriate scale, i.e.

g(µi) = β0 + β1X1i + . . .+ βkXki = XTi β

Note: So far we consider only i.i.d. data – no repetitions yet!4 / 59

Page 5: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

What’s the link?

Generalized linear models are similar to multiple regression models- - but on a scale that matches the data:

I Continous data (dist=normal, link=identity)Linear regression: E(Y ) = α+ βX.

I Count data (dist=poisson, link=log)Log-linear regression: log{E(Y )} = α+ βX

I Binary data (dist=binomial, link=logit), (lecture 6)

Logistic regression: log{

E(Y )1−E(Y )

}= α+ βX

5 / 59

Page 6: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Case: Epileptic seizures

Randomized clinical trial:I 30 treated with progabide.I 28 treated with placebo.

Outcome: number of epileptic seizures duringI An 8-week interval before treatmentI Four consecutive 2-week intervals following treatmentI We consider rates of seizures per week

Reference: Thall, P.F. and Vail, S.C. (1990). Some covariance models forlongitudinal count data with overdispersion. Biometrics.

6 / 59

Page 7: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Spaghettiplot - version 1Number of seizures for each period.

Higher level in the first period; 8 weeks vs 2 weeks.7 / 59

Page 8: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Spaghettiplot - version 2Seizures per week for each period.

Lower variability in the first period; 8 weeks vs 2 weeks.8 / 59

Page 9: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Epilepsy: summary statistics

The MEANS Procedure

Analysis Variable : seizures

treatment time Obs N Mean Variance-------------------------------------------------------------------------

0 0 28 28 30.7857143 681.43386241 28 28 9.3571429 102.75661382 28 28 8.2857143 66.65608473 28 28 8.7857143 215.28571434 28 28 8.0000000 57.9259259

1 0 31 31 31.6451613 783.63655911 31 31 8.5806452 332.71827962 31 31 8.4193548 140.65161293 31 31 8.1290323 193.04946244 31 31 6.7419355 126.6645161

-------------------------------------------------------------------------

Note: Data is overdispersed (variance is > mean).9 / 59

Page 10: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Distribution at final follow-up

Do we see a difference between the groups . . .I Need a model for the expected rate of seizures.I The distribution is obviously not normal; it is integer valued

and markedly skew, with a major outlier.I Maybe a Poisson model fits?

10 / 59

Page 11: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

The poisson distributionCounts with no well-defined upper limit, e.g.:

I Number of cancer cases during a specific year.I Number of positive swabs over a certain period of time.

Poisson distribution with mean value: µ =1,2,5 and 20

Note: The mean and variance are equalI This fact is unfortunately often overlooked....

11 / 59

Page 12: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Variance in GLMs

Every choice of distribution implies a particular variance function:

Var(Y ) = φ · ν(µ)

where µ is the mean and φ is the so-called dispersion parameter.

Examples:I Normal distribution: ν(µ) = 1 and φ = σ2.

The variance is not related to the mean.I Poisson distribution ν(µ) = µ and φ = 1.

The variance is identical to the mean.I Negative binomial distribution ν(µ) = µ+ φµ2.

The variance is proportional to the squared mean.

12 / 59

Page 13: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Methods for handling overdispersion

In the Poisson model the variance is identical to the mean.

I But what if data has overdispersion?

. . . caused by heterogeneity due to omitted covariates orunrecognized clustering (such as a group of non-susceptibles)

Alternatives to the Poisson model:

I A negative binomial model (next slide).

I A semi-parametric model with mean structure and variancefunction as in the Poisson model and with an additionaldispersion parameter?.

? This has consequences for statistical inferece; parameters must be fitted usinga quasi likelihood method instead of conventional maximum likelihood (ML).13 / 59

Page 14: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

The negative binomial distributionAn alternative to the Poisson model.

I similar model for the mean (link-function: log)

I with overdispersion ν(µ) = µ+ φµ2

Poisson distribution with mean 10, followed by 3 negative binomialdistributions, with same mean and variances 30, 110, and 210:

14 / 59

Page 15: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Analysis of epilepsy data: proc genmod

Outcome: Rate of seizures in last period (no repetitions yet!).

title1 ’Poisson model: treatment effect in period 4’;

PROC GENMOD DATA=epilepsy;WHERE time=4; /* only period 4 */CLASS treatment (REF=’0’);MODEL seizures=treatment / DIST=poisson LINK=log

OFFSET=logweeks TYPE3;RUN;

Want to compare with:I Negative binomial model: change to DIST=negbin.I Overdispersion correction: Add SCALE=PEARSON to the options

following the model-statement.

15 / 59

Page 16: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Programming notesSimilar to linear models for continuous/normal data:

I CLASS specifies the categorical variables and MODEL therelation between the outcome and the covariates.

Specific to generalized linear models:I DIST specifies the distribution (e.g. poisson) and the related

default-link unless this is overuled by LINK.I OFFSET allows for comparison of rates (rather than counts)

over periods of variable length. Note that the offset-variable(logweeks) must be the log of the length of the period.

I Predicted values? (only two distinct) can be saved withOUTPUT OUT=glmfit PREDICTED=pred;

? We don’t want to save the residuals since they are difficult to interpretwhen data is not normally distributed.

16 / 59

Page 17: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Results from poisson modelAnalysis Of Maximum Likelihood Parameter Estimates

Standard Wald 95% Confidence WaldParameter DF Estimate Error Limits Chi-Square Pr > ChiSqIntercept 1 1.3863 0.0668 1.2553 1.5172 430.49 <.0001treatment 1 1 -0.1711 0.0962 -0.3596 0.0174 3.17 0.0752treatment 0 0 0.0000 0.0000 0.0000 0.0000 . .Scale 0 1.0000 0.0000 1.0000 1.0000

NOTE: The scale parameter was held fixed.

LR Statistics For Type 3 Analysis

Source DF Chi-Square Pr > ChiSqtreatment 1 3.17 0.0751

Estimated difference in rate of seizures with progabide compared toplacebo is -0.17 with 95% CI (-0.36;0.02) - on log-scale!!!

I Back-transformation: exp(−0.1711) = 0.8427.I We see 16% lower seizure rate in the Progabide group

(95% CI: between 30% lower and 2% higher).I Actually we can make SAS do this for us . . .17 / 59

Page 18: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Estimate statements

PROC GENMOD DATA=epilepsy;WHERE time=4;CLASS treatment (REF=’0’);MODEL seizures=treatment / NOINT DIST=poisson OFFSET=logweeks;ESTIMATE ’Rate Progabide’ treatment 1 0;ESTIMATE ’Rate Placebo’ treatment 0 1;ESTIMATE ’Rate Ratio’ treatment 1 -1;RUN;

Compares the parameters (log-means) of two treatment groups:I Easiest to keep track of comparisons if we can identify the

log-means in the output, so we leave out the intercept.I The ordering matters: first progabide, last placebo (ref).

We specify "1" for progabide compared to " -1" for placebo(if there were more groups they would get a "0")

18 / 59

Page 19: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Output from estimate statements

I L’Beta: usual estimate on log-scale.I Mean: has been back-transformed.

Contrast Estimate Results

Mean Mean L’Beta Standard L’BetaLabel Estimate Confidence Limits Estimate Error Alpha Confidence LimitsRate Progabide 3.3710 2.9436 3.8604 1.2152 0.0692 0.05 1.0796 1.3508Rate Placebo 4.0000 3.5090 4.5597 1.3863 0.0668 0.05 1.2553 1.5172Rate Ratio 0.8427 0.6980 1.0176 -0.1711 0.0962 0.05 -0.3596 0.0174

We also get p-values for the hypothesis H0 : "parameter=0" .

Contrast Estimate Results

Chi-Label Square Pr > ChiSqRate Progabide 308.63 <.0001Rate Placebo 430.49 <.0001Rate Ratio 3.17 0.0752

19 / 59

Page 20: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Overdispersion

BUT: Is the Poisson model realistic?!?

Estimates of treatment effect from the three different models

Model Rate ration (95% CI) P-valuePoisson (no overdispersion) 0.8427 (0.6980;1.0176) 0.0752Overdispersion correction 0.8427 (0.4236;1.6766) 0.6259Negative binomial 0.8427 (0.4964;1.4307) 0.5264

When overdispersion is disregarded:I standard errors are downwards biased (CIs are too narrow).I type I error rate is inflated (p-values are too small).

20 / 59

Page 21: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

What if there is an upper limit for the counts?E.g. number of days away from work in a month.

I The distribution of number out of n is binomialMore about binomial models in lecture 6).

I Unless n is large, then the binomial model becomesuntractable and we might use the Poisson as anapproximation.

The law of rare events:If the count parameter n in the Binomial distribution is large andthe probability parameter p is small (i.e. close to 0), the Binomialdistribution is approximately the same as the Poisson distribution:

P (Y = m) ' µm

m! exp(−µ)

where µ = np is the mean value.21 / 59

Page 22: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Outline

Repetition of generalized linear models

Marginal models

Generalized linear mixed models

Comparison of Marginal models and GLMMs

22 / 59

Page 23: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

What about repeated measurements?

In case of normally distributed data:I Replace the univariate normal model by a multivariate.

But what if data is binary or consists of counts?I No multivariate binomial or poisson distribution!

Alternative: specify a semi-parametric model by

1. Mean E(Yij) = µij = g−1(XTijβ) with link-function g.

2. Variance V(Yij) = φ · ν(µij) with variance function ν.3. A correlation pattern matrix Corr(Yi) = Λ.

Mean and variance is similar to a conventional GLM but we don’tassume any particular distribution for the data. This partial modelspecification is in fact sufficient to make valid inference for β.23 / 59

Page 24: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Generalized estimating equations (GEE)

Find the generalized least squares estimator β̂ by minimizing

N∑i=1{yi − µi(β)}TV −1

i ({yi − µi(β)} = 0

where Vi is the working covariance for subject i specified byI The variances φν(µ1i), . . . , φν(µki).I The working correlation matrix Λ.

In practice, alternate between two steps until convergence:

1. Solve for β with the current estimate of Vi fixed.2. Estimate φ and the correlation parameters in Λ from the

scaled residuals eij = ν(µ̂ij)−1/2(Yij − µ̂ij) and update Vi.24 / 59

Page 25: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Properties of GEE

I The GEE-estimator is robust. I.e. it is valid even when theworking covariance is misspecified.

I But only if SEs are estimated with the sandwichcovariance estimator (default in proc genmod) which alsohandles overdispersion and time-varying dispersion correctly.

I When there are missing data that are missing at random butnot missing completely at random inverse probabilityweighting is needed to get unbiased estimates and SEs.

Caution:I The sandwich covariance estimator is known to perform

poorly in small datasets; it is anti-conservative!I And it cannot be used at all if the design is unbalanced.

25 / 59

Page 26: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Choosing a working covariance

Possibile choices in proc genmod, all giving valid inference:

I unstructured (type=un)I compound symmetry (type=cs)I autoregressive (type=ar)I working independence (type=ind)

Why not avoid choosing the correlation alltoghether by alwaysusing working independence (which is easiest to compute)?

I Because we get more power when Vi is close to the truth.

26 / 59

Page 27: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Case study: Counts of leprosy bacilli

Randomized clinical trial:I 10 patients treated with antibiotic drug=AI 10 patients treated with antibiotic drug=BI 10 patients treated with placebo drug=P

Outcome: total number of bacilli at six sites of the body,I just before treatment (time=0)I several months after treatment, (time=1)

Reference: Snedecor, G.W. and Cochran, W.G. (1967), Statistical Methods,(6th edn), Iowa State University Press

27 / 59

Page 28: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Leprosy bacilli: spaghettiplots

Number of bacilli at baseline and follow-up.

28 / 59

Page 29: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Leprosy bacilli: summary statistics

Analysis Variable : bacilli

drug time Obs N Mean Variance-------------------------------------------------------------A 0 10 10 9.3000000 22.6777778

1 10 10 5.3000000 21.5666667

B 0 10 10 10.0000000 27.55555561 10 10 6.1000000 37.8777778

P 0 10 10 12.9000000 15.65555561 10 10 12.3000000 51.1222222

-------------------------------------------------------------

Note: overdispersion and higher variance at follow-up.

29 / 59

Page 30: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Model reflections

I We are dealing with counts, so it is natural to consider aPoisson-like distribution with log-link, even though data ismost likely not exactly Poisson due to the overdispersion .

I The design is that of a classical baseline follow-up study.Covariates are drug and time and the treatment effect isexpected to show as a drug*time-interaction.

I Because treatment was randomized, the mean values atbaseline should be identical across the three groups

I We have replicate measurements on each subject. Thus weneed to account for correlation to get valid results.

I In fact, there is only one correlation, so type=un, type=cs,and type=ar all describe the same correlation pattern.

30 / 59

Page 31: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Model for the treatment effects

Mean values on log-scale:

Treatment Period Mean (on log scale)P Baseline β1P Follow-up β1 + β2A Baseline β1A Follow-up β1 + β2 + β3B Baseline β1B Follow-up β1 + β2 + β4

β2 denotes time-change from baseline to follow-up on placebo.

β3 and β4 denote differences in time-effect of drug A and Bcompared to placebo: the treatment effects.

31 / 59

Page 32: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Leprosy bacilli: proc genmod

1. First add the variable adjdrug (effective treatment) to the data.

DATA leprosy;SET leprosy;drugadj = drug;IF time = 1 THEN drugadj = ’P’;RUN;

2. Next do the baseline follow-up analysis in proc genmod:

PROC GENMOD DATA=leprosy;CLASS id time (REF=’0’) drugadj (REF=’P’);MODEL bacilli=time drugadj*time / DIST=poisson LINK=log TYPE3;REPEATED SUBJECT=id / WITHINSUBJECT=time TYPE=un CORRW;RUN;

32 / 59

Page 33: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Programming notes

I Relation between outcome and covariates is specified similiarto continuous/normal data (i.e. like in proc mixed).

I DIST=poisson by default specifies the LINK-function as log,and the variance function ν(µ) = µ. Note that we don’tactually assume that data has a poisson distribution because amarginal model (gee) is default with the repeated statement.

I REPEATED identifies subjects (or clusters) and specifies theworking correlation for the repeated measurements (looks alot like proc mixed but note the different ordering of options).

I WITHINSUBJECT=time is needed to get the correct temporalordering of replicates in longitudinal data. In clustered datawhere individuals are exchangeable this is omitted.

I CORRW prints the estimated working correlation.33 / 59

Page 34: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Leprosy bacilli: output from proc genmodModel Information

Data Set WORK.LEPROSYDistribution PoissonLink Function LogDependent Variable bacilli

Number of Observations Read 60Number of Observations Used 60

Class Level Information

Class Levels Valuesid 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

21 22 23 24 25 26 27 28 29 30time 2 1 0drugadj 3 A B P

Parameter Information

Parameter Effect time drugadjPrm1 InterceptPrm2 time 1Prm3 time 0Prm4 time*drugadj 1 APrm5 time*drugadj 1 BPrm6 time*drugadj 1 PPrm7 time*drugadj 0 P34 / 59

Page 35: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Leprosy bacilli: output from proc genmod

GEE Model Information

Correlation Structure UnstructuredWithin-Subject Effect time (2 levels)Subject Effect id (30 levels)Number of Clusters 30Correlation Matrix Dimension 2Maximum Cluster Size 2Minimum Cluster Size 2

Algorithm converged.

Working Correlation Matrix

Col1 Col2Row1 1.0000 0.7966Row2 0.7966 1.0000

GEE Fit CriteriaQIC -405.7657QICu -403.6905

ATT: Always check that the numerical optimisation has converged.35 / 59

Page 36: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Leprosy bacilli: output from proc genmod

Analysis Of GEE Parameter EstimatesEmpirical Standard Error Estimates

Standard 95% ConfidenceParameter Estimate Error Limits Z Pr > |Z|Intercept 2.3734 0.0801 2.2163 2.5304 29.62 <.0001time 1 -0.0138 0.1573 -0.3222 0.2946 -0.09 0.9300time 0 0.0000 0.0000 0.0000 0.0000 . .time*drugadj 1 A -0.5406 0.2186 -0.9690 -0.1122 -2.47 0.0134time*drugadj 1 B -0.4791 0.2279 -0.9257 -0.0325 -2.10 0.0355time*drugadj 1 P 0.0000 0.0000 0.0000 0.0000 . .time*drugadj 0 P 0.0000 0.0000 0.0000 0.0000 . .

Score Statistics For Type 3 GEE Analysis

Source DF Chi-Square Pr > ChiSqtime 1 13.90 0.0002time*drugadj 2 4.56 0.1024

Do we see a significant p-value for the treatment effect - ???I Main interest: compare each drug in turn with placebo.I A and B are have similar effect, so we don’t see the significance

when comparing all three to each other (like in an ANOVA).36 / 59

Page 37: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Back-transformed estimates1. It is easier to identify means for treatments over time when

main effect of time and intercept are left out of MODEL.2. Order: "A time 1", "B time 1", "P time 1", "All time 0"(ref).

PROC GENMOD DATA=leprosy;CLASS id time (REF=’0’) drugadj (REF=’P’);MODEL bacilli=drugadj*time / NOINT DIST=poisson LINK=log;REPEATED SUBJECT=id / WITHINSUBJECT=time TYPE=un CORRW;

ESTIMATE ’change with A’ drugadj*time 1 0 0 -1;ESTIMATE ’change with B’ drugadj*time 0 1 0 -1;ESTIMATE ’change with P’ drugadj*time 0 0 1 -1;ESTIMATE ’A vs placebo ’ drugadj*time 1 0 -1 0;ESTIMATE ’B vs placebo ’ drugadj*time 0 1 -1 0;ESTIMATE ’drug A vs B ’ drugadj*time 1 -1 0 0 ;

RUN;37 / 59

Page 38: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Leprosy bacilli: Results

I L’Beta: usual estimate on log-scale.I Mean: has been back-transformed.

Contrast Estimate Results

Mean Mean L’Beta Standard L’BetaLabel Estimate Confidence Limits Estimate Error Alpha Confidence Limitschange with A 0.5744 0.4281 0.7706 -0.5544 0.1499 0.05 -0.8483 -0.2605change with B 0.6109 0.4478 0.8333 -0.4929 0.1585 0.05 -0.8035 -0.1823change with P 0.9863 0.7245 1.3425 -0.0138 0.1573 0.05 -0.3222 0.2946A vs placebo 0.5824 0.3795 0.8939 -0.5406 0.2186 0.05 -0.9690 -0.1122B vs placebo 0.6194 0.3963 0.9681 -0.4791 0.2279 0.05 -0.9257 -0.0325A vs B 0.9403 0.6148 1.4381 -0.0615 0.2168 0.05 -0.4864 0.3633

(P-values omitted due to lack of space)

Conclusion:Mean count of bacilli decresed by -43% with drug A (CI: -68%;-23%),-39% with drug B (-56%;-17%), and -1% with placobo (-28%;+34%).Thus with drug A an additional reduction of -42% (-62%;-11%, P=0.01)was seen compared with placebo. Similarly with drug B the additionalreduction was -38% (-60%;-3%, P=0.04) compared with placebo.38 / 59

Page 39: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Leprosy bacilli: Modeling choices

Note: Assumed indepence give similar estimates to workingindependence, but qualitatively different inference . . .39 / 59

Page 40: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Estimates and SEs for "B" vs Placebo (log-scale)

Model for repeated Poisson Negative binomialmeasurements distribution distributionSemi-parametric:GEE Unstructured -0.48 (0.23) -0.50 (0.24)GEE Working indep. -0.70 (0.35) -0.70 (0.35)

Specific distribution:Assumed independence -0.70 (0.16) -0.70 (0.29)

I GEE can account for correlation, overdispersion, time- andtreatment-dependent dispersion.

I Choice of distribution has little impact on GEE. But workingindependence is a less efficient choice than unstructured.

I Assumed independence is unrealistic; Poisson likewise.40 / 59

Page 41: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Pros and cons of marginal models

AdvantagesI Minimal model assumptions, hence fewer wrong assumptions.I High flexibility; can model many different kinds of data.I Computationally simple.

DrawbacksI The sandwich covariance estimator is anti-conservative when

samples are small and model based covariance estimates areonly valid if the working covariance is correct. In particular,compound symmetry must be true if the design is unbalanced.

I Need a model for the missingness to handle missing data.I Power calculations demands a fullly specified model.I Possible to specify mean-covariance combinations that do not

match any multivariate distribution (binary data in particular).41 / 59

Page 42: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Outline

Repetition of generalized linear models

Marginal models

Generalized linear mixed models

Comparison of Marginal models and GLMMs

42 / 59

Page 43: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

GLMMs are variance component modelsIn parallel to linear mixed models, we specify a model with subjectspecific parameters bi (random effects):

g(µij) = XTijβ + ZTijbi

Model assumptions:1. bi ∼ N(0, G) and independent of the covariates Xi.2. For any subject the repeated measurements are conditionally

indpendent given the random effect(s) and distributedaccording to a GLM with prespecified distribution, linkfunction g, and variance function Var(Yij |bi) = φ · ν(µij).

I This fully specifies a multivariate model.I Correlation between replicates is induced by and solely

due to the random effect(s).43 / 59

Page 44: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Interpretion of regression coefficients in a GLMM

The effect of a covariate is interpreted for fixed values of allother factors including the random effect.

I It makes sense to interpret the effect of time on the individualas time is usually a within subject covariate.

I It makes sense to compare treatments that has beenrandomized (the distribution of random effects is identicalacross treatment groups).

I But what about covariates such as gender; Is it reasonable tocompare a man of averge frailty to a woman of average frailty?

We say that GLMM regression parameters are subject specific.

44 / 59

Page 45: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Interpretation of variance components

Variability among subject is modeled by the random effects biwhich are assumed to follow a normal distribution.

I It is difficult to check the validity of the normal assumption,but fortunately inference for the regression parameters is notvery sensitive to misspecification of the distribution.

I We could use the normal range for the bi’s to visualizevariation between subjects, but be aware that this is amodel-based extrapolation strongly influenced by the normalassumption.

I The random effects can be estimated by BLUPs but againthese estimates are also strongly influenced by the normalassumption and thus no good for checking it!

45 / 59

Page 46: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Technical note on inference for GLMMs?

Maximize the likelihood function:

N∏i=1

∫f(yi|bi, β, φ)f(bi|G)dbi

This is a computational challenge.I Integrals must be evaluated by numerical integration. The

preferable option is Gaussian quadrature with a suitablylarge number of quadrature points.

I Infeasible with many random effects or when data is large.I Beware of local maxima! Ideally an initial grid search should

be performed over a range of covariance parameters.

46 / 59

Page 47: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Leprosy bacilli: proc glimmix

PROC GLIMMIX DATA=leprosy METHOD=QUAD(QPOINTS=50);CLASS id time drugadj;MODEL bacilli = time*drugadj / NOINT DIST=poisson LINK=log;RANDOM intercept / SUBJECT=id G;OUTPUT OUT=glmmfit PRED(ILINK)=ipred PRED(ILINK NOBLUP)=pred;

ESTIMATE ’change with A’ drugadj*time 1 0 0 -1 / EXP CL;ESTIMATE ’change with B’ drugadj*time 0 1 0 -1 / EXP CL;ESTIMATE ’change with P’ drugadj*time 0 0 1 -1 / EXP CL;ESTIMATE ’A vs placebo ’ drugadj*time 1 0 -1 0 / EXP CL;ESTIMATE ’B vs placebo ’ drugadj*time 0 1 -1 0 / EXP CL;ESTIMATE ’drug A vs B ’ drugadj*time 1 -1 0 0 / EXP CL ;

RUN;

47 / 59

Page 48: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Programming notesOverall similar to the marginal model, save from:

I METHOD=QUAD: approximates the likelihood function byGaussian quadrature.

I QPOINTS=50: more quadrature points → better accuracy.

I RANDOM: here we only have a random intercept, so it is notnecessary to specify a TYPE.

(otherwise choose un or perhaps vc if it is reasonable toassume independence between the random effects).

I G: prints the estimated G-matrix; here σ2b .

I OUTPUT OUT= saves the predicted values in an dataset.Predictions are individual unless the NOBLUP-option is used.The ILINK-option makes back-transformation.

48 / 59

Page 49: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Leprosy: GLMM estimtates

Exponentiated Exponentiated ExponentiatedLabel Estimate Lower Upperchange with placebo 1.0031 0.7786 1.2924change with A 0.5475 0.3897 0.7692change with B 0.5947 0.4312 0.8202A vs placebo 0.5458 0.3594 0.8288B vs placebo 0.5929 0.3963 0.8869A vs B 0.9206 0.5812 1.4583

(Estimates on log-scale and P-values omitted due to lack of space)

Conclusion:The expected increase in individual bacilli count is estimated as-43% with drug A (CI: -61%;-23%), -40% with drug B(-57%;-18%), and +1% with placobo (-22%;+29%).

With drug A an additional reduction of -45% (-64%;-17%)is expected compared with placebo . . .49 / 59

Page 50: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Poisson or negative binomial distribution

Not that obvious a choice since the random effect inducesoverdispersion . . .

Poisson distribution Negative binomialEffect Estimate (SE) P Estimate (SE) Pchange with P 0.01 (0.12) 0.98 0.14 (0.23) 0.55change with A -0.60 (0.17) 0.001 -0.71 (0.25) 0.007change with B -0.52 (0.16) 0.003 -0.57 (0.24) 0.025A vs placebo -0.61 (0.20) 0.006 -0.84 (0.30) 0.006B vs placebo -0.52 (0.20) 0.013 -0.70 (0.29) 0.02A vs B -0.08 (0.22) 0.72 -0.14 (0.31) 0.65

For comparison of non-nested models use Akaike’s criterion (AIC).I Poission fits better than negative binomial (362.25 vs 379.11).

50 / 59

Page 51: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Leprosy: Individual predictions from GLMM

51 / 59

Page 52: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Pros and cons of GLMMsAdvantages

I Suited for making individual predictions.I Fully specified model allows for exact likelihood inference,

model comparisons, and simulation for e.g. power calculations.I Likelihood inference automatically handles data that are

missing at random optimally.

DrawbacksI More model assumptions → higher risk of misspecification.Difficult to check assumptions about the random effectsand tempting to extrapolate from these very assumptions.

I Not optimal for making inference for population averages(due to having to average over the random effect).

I Computationally infeasible when the number of randomeffects or the overall size of the data becomes large.

52 / 59

Page 53: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Outline

Repetition of generalized linear models

Marginal models

Generalized linear mixed models

Comparison of Marginal models and GLMMs

53 / 59

Page 54: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Marginal models vs GLMMs

Normal outcomes:I Variance component model with random intercept is the same

as repeated measurements model with compound symmetry.

Non-normal outcomes:I Marginal models and GLMMs are inherently different models!I They differ in interpretation.I They differ in actual figures, i.e. estimates and SEs.

54 / 59

Page 55: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Leprosy bacilli: GLMM vs Marginal model

Regression coefficients are similar but GLMM estimates a smallerintercept than GEE.

GEE GLMMParameter Estimate (SE) Pval Estimate (SE) PvalIntercept 2.37 (0.08) - 2.24 (0.11) -time -0.01 (0.16) 0.93 0.01 (0.12) 0.98time*A -0.54 (0.22) 0.013 -0.61 (0.20) 0.006time*B -0.48 (0.23) 0.036 -0.52 (0.20) 0.013

Data is small, so maybe GEE underestimates the SEs . . .– Should we prefer GLMM then?

I Maybe not, SEs from GLMM are even smaller(due to stronger model assumptions we cannot verify).55 / 59

Page 56: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Predicted means GLMM vs Marginal model

Note the difference in interpretation:Population average vs expected for person of average frailty .56 / 59

Page 57: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Technical explanation: conditional vs marginal mean?

The GLMM with log-link implies that

E(Yij) = E{E(Yij |bi)} = E(eXTijβ+ZT

ijbi) = eXTijβ · E(eZT

i bi)

I Regression coefficients are the same as in the marginal model.I Only the intercept differs (it is smaller in the GLMM).

But a conditional poisson distribution does not imply amarginal poisson distribution.

I E.g. the marginal variance is

Var(Yij) = eXTijβ + (eX

Tijβ)2 ·Var(eZ

Tijbi)

with overdispersion similar to the negative binomial(which differ in other aspects, though).

57 / 59

Page 58: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Recap: The two model types

Marginal models aka population average models:

I Describe covariate effects on the population mean,I I.e. the expected effect of treatment on the entire population.I Analyzed via repeated-statement in proc genmod.

Generalized linear mixed models aka subject specific models:

I Describe covariate effects on the individual,I I.e. the expected effect of treatment on the individual

conditioning on his or her general health (frailty).I Analyzed via random-statement in proc glimmix.

58 / 59

Page 59: Models for counts - Analysis of repeated measurements, NFA

u n i v e r s i t y o f c o p e n h a g e n d e p a r t m e n t o f b i o s t a t i s t i c s

Marginal model or GLMM – which should I prefer?

I Different specifications of the joint distribution of Yi lead toregression coefficients with quite distinct interpretations.

I Marginal models aim at inference for the population means.The models are semi-parametric. They merely acknowledgethe correlation and do not seek to explain it.

I GLMMs assume that the correlation among repeatedmeasurements arise from the sharing of random effect orsubject specific parameters. The parameters in GLMMs havesubject specific but not population average interpretations.

Choice of model should be made on subject matter grounds . . . andthere is no contradiction in repporting both subject-specific andpopulation averaged effects if both are of interests.59 / 59