check_o function

Check the fit for orthogonality of all points

Check the fit for orthogonality of all points

Checks for orthogonality of all points by calculating the angle between the slope of the tangent at (x0i,y0i)(x_{0i}, y_{0i}) and the slope of the Euclidean vector Di\|\vec{D}_i\| to (xi,yi)(x_i, y_i), which should be 9090^{\circ} if the Euclidean distance has been minimized. See 'Details'. latin1

check_o(object, plot = TRUE)

Arguments

  • object: an object returned from onls.
  • plot: logical. If TRUE, the α\alpha-values are plotted for a quick overview of orthogonality for all points.

Returns

A dataframe containing xix_i, x0ix_{0i}, yiy_i, y0iy_{0i}, αi\alpha_i, dfdx\frac{df}{dx} and a logical for 89.95<αi<90.0589.95^\circ < \alpha_i < 90.05^\circ. If plot = TRUE, a plot of the α\alpha-values in black if orthogonal, or red otherwise.

Details

This is a validation method for checking the orthogonality between all (x0i,y0i)(x_{0i}, y_{0i}) and (xi,yi)(x_i, y_i). The function calculates the angle between the slope mi\mathrm{m}_i of the tangent obtained from the first derivative at (x0i,y0i)(x_{0i}, y_{0i}) and the slope ni\mathrm{n}_i of the onls-minimized Euclidean distance between (x0i,y0i)(x_{0i}, y_{0i}) and (xi,yi)(x_i, y_i):

tan(αi)=mini1+mini,mi=df(x,β)dx0i,ni=yiy0ixix0i \tan(\alpha_i) = \left|\frac{\mathrm{m}_i - \mathrm{n}_i}{1 + \mathrm{m}_i \cdot \mathrm{n}_i}\right|, \,\, \mathrm{m}_i = \frac{df(x, \beta)}{dx_{0i}}, \,\, \mathrm{n}_i = \frac{y_i - y_{0i}}{x_i - x_{0i}} =>αi[]=tan1(mini1+mini)3602π => \alpha_i[^{\circ}] = \tan^{-1} \left( \left|\frac{\mathrm{m}_i - \mathrm{n}_i}{1 + \mathrm{m}_i \cdot \mathrm{n}_i}\right| \right) \cdot \frac{360}{2\pi}

Author(s)

Andrej-Nikolai Spiess

Examples

## Compare 'data range extended' orthogonal model with a ## 'data range restricted' model by setting "extend = c(0, 0)" ## => some x may not be orthogonal! x <- 1:20 y <- 10 + 3*x^2 y <- sapply(y, function(a) rnorm(1, a, 0.1 * a)) DAT <- data.frame(x, y) mod1 <- onls(y ~ a + b * x^2, data = DAT, start = list(a = 1, b = 1)) check_o(mod1) mod2 <- onls(y ~ a + b * x^2, data = DAT, start = list(a = 1, b = 1), extend = c(0, 0)) check_o(mod2)
  • Maintainer: Andrej-Nikolai Spiess
  • License: GPL (>= 2)
  • Last published: 2022-10-31

Useful links