invpred
statistics: x0 = invpred (x, y, y0)
statistics: [x0, dxlo, dxup] = invpred (x, y, y0)
statistics: […] = invpred (…, name, value)
Inverse prediction from a simple linear regression.
x0 = invpred (x, y, y0) fits the simple
linear regression of y on x and returns, for each element of
y0, the value of the predictor at which the fitted line takes that
response. x and y must be vectors of real values of the same
length; y0 may be of any size and x0 is returned with the same
size. Observations where either x or y is NaN are
dropped in pairs before the fit.
[x0, dxlo, dxup] = invpred (…) also returns
the width of a confidence interval on either side of x0, so that the
interval is [x0 - dxlo, x0 + dxup]. The
bounds follow Fieller’s theorem and are therefore not symmetric about
x0. They are not simultaneous over the elements of y0, and
they need not be finite: when the slope is not significantly different from
zero at the requested level the interval is unbounded, and dxlo and
dxup are both Inf.
[…] = invpred (…, name, value) accepts the
following name-value pairs:
"alpha" is the significance level of the interval, a scalar
strictly between 0 and 1, so that the interval has confidence
. The default is 0.05.
"predopt" selects what the interval covers. With
"observation", the default, it covers a new observation whose
response is y0. With "curve", it covers the point at which
the true regression line takes the value y0, and is narrower because
it carries no new-observation variance.
See also: regress, fitlm, polyfit
Source Code: invpred
Estimate the predictor value at which a fitted line reaches a response of 20, with a 95% confidence interval either side of it.
x = (1:10)'; y = 2 + 3 * x + [0.5; -0.3; 0.2; 0.8; -0.6; 0.1; -0.4; 0.7; -0.2; 0.3]; [x0, dxlo, dxup] = invpred (x, y, 20)
x0 = 5.9647 dxlo = 0.4086 dxup = 0.4103
interval = [x0 - dxlo, x0 + dxup]
interval = 5.5562 6.3750