Skip to content

Commit 05dcb89

Browse files
committed
add final model plot to readme
1 parent 9bff96f commit 05dcb89

File tree

3 files changed

+48
-19
lines changed

3 files changed

+48
-19
lines changed

README.Rmd

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ City](https://www1.nyc.gov/html/dot/html/about/datafeeds.shtml#Pedestrians).
2828

2929
Final result looks like this:
3030
```{r load, echo = FALSE}
31+
library (ggplot2)
32+
theme_set (theme_minimal ())
3133
devtools::load_all (".", export_all = FALSE)
3234
data_dir <- "/data/data/moveability/nyc"
3335
```
@@ -48,3 +50,15 @@ The final flow model looks like this:
4850

4951
![](./man/figures/flowmap.png)
5052

53+
And a final statistical relationship between modelled and observed pedestrian
54+
counts that looks like this:
55+
```{r model-plot}
56+
data_dir <- "/data/data/moveability/nyc"
57+
dat <- readRDS (file.path (data_dir, "ped-model-final.Rds"))
58+
mod <- lm (dat$p ~ dat$flowvars)
59+
res <- data.frame (predicted = predict (mod),
60+
actual = dat$p)
61+
ggplot (res, aes (x = predicted, y = actual)) +
62+
geom_point () +
63+
geom_smooth (method = "lm")
64+
```

README.md

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Status](https://travis-ci.org/moveability/calibration.svg)](https://travis-ci.or
55
[![Project Status: Concept - Minimal or no implementation has been done
66
yet.](http://www.repostatus.org/badges/0.1.0/concept.svg)](http://www.repostatus.org/#concept)
77

8-
calibration
9-
===========
8+
# calibration
109

1110
<!-- badges: start -->
1211

@@ -21,7 +20,7 @@ City](https://www1.nyc.gov/html/dot/html/about/datafeeds.shtml#Pedestrians).
2120

2221
Final result looks like this:
2322

24-
#> Loading calibration
23+
#> Loading nyped
2524

2625
``` r
2726
x <- calc_layer_scales (data_dir, model = "final")
@@ -31,22 +30,22 @@ x <- calc_layer_scales (data_dir, model = "final")
3130
knitr::kable (x)
3231
```
3332

34-
| | layer | estimates| full\_rel| ped\_rel| full\_abs| ped\_abs| t| p|
35-
|-----|:--------|--------------:|-----------:|-----------:|-------------:|-------------:|----------:|----------:|
36-
| 13 | hea-dis | 105658.191105| 0.5719363| 0.3459949| 60429.755766| 36557.196583| 9.868915| 0.0000000|
37-
| 1 | sub-dis | 22.566344| 0.5219142| 0.5682277| 11.777695| 12.822822| 8.986039| 0.0000000|
38-
| 12 | sub-cen | -10.087818| -0.2347841| -0.3304276| 2.368459| 3.333293| -6.994975| 0.0000000|
39-
| 6 | sub-hea | 8.378134| 0.4338598| 0.4335501| 3.634935| 3.632341| 6.658314| 0.0000000|
40-
| 7 | sus-edu | -5923.748211| -0.6416411| -0.5697332| 3800.920378| 3374.956231| -6.056855| 0.0000000|
41-
| 8 | edu-hea | -24921.480025| -0.4563520| -0.3789464| 11372.966534| 9443.905594| -5.607032| 0.0000002|
42-
| 4 | edu-tra | 23977.299359| 0.3225789| 0.2620421| 7734.569685| 6283.060961| 5.347316| 0.0000006|
43-
| 2 | sub-tra | 6.444493| 0.2392262| 0.2839541| 1.541692| 1.829940| 5.080766| 0.0000018|
44-
| 9 | sus-res | 6258.235319| 0.3904308| 0.4362252| 2443.407704| 2729.999677| 5.080036| 0.0000018|
45-
| 11 | sus-sub | -1336.884757| -0.1903741| -0.2170844| 254.508256| 290.216796| -4.039428| 0.0001066|
46-
| 5 | sus-ent | 1445.795365| 0.2070682| 0.1704797| 299.378267| 246.478763| 4.002238| 0.0001220|
47-
| 3 | edu-dis | -78056.981732| -0.5872607| -0.3261469| 45839.794420| 25458.042278| -3.183290| 0.0019518|
48-
| 14 | ent-tra | 38179.006598| 0.1893925| 0.1540936| 7230.818735| 5883.141715| 3.176518| 0.0019936|
49-
| 10 | edu-sus | 16903.889029| 0.2340051| 0.1677712| 3955.596308| 2835.985535| 3.033825| 0.0030914|
33+
| | layer | estimates | full\_rel | ped\_rel | full\_abs | ped\_abs | t | p |
34+
| -- | :------ | -------------: | ----------: | ----------: | -----------: | -----------: | ---------: | --------: |
35+
| 13 | hea-dis | 105658.191105 | 0.5719363 | 0.3459949 | 60429.755766 | 36557.196583 | 9.868915 | 0.0000000 |
36+
| 1 | sub-dis | 22.566344 | 0.5219142 | 0.5682277 | 11.777695 | 12.822822 | 8.986039 | 0.0000000 |
37+
| 12 | sub-cen | \-10.087818 | \-0.2347841 | \-0.3304276 | 2.368459 | 3.333293 | \-6.994975 | 0.0000000 |
38+
| 6 | sub-hea | 8.378134 | 0.4338598 | 0.4335501 | 3.634935 | 3.632341 | 6.658314 | 0.0000000 |
39+
| 7 | sus-edu | \-5923.748211 | \-0.6416411 | \-0.5697332 | 3800.920378 | 3374.956231 | \-6.056855 | 0.0000000 |
40+
| 8 | edu-hea | \-24921.480025 | \-0.4563520 | \-0.3789464 | 11372.966534 | 9443.905594 | \-5.607032 | 0.0000002 |
41+
| 4 | edu-tra | 23977.299359 | 0.3225789 | 0.2620421 | 7734.569685 | 6283.060961 | 5.347316 | 0.0000006 |
42+
| 2 | sub-tra | 6.444493 | 0.2392262 | 0.2839541 | 1.541692 | 1.829940 | 5.080766 | 0.0000018 |
43+
| 9 | sus-res | 6258.235319 | 0.3904308 | 0.4362252 | 2443.407704 | 2729.999677 | 5.080036 | 0.0000018 |
44+
| 11 | sus-sub | \-1336.884757 | \-0.1903741 | \-0.2170844 | 254.508256 | 290.216796 | \-4.039428 | 0.0001066 |
45+
| 5 | sus-ent | 1445.795365 | 0.2070682 | 0.1704797 | 299.378267 | 246.478763 | 4.002238 | 0.0001220 |
46+
| 3 | edu-dis | \-78056.981732 | \-0.5872607 | \-0.3261469 | 45839.794420 | 25458.042278 | \-3.183290 | 0.0019518 |
47+
| 14 | ent-tra | 38179.006598 | 0.1893925 | 0.1540936 | 7230.818735 | 5883.141715 | 3.176518 | 0.0019936 |
48+
| 10 | edu-sus | 16903.889029 | 0.2340051 | 0.1677712 | 3955.596308 | 2835.985535 | 3.033825 | 0.0030914 |
5049

5150
With the following model statistics:
5251

@@ -90,3 +89,19 @@ summary (lm (dat$p ~ f_))
9089
The final flow model looks like this:
9190

9291
![](./man/figures/flowmap.png)
92+
93+
And a final statistical relationship between modelled and observed
94+
pedestrian counts that looks like this:
95+
96+
``` r
97+
data_dir <- "/data/data/moveability/nyc"
98+
dat <- readRDS (file.path (data_dir, "ped-model-final.Rds"))
99+
mod <- lm (dat$p ~ dat$flowvars)
100+
res <- data.frame (predicted = predict (mod),
101+
actual = dat$p)
102+
ggplot (res, aes (x = predicted, y = actual)) +
103+
geom_point () +
104+
geom_smooth (method = "lm")
105+
```
106+
107+
<img src="man/figures/README-model-plot-1.png" width="100%" />

man/figures/README-model-plot-1.png

29.2 KB
Loading

0 commit comments

Comments
 (0)