Skip to content

Commit 74779f0

Browse files
committed
exercises 3
1 parent b3e228d commit 74779f0

File tree

7 files changed

+8122
-1
lines changed

7 files changed

+8122
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Some course logistics
66
- Instructor: James Scott, <http://jgscott.github.com>
77
- Meets: Mondays and Wednesday, 1:00 to 2:30 PM
88
- Classroom: UTC 4.120
9-
- Office hours: TBA
9+
- Office hours: Tuesday, 1-2 PM, via Zoom (link on Canvas). Wednesdays in person, 2:30-3:30 PM, CBA 6.478.
1010

1111
## Exercises
1212

data/greenbuildings.csv

Lines changed: 7821 additions & 0 deletions
Large diffs are not rendered by default.

exercises/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ Expected timeline:
2828
- By Feb 16: Fitting GLMs, A through C
2929
- By Feb 21: Fitting GLMs, D through G
3030

31+
## Exercises 3: Bayes and the Gaussian linear model
32+
33+
The goals of [Exercises 3](exercises03-SDS383D.pdf) are:
34+
- to introduce the normal/inverse-gamma conjugate prior for a location-scale model.
35+
- to construct and fit a simple Bayesian linear model from scratch, based on normal/inverse-gamma conjugacy.
36+
- to introduce hierarchical modeling, in the form of a regression model with heteroskedastic error.
37+
38+
Expected timeline TBA, but as a starting point:
39+
- By Feb 23: aim to finish the section on "A simple Gaussian location model"
40+
41+
3142
<!--
3243
## Exercises 2: Bayes and the Gaussian linear model
3344

exercises/exercises03-SDS383D.pdf

122 KB
Binary file not shown.

exercises/exercises03-SDS383D.tex

Lines changed: 260 additions & 0 deletions
Large diffs are not rendered by default.

r/gdpgrowth.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
a = 3
2+
NMC = 10000
3+
4+
# Using the redundant parameterization
5+
tau = rnorm(NMC, 0, 1)*sqrt(1/rgamma(NMC, a/2, rate=a/2))
6+
7+
hist(abs(tau), 500, prob=TRUE, xlim=c(0,5))
8+
curve(2*dt(x, a), add=TRUE)
9+
10+
# Adding a mean
11+
tau = rnorm(NMC, 3, 1)*sqrt(1/rgamma(NMC, a/2, rate=a/2))
12+
hist(abs(tau), 500, prob=TRUE, xlim=c(0,5))

r/green_starter.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
library(tidyverse)
2+
library(moderndive)
3+
4+
greenbuildings = read.csv('../data/greenbuildings.csv')
5+
6+
# Let's examine the "green premium"
7+
# starting point: define revenue per sq ft, as the rent times
8+
# the leasing rate (0-100 scale), divided by 100.
9+
# this is how much actual revenue the property brings in per square ft.
10+
greenbuildings = mutate(greenbuildings,
11+
rev_psf = Rent * leasing_rate/100)
12+
13+
# using lm to get coefs and std. errors
14+
lm1 = lm(rev_psf ~ green_rating + City_Market_Rent + age + class_a + class_b, data=greenbuildings)
15+
16+
# a regression table that I like better than "summary"
17+
moderndive::get_regression_table(lm1, conf.level = 0.95)

0 commit comments

Comments
 (0)