Skip to content

Instantly share code, notes, and snippets.

View njtierney's full-sized avatar
🐝
Back at work

Nicholas Tierney njtierney

🐝
Back at work
View GitHub Profile
# something like this?
library(tidyverse)
library(lobstr)
existing_data_list <- list(
  data.frame(x = 1:5, y = 0),
  data.frame(z = 5:1),
  data.frame(y = 1:5, a = 2)
)
library(conmat)
library(socialmixr)
library(tidyverse)
countries_of_interest <- c("Italy", "Spain")
list_countries <- map(countries_of_interest,
\(x) wpp_age(x, years = 2015))
list_conmat_pop <- map(
.x = list_countries,
bee_trips <- 1:10

sample(bee_trips,
       size = 100,
       replace = TRUE)
#>   [1]  2  4  5  2  3  7  5  8  5  7  6  2  8  4 10  6  2  3 10  4  6  8  9  5  6
#>  [26]  6  8  7  6  8  5  4  7  5  6  3  5  3  7  1  9  4  8  7  8  3 10  3  5 10
#>  [51] 10  5  8  6  2  6  6  3  6  5  9  6  5  9  6  9  2  5  6  4  8  4  6  2  7
#&gt; [76] 8 9 10 7 1 3 4 5 5 4 6 8 6 2 4 5 9 10 5 9 4 5 2 5 3
library(socialmixr)
library(conmat)
italy_2005 <- wpp_age("Italy", "2005")
head(italy_2005)
italy_2005_pop <- as_conmat_population(
data = italy_2005,
age = lower.age.limit,
library(tidyverse)
library(palmerpenguins)

ggplot(penguins,
       aes(x = bill_length_mm,
           y = bill_depth_mm,
           colour = island)) + 
  geom_point() + 
  scale_colour_brewer(palette = "Dark2")
# this didn't work in MCMC, we'll have to work out why.
# simulate species count data over 10 timesteps
n_times <- 10
times <- seq_len(n_times)
truth <- 100 * exp(sin(times))
y <- rpois(n_times, truth)
plot(y ~ times, type = "l")

library(greta.gam)
library(greta)
#> 
#> Attaching package: 'greta'
#> The following objects are masked from 'package:stats':
#> 
#>     binomial, cov2cor, poisson
#> The following objects are masked from 'package:base':
#> 
#>     %*%, apply, backsolve, beta, chol2inv, colMeans, colSums, diag,
==> Testing R file using 'testthat'

ℹ Loading greta
ℹ Initialising python and checking dependencies, this may take a moment.

✔ Initialising python and checking dependencies ... done!

TensorShape conversions remain stable

... Offending code

x <- shape(NA, 3)
tensorflow::as_tensor(x)
# using distributional
options(tidyverse.quiet = TRUE)
library(tidyverse)
library(distributional)

dat_dist <- tibble(
  means = c(1:5),
  sds = c(5:1),
  vals = means + rnorm(5, 0.1, 0.1),