I am looking for a way to perform weighted total least squares in R. I know one can use PCA for this as described nicely in the following post. How to perform orthogonal regression (total least squares) via PCA?
However, I need a weighted version of total least squares, i.e. I want to account for measurement error in my data, where the error $(\Delta x_i, \Delta y_i)$ can be different for each data point $(x_i, y_i)$. Any suggestions? Specifically, I want to do the following:
x = rnorm(10,0,2)
x.se = rnorm(10,0,0.7)
y = 20*x
y.se = rnorm(10,0,1)
r <- prcomp( ~ x + y )
slope <- r$rotation[2,1] / r$rotation[1,1]
intercept <- r$center[2] - slope*r$center[1]
However, here I am not accounting for the varying measurement errors in $x$ and $y$. Is there any R package which I can use to account for the x.se
and y.se
vectors?