6
$\begingroup$

Background

Errors-in-variables models are defined as:

regression models that account for measurement errors in the independent variables. In contrast, standard regression models assume that those regressors have been measured exactly, or observed without error; as such, those models account only for errors in the dependent variables, or responses.

Whether data is experimental or computational (e.g. via physics-based simulation), uncertainty in the independent variables is common. This is particularly relevant in materials science where uncertainty exists in the processing, structure, and property measurements. Additionally, this uncertainty is not necessarily constant for all parameters (a temperature sensor might have higher uncertainty at the limits of the temperature range, various aspects of a material's structure may have been determined by separate instruments, property measurements are data-mined from several sources, etc.). See also Uncertainty Quantification. I'm sure this is relevant for other disciplines too (e.g. physics, chemistry, biology, engineering).

Existing Methods

What I'm not looking for

What I am looking for

A method that caters to multidimensional, non-parametric regression with propagated measurement uncertainty in predictors and responses (i.e. uncertainty propagation, not just weighting the points) and preferably software that goes along with it (Mathematica, MATLAB, Python, R, Stan, etc.). Multidimensional refers to the predictors (i.e. responses are scalar).

Ideally, it would be something that is explained and can be performed via:

mdl = some_function(X, Xsd, y, ysd)
ypred, ysd2, cov = mdl(X2, Xsd2)

Inputs

  1. Matrix/Array of predictors (X $X$)
  2. Matrix/Array of predictor uncertainties (Xsd $\sigma_X$)
  3. Vector of response values (y $y$)
  4. Vector of response uncertainties (ysd $\sigma$)
  5. Matrix/Array of new predictors (X2 $X_2$)
  6. (Optional) Matrix/Array of new predictor uncertainties (Xsd2 $\sigma_{X2}$)

Outputs

  1. Vector of new responses (ypred $y_{pred}$)
  2. Vector of new response uncertainties (ysd2 $\sigma_2$)
  3. (Optional) predictor covariance matrix (cov $\Sigma_2$)
Assume uncertainty means standard deviation of a normal distribution. I'm fine with starting out with simpler assumptions before moving onto e.g. other distributions.

Updates

Related

$\endgroup$
15
  • 1
    $\begingroup$ Questions that are only about software (e.g. error messages, code or packages, etc.) are generally off topic here. If you have a substantive machine learning or statistical question, please edit to clarify. $\endgroup$ Mar 29, 2021 at 17:34
  • 2
    $\begingroup$ @gung-ReinstateMonica I've updated the question to focus on the method rather than solely on a software implementation. Thanks for pointing out. $\endgroup$
    – Sterling
    Mar 29, 2021 at 18:20
  • 1
    $\begingroup$ Ok, great. Thanks for the patience. Interesting, I hadn't heard of sem before. I'll look into it! $\endgroup$
    – Sterling
    Mar 29, 2021 at 18:32
  • 1
    $\begingroup$ In addition to Bayesian modeling which would be a very flexible option, the closest to a canned solution is the SIMEX algorithm (sci-hub.se/10.1080%2F01621459.1994.10476871) implemented in the simex package in R (cran.r-project.org/web/packages/simex/index.html). More broadly, the book you want to start with is: drcarroll.wpengine.com/eiv.SecondEdition. SEM is unlikely to help here, it is useful with multiple uncertain measures of an unknown predictor, e.g. unknown predictor A w/ multiple measures A1, A2, A3, ... unknown predictor B w/ multiple measures B1, B2, B3, ... $\endgroup$ Mar 29, 2021 at 18:53
  • 1
    $\begingroup$ I disagree w/ @HeteroskedasticJim, SEM is very much not limited to estimating latent variables measured by manifest variables, although that is one of the most common applications. Setting that aside, the Wikipedia page notes that, "Usually measurement error models are described using the latent variables approach". $\endgroup$ Mar 29, 2021 at 19:44

1 Answer 1

9
+100
$\begingroup$

One of the more interesting choices in R is rstan, where you could code this up yourself in the Stan modeling language (which tends to be amazing in that it can produce inference for models that we used to be unable to do for a long time). However, getting started can be a little challenging and it sounds like you'd like a higher level interface.

That could be the brms package, that uses the R model syntax and in the background generates Stan code. Via that detour (generate the Stan code via brms in R and then use the generated Stan code with pystan - or any of the other Stan-tie-ins in other languages such as MathematicaStan or MatlabStan - you can then also use it in Stan). In brms there's the me() function for predictors with measurement errors and a quite nice range of modeling options for non-linear models (it depends a bit of what exactly you are thinking about whether that's covered) and it also supports Gaussian processes, but I'm not sure from what you described to what extent you can fit it all together the way you want (if not you may be best off looking at the - usually quite well-chosen / efficient - Stan code that brms generates and having to fit it together exactly the way you want manually in Stan).

$\endgroup$
5
  • 2
    $\begingroup$ Nice, I think I had come across Stan before but didn't realize it might have a straightforward implementation for this problem. A relevant section from docs seems to be Measurement Error and Meta-Analysis which gives an example for linear regression. $\endgroup$
    – Sterling
    Mar 26, 2021 at 22:27
  • $\begingroup$ I agree that it's not obvious how hard it would be to fit everything together in Stan. Something a bit closer than the linear regression tutorial is Predator-Prey Population Dynamics: the Lotka-Volterra model in Stan from Stan Case Studies which uses parametric differential equations and incorporates measurement error. $\endgroup$
    – Sterling
    Mar 26, 2021 at 22:36
  • $\begingroup$ I'd try brms first, if that does not get you there, then going to coding a model up yourself in Stan is a serious option, but especially when things get complicated, it can take some time (e.g. finding the right parameterization can be quite important). $\endgroup$
    – Björn
    Mar 26, 2021 at 22:41
  • $\begingroup$ I have no practical experience with R (lots with MATLAB/Mathematica, some with Python), so it's been a bit rough. I posted on the stan discourse page. Giving it a shot though $\endgroup$
    – Sterling
    Mar 27, 2021 at 9:25
  • $\begingroup$ Unfortunately, still haven't quite gotten this to work.. $\endgroup$
    – Sterling
    May 12, 2021 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.