Skip to contents

york_fit() calculates the regression parameters of an error-considering linear regression.

Usage

york_fit(x, y, x_err, y_err, r = 0)

Arguments

x

vector of x values.

y

vector of y values. Has to be same the length as x.

x_err

Error on the x values. Has to be same the length as x.

y_err

Error on the y values. Has to be same the length as x.

r

Correlation coefficient of x_err and y_err at each data point. Default: 0 (independent errors). Has to be same the length as x. Optional.

Value

A list with regression parameters:

  • slope and its standard error

  • intercept and its standard error

  • weights of the points (normalized to 1)

  • residual standard error (sigma)

  • R2

  • p-value (two-tailed t-test).

Details

Regression fitting method according to York et al. (2004). The algorithm is described in the appendix of Wacker et al. (2014).

Contributors

Julian Tödter

References

York, D., Evensen, N. M., López Martínez, M., & De Basabe Delgado, J. (2004). Unified equations for the slope, intercept, and standard errors of the best straight line. American Journal of Physics, 72(3), 367-375. doi:10.1119/1.1632486

Wacker, U., Fiebig, J., Tödter, J., Schöne, B. R., Bahr, A., Friedrich, O., et al. (2014). Empirical calibration of the clumped isotope paleothermometer using calcites of various origins. Geochimica et Cosmochimica Acta, 141, 127-144. doi:10.1016/j.gca.2014.06.004

Examples

york_fit(
  x = c(1, 2, 3),
  y = c(1.1, 1.9, 3.2),
  x_err = c(0.1, 0.2, 0.1),
  y_err = c(0.2, 0.1, 0.2))
#> $slope
#> [1] 1.061775
#> 
#> $slope_se
#> [1] 0.1599487
#> 
#> $intercept
#> [1] -0.05293936
#> 
#> $intercept_se
#> [1] 0.3416549
#> 
#> $w
#> [1] 0.3412216 0.3175568 0.3412216
#> 
#> $sigma
#> [1] 0.1167873
#> 
#> $R2
#> [1] 0.9822171
#> 
#> $pval
#> [1] 0.09518642
#>