Skip to content

Instantly share code, notes, and snippets.

@davharris
Created April 3, 2014 00:53
Show Gist options
  • Save davharris/9946350 to your computer and use it in GitHub Desktop.
Save davharris/9946350 to your computer and use it in GitHub Desktop.
library(ggplot2)
library(mgcv)
# Something bad happens at t=400 and lambda drops
lambdas = c(runif(4E2, 6, 8), runif(1E2, 2, 4))
obs = rpois(length(lambdas), lambdas)
qplot(x = 1:length(obs), y = obs) +
stat_smooth(method = "gam", family = poisson, formula = y ~ s(x), size = 3)
@davharris
Copy link
Author

Kernel regression might be better-suited for this, but I'm not sure if it has ggplot2 integration, so I used a GAM :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment