Modeling data with three (or more) levels

Part 2

Prof. Maria Tackett

Mar 27, 2024

Announcements

  • Quiz 04 - due March 28 at noon

    • Covers readings and lectures March 4 - 20

    • Longitudinal modeling, Chapter 9 of BMLR

  • Project 02

    • Presentations April 3 during lecture
    • Written report + GitHub repo due April 4 at 11:59pm
  • Final project - Round 1 submission (optional) due April 25

Topics

  • Write form of model for models with more than two levels

  • Interpret fixed and random effects at each level

  • See how three-level models are used in data analysis example

Note

The notes are based on Chapter 10 of Roback and Legler (2021) and Jones (1991) unless otherwise noted.

Data: Housing prices in Southampton

The data includes the price and characteristics for 918 houses sold between 1986 and 1991 in Southampton, England. The data were originally collected from a local real estate agency and were analyzed in Jones (1991). The primary variables of interest are

  • price: Sales price in thousands of £
  • Age: Age of the house
  • Bedrooms: Number of bedrooms
  • House Type: (semi-detached, detached, bungalow, terrace, flat)
  • Central heating: Whether house has central heating (0: yes, 1: no)
  • Garage: Number of garages (none, single, double)
  • Districts: one of 34 districts
  • Half-years: Half-year periods beginning the second half of 1986

Data structure

Portions of Figure 2b from Jones (1991)

Note

You can access the paper on Canvas.The paper uses different symbols to represent parameters than what is in the textbook. The slides will follow the textbook.

Unconditional means model

Yijk=α0+u~i+uij+ϵijku~i∼N(0,σu~2)uij∼N(0,σu2)ϵijk∼N(0,σ2)

Level One (house within time)

Yijk=aij+ϵijk,ϵijk∼N(0,σ2)

Level Two (time within district)

aij=ai+uij,uij∼N(0,σu2)

Level Three (district)

ai=α0+u~i,u~i∼N(0,σu~2)

Model A

Table 1 from Jones (1991)


Interpret β^0 (this is α0 in our model notation)

Table 1 from Jones (1991)

Model A: Random effects

  • About 29.8% of the variability in price is explained by differences between districts.
  • About 21% of the variability in price is explained by differences between time periods within the same district.
  • About 49.2% of the variability in price is explained by differences between houses in the same district sold in the same time period.

Model B: Covariates + random intercepts

Table 1 from Jones (1991)

Model B: Composite model

Yijk=α0+β1 ageijk+β2 detachedijk+β3 bungalowijk+β4 terraceijk+β5 flatijk+β6 bedroomsijk+β7 heatingijk+β8 singleijk+β9 doubleijk+[u~i+uij+ϵijk]u~i∼N(0,σu~2)uij∼N(0,σu2)ϵijk∼N(0,σ2)

Write the Level One, Level Two, Level Three models.

Model C: Additional random effect

  1. How does this model differ from Model B?
  2. Write the composite model.
  3. Write the Level One, Level Two, and Level Three models.

Table 1 from Jones (1991)

Visualizing price by district over time

Figure 3 from Jones (1991)
  1. What do you observe from the plot?
  2. What terms in the model can be understood from the plot?
  3. How might you use this type of plot to support decisions you make in the analysis?

Price by district and bedrooms

Figure 4 from Jones (1991)
  1. What do you observe from the plot?
  2. What terms in the model can be understood from the plot?
  3. How might you use this type of plot to support decisions you make in the analysis?


How does our understanding of the effect of bedrooms differ in this model compared to Model B?

Covariance structure of observations

Questions we want to answer

Let’s consider the covariance structure between observations at different levels.

  • What is the covariance structure of houses in the same district sold in different time periods? (Yij,Yij′)
  • What is the covariance structure of houses in the same district sold in the same time period? (Yijk,Yijk′)
    • How does this structure differ between Model B and Model C in Jones (1991)?

Calculating variance and covariance

Suppose Y1=a1X1+a2X2+a3 and Y2=b1X1+b2X2+b3 where X1 and X2 are random variables and ai and bi are constants for i=1,2,3, then we know from probability theory that: Var(Y1)=a12Var(X1)+a22Var(X2)+2a1a2Cov(X1,X2)Cov(Y1,Y2)=a1b1Var(X1)+a2b2Var(X2)+(a1b2+a2b1)Cov(X1,X2)

We will use these properties to define the covariance structure of the observations in the model.

From BMLR: Section 9.7.5

Covariance structure under Model B

Let Yijk be the sales price for the house k in district i sold in time period j, and x1,…,x9 be the house-level covariates. Yijk=α0+∑i=19βixi+[u~i+uij+ϵijk] u~i∼N(0,σu~2),uij∼N(0,σu2),ϵijk∼N(0,σ2)

Variance and covariance derivations

  1. Use Model B to write the derivation of Var(Yijk), the variance of an individual observation.
  2. Use Model B to write the derivation of Cov(Yijk,Yijk′), the covariance between houses sold in the same time period that are in the same district.
  3. Write Cov(Yij), covariance matrix for houses sold in the same time period in the same district

References

Jones, Kelvyn. 1991. “Specifying and Estimating Multi-Level Models for Geographical Research.” Transactions of the Institute of British Geographers, 148–59.
Roback, Paul, and Julie Legler. 2021. Beyond multiple linear regression: applied generalized linear models and multilevel models in R. CRC Press.

🔗 STA 310 - Spring 2024

1 / 19
Modeling data with three (or more) levels Part 2 Prof. Maria Tackett Mar 27, 2024

  1. Slides

  2. Tools

  3. Close
  • Modeling data with three (or more) levels
  • Announcements
  • Topics
  • Data: Housing prices in Southampton
  • Data structure
  • Unconditional means model
  • Model A
  • Model A: Random effects
  • Model B: Covariates + random intercepts
  • Model B: Composite model
  • Model C: Additional random effect
  • Visualizing price by district over time
  • Price by district and bedrooms
  • Covariance structure of observations
  • Questions we want to answer
  • Calculating variance and covariance
  • Covariance structure under Model B
  • Variance and covariance derivations
  • References
  • f Fullscreen
  • s Speaker View
  • o Slide Overview
  • e PDF Export Mode
  • b Toggle Chalkboard
  • c Toggle Notes Canvas
  • d Download Drawings
  • ? Keyboard Help