Description Usage Arguments Details Value References Examples
bfsl
calculates the bestfit straight line to independent points with
(possibly correlated) normally distributed errors in both coordinates.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  bfsl(...)
## Default S3 method:
bfsl(x, y = NULL, sd_x = 0, sd_y = 1, r = 0, control = bfsl_control(), ...)
## S3 method for class 'formula'
bfsl(
formula,
data = parent.frame(),
sd_x,
sd_y,
r = 0,
control = bfsl_control(),
...
)

... 
Further arguments passed to or from other methods. 
x 
A vector of x observations or a data frame (or an
object coercible by 
y 
A vector of y observations. 
sd_x 
A vector of x measurement error standard deviations. If it is of length one, all data points are assumed to have the same x standard deviation. 
sd_y 
A vector of y measurement error standard deviations. If it is of length one, all data points are assumed to have the same y standard deviation. 
r 
A vector of correlation coefficients between errors in x and y. If it is of length one, all data points are assumed to have the same correlation coefficient. 
control 
A list of control settings. See 
formula 
A formula specifying the bivariate model (as in 
data 
A data.frame containing the variables of the model. 
bfsl
provides the general leastsquares estimation solution to the
problem of fitting a straight line to independent data with (possibly
correlated) normally distributed errors in both x
and y
.
With sd_x = 0
the (weighted) ordinary least squares solution is
obtained. The calculated standard errors of the slope and intercept
multiplied with sqrt(chisq)
correspond to the ordinary least squares
standard errors.
With sd_x = c
, sd_y = d
, where c
and d
are
positive numbers, and r = 0
the Deming regression solution is obtained.
If additionally c = d
, the orthogonal distance regression solution,
also known as major axis regression, is obtained.
Setting sd_x = sd(x)
, sd_y = sd(y)
and r = 0
leads to
the geometric mean regression solution, also known as reduced major
axis regression or standardised major axis regression.
The goodness of fit metric chisq
is a weighted reduced chisquared
statistic. It compares the deviations of the points from the fit line to the
assigned measurement error standard deviations. If x
and y
are
indeed related by a straight line, and if the assigned measurement errors
are correct (and normally distributed), then chisq
will equal 1. A
chisq > 1
indicates underfitting: the fit does not fully capture the
data or the measurement errors have been underestimated. A chisq < 1
indicates overfitting: either the model is improperly fitting noise, or the
measurement errors have been overestimated.
An object of class "bfsl
", which is a list
containing
the following components:
coefficients 
A 
chisq 
The goodness of fit (see Details). 
fitted.values 
The fitted mean values. 
residuals 
The residuals, that is 
df.residual 
The residual degrees of freedom. 
cov.ab 
The covariance of the slope and intercept. 
control 
The control 
convInfo 
A 
call 
The matched call. 
data 
A 
York, D. (1968). Least squares fitting of a straight line with correlated errors. Earth and Planetary Science Letters, 5, 320–324, https://doi.org/10.1016/S0012821X(68)800597
1 2 3 4 5 6 7 8 9  x = pearson_york_data$x
y = pearson_york_data$y
sd_x = 1/sqrt(pearson_york_data$w_x)
sd_y = 1/sqrt(pearson_york_data$w_y)
bfsl(x, y, sd_x, sd_y)
bfsl(y~x, pearson_york_data, sd_x, sd_y)
fit = bfsl(pearson_york_data)
plot(fit)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.