Difference between revisions of "Recipe/Theory/Statistics exploration"
Line 41: | Line 41: | ||
== Factor analysis == | == Factor analysis == | ||
− | It is unclear whether [https://en.wikipedia.org/wiki/Factor_analysis Factor analysis] is appropriate enough for the recipe problem | + | It is unclear whether [https://en.wikipedia.org/wiki/Factor_analysis Factor analysis] is appropriate enough for the recipe problem. |
One of the assumptions in Factor analysis is that there is a [https://en.wikipedia.org/wiki/Linear_combination linear combination] between the observed variables and the potential factors. This holds for the recipe problem, as the nutrients are clearly related to the ingredients used. | One of the assumptions in Factor analysis is that there is a [https://en.wikipedia.org/wiki/Linear_combination linear combination] between the observed variables and the potential factors. This holds for the recipe problem, as the nutrients are clearly related to the ingredients used. | ||
Line 61: | Line 61: | ||
The use of M here is worrisome, as it implies that one looks only at variations from the mean. The problem thus looks mainly at the variances. This is not comparable to a physical quantity like a nutrient. | The use of M here is worrisome, as it implies that one looks only at variations from the mean. The problem thus looks mainly at the variances. This is not comparable to a physical quantity like a nutrient. | ||
+ | |||
+ | == Errors-in-variables model == | ||
+ | An [https://en.wikipedia.org/wiki/Errors-in-variables_model errors-in-variables model] might be a better approach. This approach uses the fact that the observed variables and the latent variables are actual |
Revision as of 09:28, 22 January 2025
Finding the recipe of a product based on the list of ingredients and nutritional values, is a statistical problem of Linear regression for which a lot of theory exists. The recipe fitting problem is very specific and it is a bit difficult to find the right statistical approach in all the dense wikipedia pages.
Simple regression
We are not used to the terminology used in linear regression statistics, so some translation is needed:
- dependent variables / observed values (y) - these comparable to a nutrient of the product. Usually there are many values y observed (n dimensions);
- regressors / independent variable (x) - this is a nutrient in an ingredient. This independent variable kan have multiple dimensions p;
- regression coefficients (β) - the recipe fraction. In a general situation β can have p values for each observation (making a matrix);
- error term (ε) - the deviation from the fit for each observation;
This gives the relation:
(1) y = X β + ε
The recipe estimation is much simpler:
- there is only one product, so only 1 observed value, so n = 1;
- but also p = 1, as there is only one percentage per ingredient;
This simplifies the relation (1) to a simple multiplication for products with one nutrient. And in that case ε = 0.
Relation (1) could be extended with a term β0, which designates the intercept. In the recipe case this is 0, i.e. if there are no nutrients in the ingredient, then there are also nu nutrients in the product. In a mathematic approach it might be necessary to retain the β0 though.
Multivariate regression
Clearly we need a more complicated approach that supports multiple ingredients and multiple nutrients. The theory that corresponds to this is general multivariate regression. The corresponding formula is:
(2) Y = X B + U
In this formula
- Y is a matrix observations yij, with i an observation and j an aspect like a nutrient;
- X is the matrix of the nutrients for each ingredient;
- B the matrix of the recipe fractions for each obervation;
- U is a matrix containing the errors, which we will try to minimise;
As we have only one observation, (2) reverts to a simple matrix calculation. And now it corresponds to the formula we have originally. But the multivariate solutions should be used otherwise we cannot support multiple nutrients.
Latent variables
The data used for the recipe estimation is very strange from a statistical point of view: the nutrients of the product are only related to the nutrients of the ingredients through their name. In a linear regression approach we should measure the nutrients of the ingredients before we do the processing and then measure the nutrients of the product. Are there statistical models that support this?
This wikipedia page discusses the difference between latent and observable variables. This seems to fit the recipe problem very well. The observable variables are the nutrients of the product, whereas the latent variables are ingredients. The examples are mostly from social sciences, so it is hard to transpose the recipe problem onto a social science problem.
There are many models classes and methodologies to find and quantify the latent variables. Of all these theories Factor analysis seems most appropriate.
Factor analysis
It is unclear whether Factor analysis is appropriate enough for the recipe problem.
One of the assumptions in Factor analysis is that there is a linear combination between the observed variables and the potential factors. This holds for the recipe problem, as the nutrients are clearly related to the ingredients used.
Factor analysis uses a loading matrix, which relates the factors to the observations. In the recipe case this will be the supposed nutrients for each ingredient.
The statistical model for Factor analysis assumes that there are multiple observations, which is not the case for the recipe problem.
The formula used in factor analysis is:
(3) X - M = LF + ε
With:
- X the observed values;
- M the mean of the observed values;
- L the loading matrix
- F the factors
- ε the errors
The use of M here is worrisome, as it implies that one looks only at variations from the mean. The problem thus looks mainly at the variances. This is not comparable to a physical quantity like a nutrient.
Errors-in-variables model
An errors-in-variables model might be a better approach. This approach uses the fact that the observed variables and the latent variables are actual