Skip to content

Commit 87e9b85

Browse files
authored
compute the correct interval for locfit smoothers #3806 (#4435)
1 parent 79be511 commit 87e9b85

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

R/stat-smooth-methods.r

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ predictdf.loess <- function(model, xseq, se, level) {
4747

4848
if (se) {
4949
y = pred$fit
50-
ci <- pred$se.fit * stats::qt(level / 2 + .5, pred$df)
50+
ci = pred$se.fit * stats::qt(level / 2 + .5, pred$df)
5151
ymin = y - ci
5252
ymax = y + ci
5353
base::data.frame(x = xseq, y, ymin, ymax, se = pred$se.fit)
@@ -62,8 +62,9 @@ predictdf.locfit <- function(model, xseq, se, level) {
6262

6363
if (se) {
6464
y = pred$fit
65-
ymin = y - pred$se.fit
66-
ymax = y + pred$se.fit
65+
ci = pred$se.fit * stats::qt(level / 2 + .5, model$dp["df2"])
66+
ymin = y - ci
67+
ymax = y + ci
6768
base::data.frame(x = xseq, y, ymin, ymax, se = pred$se.fit)
6869
} else {
6970
base::data.frame(x = xseq, y = as.vector(pred))

0 commit comments

Comments
 (0)