---
title:  Mortality and air pollution
---


- Does ambient air pollution contribute to mortality?
- there is satellite-derived data available
- let's investigate!
- see [here](https://sites.wustl.edu/acag/datasets/surface-pm2-5/#V6.GL.02.04)
- or more specifically [here](https://wustl.app.box.com/s/s7eiaxytjr9w1z7glat45cesitcemprv/folder/327763830392)
- download and save the 2015 file.  I've put it in my Downloads folder


Load the data, tell R -999 means missing values.  also 
```{r pm}
library(terra)
x = rast('~/Downloads/V6GL02.04.CNNPM25.0p10.GL.201501-201512.nc')
NAflag(x) = -999
plot(x)
```

again, with a nicer colour scale
```{r pmPLot}
setMinMax(x)
pmCol = mapmisc::colourScale(
	x, style='equal', transform='log',
	dec=-1, breaks=12, col='Spectral',
	rev=TRUE)
plot(x, breaks=pmCol$breaks, col=pmCol$col, legend=FALSE)
mapmisc::legendBreaks("left", pmCol)
```

```{r betterPmPlot}

worldMap = vect(rnaturalearth::ne_countries(type="countries", scale="medium"))
worldMapT = project(worldMap, crs(x))

euro = readRDS("../data/euroSpaceTerra.rds")
euroT = project(euro, crs(x))
mapmisc::map.new(euroT)
plot(x, breaks=pmCol$breaks, col=pmCol$col, add=TRUE, legend=FALSE)
plot(worldMapT, add=TRUE)
mapmisc::legendBreaks("right", pmCol)
```

```{r extract}
pmNuts = extract(x, euroT, fun='mean', na.rm=TRUE)
euro$pm = pmNuts$PM25
euro$sqrtPm = sqrt(euro$pm)
```

```{r plotPmSmr}
plot(euro$sqrtPm, euro$smr)
```


# Fit BYM model



# Plot some results


