50% off | Unlimited Data & AI Learning
Get 50% off unlimited learning

IsoplotR (version 0.5)

yorkfit: Linear regression of X,Y-variables with correlated errors

Description

Implements the unified regression algorithm of York et al. (2004) which, although based on least squares, yields results that are consistent with maximum likelihood estimates of Ludwig and Titterington (1994)

Usage

yorkfit(X, Y, sX, sY, rXY)

Arguments

X
vector of measurements
Y
vector of measurements
sX
standard errors of X
sY
standard errors of Y
rXY
correlation coefficients between X and Y

Value

a two element list of vectors containing
a
the intercept of the straight line fit and its standard error
b
the slope of the fit and its standard error

References

Ludwig, K. R., and D. M. Titterington. "Calculation of 230ThU isochrons, ages, and errors." Geochimica et Cosmochimica Acta 58.22 (1994): 5031-5042.

York, Derek, et al. "Unified equations for the slope, intercept, and standard errors of the best straight line." American Journal of Physics 72.3 (2004): 367-375.

Examples

Run this code
   X <- c(1.550,12.395,20.445,20.435,20.610,24.900,
          28.530,50.540,51.595,86.51,106.40,157.35)
   Y <- c(.7268,.7849,.8200,.8156,.8160,.8322,
          .8642,.9584,.9617,1.135,1.230,1.490)
   n <- length(X)
   sX <- X*0.01
   sY <- Y*0.005
   rXY <- rep(0.8,n)
   fit <- yorkfit(X,Y,sX,sY,rXY)
   covmat <- matrix(0,2,2)
   plot(range(X),fit$a[1]+fit$b[1]*range(X),type='l',ylim=range(Y))
   for (i in 1:n){
       covmat[1,1] <- sX[i]^2
       covmat[2,2] <- sY[i]^2
       covmat[1,2] <- rXY[i]*sX[i]*sY[i]
       covmat[2,1] <- covmat[1,2]
       ell <- ellipse(X[i],Y[i],covmat,alpha=0.05)
       polygon(ell)
   }

Run the code above in your browser using DataLab