# Errors-in-variables multivariate polynomial regression (R)

(EDIT: the question has been modified just a little bit to be more specific)

I want to fit a multivariate polynomial regression that accounts for measurement errors (an Error-in-Variables model).

As an example, my input data is like:

y      sd_y      x       sd_x       z       sd_z

9.55   0.26     6.74     0.71      0.25     0.02
8.31   0.19     5.93     0.33      -0.40    0.05
...    ...      ...      ...        ...     ...


where sd_y, sd_x, sd_z are the standard deviations of each variable, and

 wx <- 1/(sd_x)**2 ; wy <- 1/(sd_y)**2 ; wz <- 1/(sd_z)**2


would be the weights for each variable.

If I use a standard regression model (where predictors are supposed to have been measured exactly or without error) my function or fit, in R, would be:

p <- lm(y~polym(x, z, degree = 2, raw=TRUE))


Is there a method/package in R that allows to deal with "error-in-variables models"? If so, how I would write my fit p when using the supposed package?

• Your question is not entirely clear. How would these weights work exactly? What is the function being optimized? – Glen_b Jun 30 '15 at 9:37
• I want to obtain the fit I called p, this is my function to optimise. I've just added the kind of weights would like to take into account when looking for the best fit (wx, wy, wz). I want my polynomial to be fitted giving more or less importance (weights) to each observation depending on its weight (since the input it's observational data, I think it's logical to have these standard deviations into account). – LRD Jun 30 '15 at 9:54
• An observation is a point in $\mathbb{R}^3$, $(x,z,y)$. A single point should have one weight. How are you combining the weights? Further, note that if $x$ and $z$ are random (the values have non-zero standard deviations) then lm is the wrong tool for fitting a relationship with $y$; least squares regression assumes they're fixed, not random. e.g. see here – Glen_b Jun 30 '15 at 9:59
• ok, I see the point about the least squares regression and the errors-in-variables models. Thanks for the link, it really helped me to learn more about that. So, is there any package or method in R which allows to deal with this "error-in-variables models" problem? I've read things about ODRpack or leiv, but I'm not sure of their usage. Are they applicable to my multivariate problem? If you have knowledge about that, maybe an example will help me a lot, thanks – LRD Jun 30 '15 at 12:44
• Such an answer wouldn't really respond to your present question. – Glen_b Jun 30 '15 at 16:11