hierarchical generalized linear models · hierarchical generalized linear models `so now we are...

30
Hierarchical Generalized Linear Models Measurement Incorporated Hierarchical Linear Models Workshop

Upload: dangkhanh

Post on 27-Jun-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Hierarchical Generalized Linear Models

Measurement Incorporated Hierarchical Linear Models Workshop

Page 2: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Hierarchical Generalized Linear ModelsHierarchical Generalized Linear ModelsSo now we are moving on to the more advanced type topicstopics.

To begin we will start with a general type of model To begin we will start with a general type of model that deals with generalized linear models.

This is a general set of models that can deal with observations that are not normally distributed.observations that are not normally distributed.

Measurement Incorporated HLM Workshop March 14, 20082

Page 3: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

OverviewOverviewWe will first talk about the generalized linear model.

HLM is a special case of HGLM.HLM is a special case of HGLM.

The HGLM handles many types of data:y ypBinary Outcomes.Count Data.Ordinal Data.Multinomial Data.

We will focus only on the binary case in this lecture.

Measurement Incorporated HLM Workshop March 14, 20083

Page 4: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

GLM Versus the Basic Linear ModelGLM Versus the Basic Linear ModelFirst we start by talking about our basic linear model.

We then rephrase it as a generalized linear model.This will show us a more general approach to linear models.g pp

Then we start to talk about how we can use this new d l d l l model to model non-normal responses.

Measurement Incorporated HLM Workshop March 14, 20084

Page 5: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

GLM versus Basic Linear ModelGLM versus Basic Linear ModelTo begin we think of your basic linear model.

iii rXY ++= 10 ββHave a part that is being predicted

Have a part that defines what we would expect to see

Have a residual part

),(~| 2σμμ iii NYNote the Sampling distribution of Yi given our predicted value

Measurement Incorporated HLM Workshop March 14, 20085

Page 6: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Basic Linear ModelBasic Linear ModelIn this model, we assume that:

The observed values have a wide range of possible values (neg. inf. to pos. inf. approximately).

There is a linear relationship between X and Y.

The errors are normal independent and have the same variance.

Measurement Incorporated HLM Workshop March 14, 20086

Page 7: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Basic Linear ModelBasic Linear ModelThis works fine unless we try to model responses that are binary counts or categories (ordinal or that are binary, counts, or categories (ordinal or nominal).

Notice in this case (with binary data) our basic assumptions seem unreasonablep

For example, think of a binary response (pass/fail).For example, think of a binary response (pass/fail).

Measurement Incorporated HLM Workshop March 14, 20087

Page 8: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Example: Binary ResponsesExample: Binary ResponsesIn this case the first assumption is inaccurate because we can only observe a value of 0 and 1.

The second assumption does not seem reasonable because it could lead to predicting a value outside of 0 or 1.

Finally, the third assumption cannot be correct because they are describing the differences between our predicted value and the observed value (which is only a 0 or 1).

So we can see that we need to generalize our model to gaccount for this.

Measurement Incorporated HLM Workshop March 14, 20088

Page 9: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Generalized Linear ModelsGeneralized Linear ModelsIn expanding the models, we will focus on certain parts of the basic regression model.the basic regression model.

Mainly, we will need to change our variable so that it is y, gsomething that we can predict and change our basic assumptions of the errors.

Measurement Incorporated HLM Workshop March 14, 20089

Page 10: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

GLM with the Basic RegressionGLM with the Basic RegressionNow we start by assuming that we have a linear relationshiprelationship

iii rX ++= 10 ββη iii 10 ββη

This is a generic notation for a

•Conceptually, we will transform our original expected value to η to ensure that we can usenotation for a

transformation of the expected response

expected value to η to ensure that we can use our regression.

•This is the same as putting constraints on our expected responsesexpected responses.

Measurement Incorporated HLM Workshop March 14, 200810

Page 11: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Link FunctionLink Function

In basic regression we have a continuous response variable Y with expected outcome μYi with expected outcome μ.

This value is fine with the basic assumptions so and we will This value is fine with the basic assumptions so and we will simply have:

ii μη =

Finally, we will specify the error mean and variance based on our original variableson our original variables.

Mainly we will need to only worry about our link function

Measurement Incorporated HLM Workshop March 14, 200811

Page 12: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

GLMGLM

This is the Link function taking ourThis is the regression part (The Structural Model)

This is the Link function, taking our expected response and changing it to something that we can predict with a regular regression model

iii rX ++= 10 ββη

uf η=)( The Sampling Distributioniiuf η=)(

This is the conditional distribution of Yi|A where A is some expected responsep

Measurement Incorporated HLM Workshop March 14, 200812

Page 13: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Hierarchical Generalized Linear ModelsHierarchical Generalized Linear ModelsNow, one other thing needs an introduction before we get to the actual models:get to the actual models:

The hierarchical part.

The last thing is that we also have nested data, so we not only have a GLM, but we also have to model the

ff f HLMcoefficients as part of an HLM.

Measurement Incorporated HLM Workshop March 14, 200813

Page 14: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Hierarchical Generalized Linear ModelsHierarchical Generalized Linear Models

iiuf η=)( Notice that now we have added the subscript j for the nesting of our data.data.

In modeling the hierarchical part we will make all of the same basic

ti th h i thijijjji rX ++= 10 ββη assumption the we have in the

past…this part is unchanged

Measurement Incorporated HLM Workshop March 14, 200814

Page 15: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

The ModelsThe ModelsFrom here we now are going to talk about the different types of models. For each model we will need to talk about

The sampling distributionThe sampling distribution.The link function.The structural model.

Now we go to binary responses (leaving counts ordinal, and nominal responses to the book).

Measurement Incorporated HLM Workshop March 14, 200815

Page 16: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

BinomialBinomialIn the case of Binary data we now have observed a set of binary responses.y p

Our goal is to model the probability of a g p ydichotomous response as a function of a set of covariates.

The problem, using basic regression we could get values outside of 0-1 so we will use a logit linkvalues outside of 0 1 so we will use a logit link.

Measurement Incorporated HLM Workshop March 14, 200816

Page 17: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Binomial HGLMBinomial HGLM

This is the Link function taking ourThis is the regression part (The Structural Model)

This is the Link function, taking our expected response (probability) and changing it to something that we can predict with a regular regression

0 1ij j j ij ijX rη β β= + +model

ϕ⎛ ⎞The Sampling Distribution

log1 iϕ ηϕ

⎛ ⎞=⎜ ⎟−⎝ ⎠

This is the conditional distribution of Yi|φ is Binomial(mij, φij)

Measurement Incorporated HLM Workshop March 14, 200817

Page 18: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Most Important…InterpretationMost Important…InterpretationSo what does this mean?

We model the expected log-odds of the response as a linear function of the covariatesa linear function of the covariates.

In some cases it is enough to simply interpret the logIn some cases it is enough to simply interpret the log-odds or the odds in other cases you may want to covert it back to a probability. covert it back to a probability.

Measurement Incorporated HLM Workshop March 14, 200818

Page 19: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

OddsOddsBy using the probability of a 1 divided by the probability of a 0 we have something that tells us the likelihood of either occurring.

“How many successes would I expect to see for each failure I see”

Note that if the odds are “1” this is the same as “1 to 1 odds”, which means each event is equally likely to occur.

What about the odds of .25?

Measurement Incorporated HLM Workshop March 14, 200819

Page 20: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

OddsOddsIf the odds are greater than 1…then a 1 is more likely:

Log-odds are positiveLog odds are positive.

If the odds are less than 1…then a 0 is more likely:yLog-odds are negative.

Measurement Incorporated HLM Workshop March 14, 200820

Page 21: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Interpretation (using HGLM)Interpretation (using HGLM)

X rη β β= + +0 1ij j j ij ijX rη β β= + +

Again we have random error, This is the expected log-odds h ll th i bl

1 10 1j juβ γ= +0 00 0j juβ γ= +

but the intercept describes the change in the log-odds for unit change in X. This is related to th i d i

when all other variables are zero plus the random error. Random Error is still normal (0,τ)

the increase or decrease in the odds.

Measurement Incorporated HLM Workshop March 14, 200821

Page 22: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

ExampleExampleFrom Hedeker (http://tigger.uic.edu/%7Ehedeker/long.html)

NIMH Schizophrenia Study (437 patients)108 given placebo329 given drug329 given drug

7 week study

Modeling the probability a patient was rated as worse than moderately illmoderately ill.

7-point scale.

Measurement Incorporated HLM Workshop March 14, 200822

Page 23: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

HLM Setup: Random Intercept ModelHLM Setup: Random Intercept Model

Measurement Incorporated HLM Workshop March 14, 200823

Page 24: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Model Parameter Estimates: Fixed EffectsModel Parameter Estimates: Fixed EffectsHere we find our fixed effect parameters.

The main effect of treatment was not significant.

The interaction between The interaction between treatment and week was significant.

As time goes on, As time goes on, treatment improves the condition.

Measurement Incorporated HLM Workshop March 14, 200824

Page 25: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Model Parameter Estimates: Variance ComponentsVariance Components

We can look at the results for our Level-2 variance (τ00).

Measurement Incorporated HLM Workshop March 14, 200825

Page 26: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Linear Model: Logits and Square Root of WeekLinear Model: Logits and Square Root of Week

Measurement Incorporated HLM Workshop March 14, 200826

Page 27: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Non-linear Model: Logits and WeekNon linear Model: Logits and Week

Measurement Incorporated HLM Workshop March 14, 200827

Page 28: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Nonlinear Model: Probabilities and Square Root of WeekProbabilities and Square Root of Week

Measurement Incorporated HLM Workshop March 14, 200828

Page 29: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

Nonlinear Model: Probabilities and WeekProbabilities and Week

Measurement Incorporated HLM Workshop March 14, 200829

Page 30: Hierarchical Generalized Linear Models · Hierarchical Generalized Linear Models `So now we are moving on to the more advanced type topics. `To begin we will start with a general

SummarySummaryIn general, we can see that the only hard thing about the application of these model is the interpretation.application of these model is the interpretation.

Otherwise, input using HLM is the same., p g

Estimation of such models in HLM can be problematic.pUses an estimator known to be biased in certain situations.

Not maximum likelihood.

O h h i f i i d dOther mechanisms for estimation are recommended:Mplus.SAS proc nlmixed.pBayesian algorithms (such as glmmgibbs in R).

Measurement Incorporated HLM Workshop March 14, 200830