Learn R Programming

onls (version 0.2)

x0, y0: x0/y0-values from orthogonal nonlinear least squares regression

Description

Returns the fitted foot points \(\hat\xi_i\) (x0) and the corresponding fitted response \(f(\hat\xi_i, \hat\theta)\) (y0) obtained by onls -- the points on the fitted curve/surface that the orthogonal-distance criterion projects each observation onto. See 'Details' for the criterion actually minimized, which reduces to plain Euclidean distance only in the simplest (single-predictor, unweighted) case; for multivariate and/or weighted fits, a precision-weighted quadratic form is minimized instead.

Usage

x0(object) 
y0(object)

Value

For single-predictor models, a length-\(n\) vector of \(\hat\xi_i\) (x0) or \(f(\hat\xi_i,\hat\theta)\) (y0) values. For multivariate models, x0 returns an \(n \times p\) matrix (one column per predictor); y0 still returns a length-\(n\) vector, since the response remains univariate.

Arguments

object

an object returned from onls.

Author

Andrej-Nikolai Spiess

Details

For a single-predictor (\(p=1\)), unweighted onls fit, the foot point \(\hat\xi_i\) (returned by x0) is obtained by minimizing the plain Euclidean distance between the observation \((x_i, y_i)\) and a point \((\xi_i, f(\xi_i,\hat\theta))\) on the fitted curve, $$\min_{\xi_i} \sqrt{(x_i-\xi_i)^2 + \left[y_i-f(\xi_i,\hat\theta)\right]^2}.$$ More generally -- for multivariate models (\(p>1\)) and/or fits using weights, sigma_x, or sigma_y -- onls instead minimizes a precision-weighted quadratic form (see 'Details' in onls for the full construction), $$\min_{\xi_i} \; Qyy_i \left[y_i - f(\xi_i,\hat\theta)\right]^2 + (\xi_i-x_i)^T Qx_i (\xi_i-x_i),$$ which reduces to the plain Euclidean distance above only when \(p=1\) and \(Qyy_i = Qx_i = 1\) (the default, unweighted case) -- Euclidean distance is therefore a special case of the criterion minimized, not the general rule.

x0 returns \(\hat\xi_i\): a length-\(n\) vector for single-predictor models, or an \(n \times p\) matrix (one column per predictor, in the order given by object$pred_names) for multivariate models. y0 returns \(f(\hat\xi_i,\hat\theta)\), always a length-\(n\) vector, since the response is univariate regardless of \(p\).

For single-predictor models, values are returned in the internally-used sorted-predictor order (matching object$pred/object$resp), not necessarily the original row order of the input data; for multivariate models, sorting is a no-op and the original observation order is used.

Examples

Run this code
DNase1 <- subset(DNase, Run == 1)
DNase1$density <- sapply(DNase1$density, function(x) rnorm(1, x, 0.1 * x))
mod <- onls(density ~ Asym/(1 + exp((xmid - log(conc))/scal)), 
             data = DNase1, start = list(Asym = 3, xmid = 0, scal = 1))
x0(mod)
y0(mod)

Run the code above in your browser using DataLab