Grilled Cheese

ExploreLog inSign up
Terms of UsePrivacy PolicyCommunity StandardsHelpGet the app

Grilled Cheese is a product of Village Compute

Version devBuilt at: 2026-12-03 22:42:33 EST

PhotosVideosAllPeople
LatestRanked
library("gratia")
library("mgcv")
library("ggplot2")

set.seed(2)
d <- expand.grid(x = seq(0, 1, length.out = 15),
  site = factor(1:12))
eta <- 0.3 + d$x + rnorm(12, sd = 0.6)[d$site]
d$y <- rpois(nrow(d), exp(eta))

fit <- gam(y ~ x + s(site, bs = "re"),
  data = d, family = poisson(), method = "REML")
avg <- conditional_values(fit, "x", marginalise = TRUE)
zero <- conditional_values(fit, "x", exclude = "s(site)")

draw(avg, ylab = "Expected count") +
  geom_line(data = zero, aes(x, .fitted), linetype = 2)
library("gratia")
library("mgcv")

fit <- gam(list(accel ~ s(times, k = 20),
  ~ s(times, k = 6)), data = MASS::mcycle,
  family = gaulss(), method = "REML")

conditional_moments(fit, condition = "times",
  moments = c("mean", "sd")) |>
  draw(xlab = "Time after impact (ms)")
library("gratia")
library("mgcv")
library("ggcube")

fit <- gam(Ozone ~ te(Temp, Wind, k = c(5, 5)) +
  s(Solar.R, k = 5), data = airquality,
  family = Gamma(link = "log"), method = "REML")
surface <- conditional_values(fit,
  condition = list(c("Temp", "Wind"), Solar.R = 250))

draw(surface, surface = "3d", contour = FALSE,
  surface_3d = list(yaw = 40, persp = FALSE),
  xlab = "Temperature (°F)", ylab = "Wind speed (mph)",
  zlab = "Ozone (ppb)")
library("gratia")
library("mgcv")

fit <- gam(Ozone ~ te(Temp, Wind, k = c(5, 5)) +
  s(Solar.R, k = 5), data = airquality,
  family = Gamma(link = "log"), method = "REML")

conditional_values(fit,
  condition = list(c("Temp", "Wind"),
    Solar.R = c(100, 250))) |>
  draw(xlab = "Temperature (°F)",
    ylab = "Wind speed (mph)", zlab = "Ozone (ppb)")
library("gratia")
library("mgcv")

fit <- gam(uptake ~ Treatment +
  s(conc, by = Treatment, k = 6) +
  s(Plant, bs = "re"), data = CO2, method = "REML")

slope <- difference_smooths(fit, select = "s(conc)",
  order = 1)
draw(slope) +
  ggplot2::geom_hline(yintercept = 0, linetype = 2)
library("gratia")
library("mgcv")

set.seed(4)
x <- seq(0, 1, length.out = 100)
y <- sin(6 * x) + rnorm(100, sd = 0.2)
fit <- gam(y ~ s(x, bs = "cr", k = 8), method = "REML")

smooth_estimates(fit, interval = "simultaneous",
  simultaneous_method = "tube",
  simultaneous_domain = c(0, 1)) |>
  draw()
library("gratia")
library("mgcv")

set.seed(1701)
d <- data.frame(x = runif(200))
d$y <- 2 * d$x + 4 * d$x^2 + rnorm(200, sd = 0.2)
fit <- scasm(y ~ s(x, bs = "sc", k = 6,
  xt = c("m+", "c+")), data = d, bs = 0)

draw(fit, interval = "simultaneous",
  interval_method = "shape", shape_source = "gaussian",
  n_sim = 2000, seed = 1702)
library("gratia")
library("mgcv")

set.seed(7)
d <- data.frame(x = runif(450), z = runif(450))
d$y <- sin(3 * pi * d$x) * cos(2 * pi * d$z) +
  rnorm(450, sd = 0.15)

coarse <- gam(y ~ s(x, z, k = 10), data = d,
  method = "REML")
fine <- gam(y ~ s(x, z, k = 55), data = d,
  method = "REML")
cmp <- compare_smooths(coarse, fine)
draw(cmp)
draw(cmp, show = "difference",
  pair = c("coarse", "fine"))
library("gratia")
library("mgcv")
library("ggplot2")

fit <- gam(Ozone ~ s(Temp) + s(Wind),
  data = airquality, method = "REML")

draw(fit) & theme(
  geom.gratia.smooth = element_geom(colour = "#A12377"),
  geom.gratia.interval = element_geom(fill = "#A12377"),
  gratia.alpha.interval = 0.18
)
library("gratia")
library("mgcv")

set.seed(12)
day <- seq(0, 365, length.out = 150)
temp <- 10 - 8 * cos(2 * pi * day / 365) +
  rnorm(length(day), sd = 1.5)

fit <- gam(temp ~ s(day, bs = "cc"),
  knots = list(day = c(0, 365)), method = "REML")
draw(fit, cyclic = "polar", rug = FALSE,
  xlab = "Day of year", ylab = "Temperature effect (°C)")
library("gratia")
library("mgcv")

# Gu and Wahba's additive example with Gaussian noise
d <- data_sim("additive", n = 400, dist = "normal",
  scale = 2, seed = 42)

fit <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3),
  data = d, family = gaussian(), method = "REML")

draw(fit, scales = "fixed", ncol = 2)
Photo, no description
Photo, no description
Photo, no description
Photo, no description
Photo, no description
Photo, no description
Photo, no description
Photo, no description
Photo, no description
Load more