32
Topic 30: Random Effects

Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Embed Size (px)

Citation preview

Page 1: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Topic 30: Random Effects

Page 2: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Outline

• One-way random effects model

–Data

–Model

– Inference

Page 3: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Data for one-way random effects model

• Y, the response variable• Factor with levels i = 1 to r

• Yij is the jth observation in cell i, j = 1 to ni

• Almost identical model structure to earlier one-way ANOVA.

• Difference in level of inference

Page 4: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Level of Inference• In one-way ANOVA, interest was in

comparing the factor level means

• In random effects scenario, interest is in the pop of factor level means, not just the means of the r study levels

• Need to make assumptions about population distribution

• Will take “random” draw from pop of factor levels for use in study

Page 5: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

KNNL Example

• KNNL p 1036

• Y is the rating of a job applicant

• Factor A represents five different personnel interviewers (officers), r=5

• n=4 different applicants were interviewed by each officer

• The interviewers were selected at random and the applicants were randomly assigned to interviewers

Page 6: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Read and check the data

data a1; infile 'c:\...\CH25TA01.DAT'; input rating officer;proc print data=a1; run;

Page 7: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

The dataObs rating officer 1 76 1 2 65 1 3 85 1 4 74 1 5 59 2 6 75 2 7 81 2 8 67 2 9 49 3 10 63 3

Page 8: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

The dataObs rating officer 11 61 3 12 46 3 13 74 4 14 71 4 15 85 4 16 89 4 17 66 5 18 84 5 19 80 5 20 79 5

Page 9: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Plot the data

title1 'Plot of the data';symbol1 v=circle i=none c=black;proc gplot data=a1; plot rating*officer/frame;run;

Page 10: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference
Page 11: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Find and plot the means

proc means data=a1; output out=a2 mean=avrate; var rating; by officer;title1 'Plot of the means';symbol1 v=circle i=join c=black;proc gplot data=a2; plot avrate*officer/frame;run;

Page 12: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference
Page 13: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Random effects model• Yij = μi + εij

– the μi are iid N(μ, σμ2)

– the εij are iid N(0, σ2)

– μi and εij are independent

• Yij ~ N(μ, σμ2 + σ2)

• Two sources of variation

• Observations with the same i are not

independent, covariance is σμ2

Key difference

Page 14: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Random effects model

• This model is also called –Model II ANOVA–A variance components model• The components of variance are

σμ2 and σ2

• The models that we previously studied are called fixed effects models

Page 15: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Random factor effects model

• Yij = μ + i + εij

i ~ N(0, σμ2) *****

• εij ~ N(0, σ2)

• Yij ~ N(μ, σμ2 + σ2)

Page 16: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Parameters

• There are three parameters in these models–μ

–σμ2

–σ2

• The cell means (or factor levels) are random variables, not parameters

• Inference focuses on these variances

Page 17: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Primary Hypothesis

• Want to know if H0: σμ2 = 0

• This implies all i in model are equal but also all i not selected for analysis are also equal.

• Thus scope is broader than fixed effects case

• Need the factor levels of the study to be “representative” of the population

Page 18: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Alternative Hypothesis

• We are sometimes interested in estimating σμ

2 /(σμ2 + σ2)

• This is the same as σμ2 /σY

2

• In some applications it is called the intraclass correlation coefficient

• It is the correlation between two observations with the same I

• Also percent of total variation of Y

Page 19: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

ANOVA table• The terms and layout of the anova table

are the same as what we used for the fixed effects model

• The expected mean squares (EMS) are different because of the additional random effects but F test statistics are the same

• Be wary that hypotheses being tested are different

Page 20: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

EMS and parameter estimates

• E(MSA) = σ2 + nσμ2

• E(MSE) = σ2

• We use MSE to estimate σ2

• Can use (MSA – MSE)/n to estimate σμ2

• Question: Why might it we want an alternative estimate for σμ

2?

Page 21: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Main Hypotheses

• H0: σμ2 = 0

• H1: σμ2 ≠ 0

• Test statistic is F = MSA/MSE with r-1 and r(n-1) degrees of freedom, reject when F is large, report the P-value

Page 22: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Run proc glm

proc glm data=a1; class officer; model rating=officer; random officer/test;run;

Page 23: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Model and error output

Source DF MS F PModel 4 394 5.39 0.0068Error 15 73Total 19

Page 24: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Random statement output

Source Type III Expected MS

officer Var(Error) + 4 Var(officer)

Page 25: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Proc varcomp

proc varcomp data=a1; class officer; model rating=officer;run;

Page 26: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

OutputMIVQUE(0) Estimates

Variance Component ratingVar(officer) 80.41042Var(Error) 73.28333

Other methods are availablefor estimation, minque is the default

Page 27: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Proc mixed

proc mixed data=a1 cl; class officer; model rating=; random officer/vcorr;run;

Page 28: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Output

Covariance Parameter Estimates

Cov Parm Est Lower Upper

officer 80.4 24.4 1498Residual 73.2 39.9 175

80.4104/(80.4104+73.2833)=.5232

Page 29: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Output from vcorr

Row Col1 Col2 Col3 Col4 1 1.0000 0.5232 0.5232 0.52322 0.5232 1.0000 0.5232 0.52323 0.5232 0.5232 1.0000 0.52324 0.5232 0.5232 0.5232 1.0000

Page 30: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Other topics• Estimate and CI for μ, p1038

–Standard error involves a combination of two variances

–Use MSA instead of MSE → r-1 df

• Estimate and CI for σμ2 /(σμ

2 + σ2), p1040

• CIs for σμ2 and σ2, p1041-1047

–Available using Proc Mixed

Page 31: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Applications

• In the KNNL example we would like σμ

2 /(σμ2 + σ2) to be small, indicating

that the variance due to interviewer is small relative to the variance due to applicants

• In many other examples we would like this quantity to be large, –e.g., Are partners more likely to be

similar in sociability?

Page 32: Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference

Last slide

• Start reading KNNL Chapter 25

• We used program topic30.sas to generate the output for today