Skip to content

Commit

Permalink
in hindsight, simplifying the code is best; added a note in the text …
Browse files Browse the repository at this point in the history
…now to say I'm also excluding terms in the other linear predictors.
  • Loading branch information
gavinsimpson committed Jun 28, 2024
1 parent 6a8a1af commit aec0304
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions paper.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ ds <- data_slice(m2,
lat = evenly(lat, lower = 40, upper = 50, by = 0.5),
lon = evenly(lon, lower = -50, upper = -40, by = 0.5))
```
Next, `fitted_values()` returns the predicted values at the specified locations. I only include the spatial effects, excluding the effects of ocean depth and day of year:
Next, `fitted_values()` returns the predicted values at the specified locations. I only include the spatial effects, excluding the effects of ocean depth and day of year, and ignore terms in the other linear predictors as they do not affect the expected chlorophyll *a*:
```{r avg-chl-fv, dependson = c("fit-chl-lsslmodel", "avg-chl-ds"), cache = TRUE}
use <- c("(Intercept)", "s(lat,lon)", "s.1(lat,lon)", "s.2(lat,lon)")
use <- c("(Intercpt)", "s(lat,lon)")
fv <- fitted_values(m2, data = ds, terms = use) # predict
```
Finally, I summarise the predictions for the location parameter to yield the average of the predicted values
Expand Down
6 changes: 3 additions & 3 deletions paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ ds <- data_slice(m2,
lat = evenly(lat, lower = 40, upper = 50, by = 0.5),
lon = evenly(lon, lower = -50, upper = -40, by = 0.5))
```
Next, `fitted_values()` returns the predicted values at the specified locations. I only include the spatial effects, excluding the effects of ocean depth and day of year:
Next, `fitted_values()` returns the predicted values at the specified locations. I only include the spatial effects, excluding the effects of ocean depth and day of year, and ignore terms in the other linear predictors as they do not affect the expected chlorophyll *a*:

``` r
use <- c("(Intercept)", "s(lat,lon)", "s.1(lat,lon)", "s.2(lat,lon)")
use <- c("(Intercpt)", "s(lat,lon)")
fv <- fitted_values(m2, data = ds, terms = use) # predict
```
Finally, I summarise the predictions for the location parameter to yield the average of the predicted values
Expand All @@ -171,7 +171,7 @@ fv |>
## # A tibble: 1 x 1
## chl_a
## <dbl>
## 1 1.07
## 1 0.930
```
While this is an acceptable answer to the question, it lacks an uncertainty estimate. This is where posterior sampling is useful. With a small modification of the above code and a little data wrangling, we can produce an uncertainty estimate ,using `fitted_samples()` to generate posterior draws of the expected chlorophyll *a*:

Expand Down
Binary file modified paper_files/figure-latex/m1-appraise-1.pdf
Binary file not shown.
Binary file modified paper_files/figure-latex/m2-appraise-1.pdf
Binary file not shown.
Binary file modified paper_files/figure-latex/m2-draw-1.pdf
Binary file not shown.
Binary file not shown.

0 comments on commit aec0304

Please sign in to comment.