{"issue":{"created_at":"2011-12-14T20:17:18Z","state":"open","updated_at":"2011-12-15T19:29:25Z","user":{"gravatar_id":"3984cd736dbbb0a76fcdb7c5aa087f45","id":86978,"url":"https://api.github.com/users/wch","login":"wch","avatar_url":"https://secure.gravatar.com/avatar/3984cd736dbbb0a76fcdb7c5aa087f45?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"comments":3,"body":"I think this is a bug, or at the very least a problem with documentation. Someone emailed me asking about confidence intervals for loess fits. He was only able to get 68% confidence intervals.\r\n\r\nThese look the same:\r\n\r\n```R\r\nggplot(cars, aes(x=speed, y=dist)) + geom_point() + stat_smooth()\r\n\r\nggplot(cars, aes(x=speed, y=dist)) + geom_point() + stat_smooth(level=.2)\r\n```\r\n\r\nAccording to the docs for `predict.loess()`, it doesn't actually support the `level` argument.\r\n\r\nIn `stat-smooth-methods.r`, it looks like it's trying to make predictions with the `level` and `interval` arguments, even though they're not supported by `predict.loess`.\r\n\r\n```R\r\npredictdf.loess <- function(model, xseq, se, level) {\r\n  pred <- stats::predict(model, newdata = data.frame(x = xseq), se = se,\r\n    level = level, interval = if(se) \"confidence\" else \"none\")\r\n...\r\n```\r\n\r\nThe docs for stat_smooth say that you can change the level -- if this isn't actually possible for loess, then it should probably be noted.\r\n\r\nAlso, it looks like `predict.loess` isn't exported from `stats`, even though other predict functions are. I wonder if that's a bug.\r\n\r\n```R\r\n> stats::predict.loess\r\nError: 'predict.loess' is not an exported object from 'namespace:stats'\r\n\r\n> stats::predict.lm\r\nfunction (object, newdata, se.fit = FALSE, scale = NULL, df = Inf, \r\n    interval = c(\"none\", \"confidence\", \"prediction\"), level = 0.95, \r\n...\r\n...\r\n```\r\n","assignee":null,"id":2557603,"labels":[{"name":"bug","color":"e02a2a","url":"https://api.github.com/repos/hadley/ggplot2/labels/bug"},{"name":"stat","color":"ededed","url":"https://api.github.com/repos/hadley/ggplot2/labels/stat"}],"number":298,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"title":"stat_smooth: level has no effect with loess","html_url":"https://github.com/hadley/ggplot2/issues/298","closed_at":null,"url":"https://api.github.com/repos/hadley/ggplot2/issues/298","milestone":{"created_at":"2011-08-15T10:23:47Z","state":"open","due_on":null,"closed_issues":18,"creator":{"gravatar_id":"7ba164f40a50bc23dbb2aa825fb7bc16","id":4196,"url":"https://api.github.com/users/hadley","login":"hadley","avatar_url":"https://secure.gravatar.com/avatar/7ba164f40a50bc23dbb2aa825fb7bc16?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"number":1,"description":"","title":"0.9","open_issues":15,"url":"https://api.github.com/repos/hadley/ggplot2/milestones/1"}},"action":"created","comment":{"created_at":"2011-12-15T19:29:25Z","updated_at":"2011-12-15T19:29:25Z","user":{"gravatar_id":"3984cd736dbbb0a76fcdb7c5aa087f45","id":86978,"url":"https://api.github.com/users/wch","login":"wch","avatar_url":"https://secure.gravatar.com/avatar/3984cd736dbbb0a76fcdb7c5aa087f45?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"Here's a bit more I've found suggesting that it's the t distribution.\r\n\r\nFrom the `predict.loess` help page:\r\ndf: an estimate of the effective degrees of freedom used in estimating the residual scale, intended for use with t-based confidence intervals.\r\n\r\nIn Cleveland, Devlin, Grosse 1988, they calculate confidence intervals using t. I've also seen some references to Cleveland and Grosse 1991 mentioning the t-distribution.","id":3167501,"url":"https://api.github.com/repos/hadley/ggplot2/issues/comments/3167501"}}