Description Usage Arguments Details Value Side Effects References See Also Examples

View source: R/discontinuity.r

This function uses a comparison of left and right handed nonparametric regression curves to assess the evidence for the presence of one or more discontinuities in a regression curve or surface. A hypothesis test is carried out, under the assumption that the errors in the data are approximately normally distributed. A graphical indication of the locations where the evidence for a discontinuity is strongest is also available.

1 | ```
sm.discontinuity(x, y, h, hd, ...)
``` |

`x` |
a vector or two-column matrix of covariate values. |

`y` |
a vector of responses observed at the covariate locations. |

`h` |
a smoothing parameter to be used in the construction of the nonparametric
regression estimates. A normal kernel
function is used and |

`hd` |
a smoothing parameter to be used in smoothing the differences of the
left and right sided nonparametric regression estimates. A normal kernel
function is used and |

`...` |
other optional parameters are passed to the |

The reference below describes the statistical methods used in the function. There are minor differences in somecomputational details of the implementation.

Currently duplicated rows of `x`

cause a difficulty in the two covariate case. Duplicated rows should be removed.

a list containing the following items

`p` |
the p-value for the test of the null hypothesis that no discontinuities are present. |

`sigma` |
the estimated standard deviation of the errors. |

`eval.points` |
the evaluation points of the nonparametric
regression estimates. When |

`st.diff` |
a vector or matrix of standardised differences between the left and right sided estimators at the evaluation points. |

`diffmat` |
when |

`angle` |
when |

`h` |
the principal smoothing parameter. |

`hd` |
the smoothing parameter used for double-smoothing (see the reference below). |

a plot on the current graphical device is produced, unless the option
`display="none"`

is set.

Bowman, A.W., Pope, A. and Ismail, B. (2006).
Detecting discontinuities in nonparametric regression curves and
surfaces.
*Statistics \& Computing*, 16, 377–390.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | ```
par(mfrow = c(3, 2))
with(nile, {
sm.discontinuity(Year, Volume, hd = 0)
sm.discontinuity(Year, Volume)
ind <- (Year > 1898)
plot(Year, Volume)
h <- h.select(Year, Volume)
sm.regression(Year[!ind], Volume[!ind], h, add = TRUE)
sm.regression(Year[ ind], Volume[ ind], h, add = TRUE)
hvec <- 1:15
p <- numeric(0)
for (h in hvec) {
result <- sm.discontinuity(Year, Volume, h,
display = "none", verbose = 0)
p <- c(p, result$p)
}
plot(hvec, p, type = "l", ylim = c(0, max(p)), xlab = "h")
lines(range(hvec), c(0.05, 0.05), lty = 2)
})
with(trawl, {
Position <- cbind(Longitude, Latitude)
ind <- (Longitude < 143.8)
# Remove a repeated point which causes difficulty with sm.discontinuity
ind[54] <- FALSE
sm.regression(Position[ind,], Score1[ind], theta = 35, phi = 30)
sm.discontinuity(Position[ind,], Score1[ind], col = "blue")
})
par(mfrow = c(1, 1))
# The following example takes longer to run.
# Alternative values for nside are 32 and 64.
# Alternative values of yjump are 1 and 0.5.
# nside <- 16
# yjump <- 2
# x1 <- seq(0, 1, length = nside)
# x2 <- seq(0, 1, length = nside)
# x <- expand.grid(x1, x2)
# x <- cbind(x1 = x[, 1], x2 = x[, 2])
# y <- rnorm(nside * nside)
# ind <- (sqrt((x[, 1] - 0.5)^2 + (x[, 2] - 0.5)^2) <= 0.25)
# y[ind] <- y[ind] + yjump
# image(x1, x2, matrix(y, ncol = nside))
# sm.discontinuity(x, y, df = 20, add = TRUE)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.