Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

I'm curious about repeatable procedures that can be used to discover the functional form of the function y = f(A, B, C) + error_term where my only input is a set of observations (y, A, B and C). Please note that the functional form of fis unknown.

Consider the following dataset:

AA  BB  CC  DD  EE  FF
==  ==  ==  ==  ==  ==
98  11  66  84  67  10500
71  44  48  12  47  7250
54  28  90  73  95  5463
34  95  15  45  75  2581
56  37  0   79  43  3221
68  79  1   65  9   4721
53  2   90  10  18  3095
38  75  41  97  40  4558
29  99  46  28  96  5336
22  63  27  43  4   2196
4   5   89  78  39  492
10  28  39  59  64  1178
11  59  56  25  5   3418
10  4   79  98  24  431
86  36  84  14  67  10526
80  46  29  96  7   7793
67  71  12  43  3   5411
14  63  2   9   52  368
99  62  56  81  26  13334
56  4   72  65  33  3495
51  40  62  11  52  5178
29  77  80  2   54  7001
42  32  4   17  72  1926
44  45  30  25  5   3360
6   3   65  16  87  288

In this example, assume that we know that FF = f(AA, BB, CC, DD, EE) + error term, but we're not sure about the functional form of f(...).

What procedure/what methods would you use to arrive at finding the functional form of f(...)?

(Bonus point: What is your best guess at the definiton of f given the data above? :-) And yes, there is a "correct" answer that will yield an R^2 in excess of 0.99.)

share|improve this question
@OP: IrishStat's comments below remind me that without some knowledge of how your independent variables are related to each other and/or the dependent variable, in theory, leaves you "up the creek without a paddle". For example, if FF was "combustion yield" and AA was amount of fuel, and BB was the amount of oxygen, you would look for an interacting term of AA and BB – Pete May 6 '11 at 1:47
@Pete: Interacting terms are absolutely possible. I hope I didn't rule out that by framing my question incorrectly. – knorv May 6 '11 at 16:39
1  
@Pete: This is no problem (and I would even call it realistic in a real life setting), just see my answer below. – vonjd May 9 '11 at 19:02
2  
Pete: Out of the infinite number of functions that will fit the data with R^2 >= 0.99 one would like to find the one with the best performance to complexity ratio (and out of sample fit of course). Sorry for not writing that explicity, I thought that was obvious :-) – knorv May 10 '11 at 8:12
1  
@knorv: So could you just accept the best answer? Or did nobody make it? Thank you. – vonjd Jan 18 at 15:23
show 2 more comments

6 Answers

To find the best fitting functional form (so called free-form or symbolic regression) for the data try this tool - to all of my knowledge this is the best one available (at least I am very excited about it)...and its free :-)

http://creativemachines.cornell.edu/eureqa

EDIT: I gave it a shot with Eureqa and I would go for:

$$AA + AA^2 + BB*CC$$ with $R^2=0.99988$

I would call it a perfect fit (Eureqa gives other, better fitting solutions, but these are also a little bit more complicated. Eureqa favours this one, so I chose this one) - and Eureqa did everything for me in about a few seconds on a normal laptop ;-)

share|improve this answer
just for reference, Eureqa's using Genetic Programming to find solutions to the symbolic regression problem. – Thies Heidecke May 8 '11 at 7:47
4  
+1 Impressive performance for a mindless, automatic tool! – whuber May 9 '11 at 22:08

$R^2$ alone is not a good measure of goodness of fit, but let's not get into that here except to observe that parsimony is valued in modeling.

To that end, note that standard techniques of EDA and regression (but not stepwise or other automated procedures) suggest using a linear model in the form

$$\sqrt{f} = a + b*c + a*b*c + \text{constant} + \text{error}$$

Using OLS, this does achieve an $R^2$ above 0.99. Heartened by such a result, one is tempted to square both sides and regress $f$ on $a$, $b*c$, $a*b*c$, and all their squares and products. This immediately produces a model

$$f = a^2 + b*c + \text{constant} + \text{error}$$

with a root MSE of under 34 and an adjusted $R^2$ of 0.9999. The estimated coefficients of 1.0112 and 0.988 suggest the data may be artificially generated with the formula

$$f = a^2 + b*c + 50$$

plus a little normally distributed error of SD approximately equal to 50.

Edit

In response to @knorv's hints, I continued the analysis. To do so I used the techniques that had been successful so far, beginning with inspecting scatterplot matrices of the residuals against the original variables. Sure enough, there was a clear indication of correlation between $a$ and the residuals (even though OLS regression of $f$ against $a$, $a^2$, and $b*c$ did not indicate $a$ was "significant"). Continuing in this vein I explored all correlations between the quadratic terms $a^2, \ldots, e^2, a*b, a*c, \ldots, d*e$ and the new residuals and found a tiny but highly significant relationship with $b^2$. "Highly significant" means that all this snooping involved looking at some 20 different variables, so my criterion for significance on this fishing expedition was approximately 0.05/20 = 0.0025: anything less stringent could easily be an artifact of the probing for fits.

This has something of the flavor of a physical model in that we expect, and therefore search for, relationships with "interesting" and "simple" coefficients. So, for instance, seeing that the estimated coefficient of $b^2$ was -0.0092 (between -0.005 and -0.013 with 95% confidence), I elected to use -1/100 for it. If this were some other dataset, such as observations of a social or political system, I would make no such changes but just use the OLS estimates as-is.

Anyway, an improved fit is given by

$$f = a + a^2 + b*c - b^2/100 + 30.5 + \text{error}$$

with mean residual $0$, standard deviation 26.8, all residuals between -50 and +43, and no evidence of non-normality (although with such a small dataset the errors could even be uniformly distributed and one couldn't really tell the difference). The reduction in residual standard deviation from around 50 to around 25 would often be expressed as "explaining 75% of the residual variance."


I make no claim that this is the formula used to generate the data. The residuals are large enough to allow some fairly large changes in a few of the coefficients. For instance, 95% CIs for the coefficients of $a$, $b^2$, and the constant are [-0.4, 2.7], [-0.013, -0.003], and [-7, 61] respectively. The point is that if any random error has actually been introduced in the data-generation procedure (and that is true of all real-world data), that would preclude definitive identification of the coefficients (and even of all the variables that might be involved). That's not a limitation of statistical methods: it's just a mathematical fact.

BTW, using robust regression I can fit the model

$$f = 1.0103 a^2 + 0.99493 b*c - 0.007 b^2 + 46.78 + \text{error}$$

with residual SD of 27.4 and all residuals between -51 and +47: essentially as good as the previous fit but with one less variable. It is more parsimonious in that sense, but less parsimonious in the sense that I haven't rounded the coefficients to "nice" values. Nevertheless, this is the form I would usually favor in a regression analysis absent any rigorous theories about what kinds of values the coefficients ought to have and which variables ought to be included.

It is likely that additional strong relationships are lurking here, but they would have to be fairly complicated. Incidentally, taking data whose original SD is 3410 and reducing their variation to residual with an SD of 27 is a 99.99384% reduction (the $R^2$ of this new fit). One would continue looking for additional effects only if the residual SD is too large for the intended purpose. In the absence of any purpose besides second-guessing the OP, it's time to stop.

share|improve this answer
Good work! So far this seems like the best answer. – Zach May 9 '11 at 1:06
@whuber: Nice work -- you're getting close! :-) It is true that the data was artifically generated with a formula plus an error term. But the formula is not exactly the one you've found - you're missing out on a couple of terms. But you're close and you're currently in the lead :-) – knorv May 9 '11 at 9:46
Clarification: you're missing out on a couple of terms should have been "you're missing out on more than one term". – knorv May 9 '11 at 9:53
@knorv You're right; one can do better. – whuber May 9 '11 at 14:13
2  
@whuber I already gave my +1, but I'd like to add that this is very instructive to read one's approach to such a problem. You're worth the bounty in any manner whatsoever. – chl May 9 '11 at 20:52
show 2 more comments

Your question needs refining because the function f is almost certainly not uniquely defined by the sample data. There are many different functions which could generate the same data.

That being said, Analysis of Variance (ANOVA) or a "sensitivity study" can tell you a lot about how your inputs (AA..EE) affect your output (FF).

I just did a quick ANOVA and found a reasonably good model: FF = 101*A + 47*B + 49*C - 4484. The function does not seem to depend on DD or EE linearly. Of course, we could go further with the model and add quadratic and mixture terms. Eventually you will have a perfect model that over-fits the data and has no predictive value. :)

share|improve this answer
@Pete As you said you could add quadratic,cubic,quartic ....and mixture terms but that would just be just nonsense. There is nonsense and there is non-sensical nonsense bot the most non-sensicle nonsense is "statistical nonsense ". – IrishStat May 5 '11 at 20:59
1  
@IrishStat it is not generally nonsense to add mixture and higher order terms; only bad when it is done without restraint and without regard to theory – Pete May 5 '11 at 23:07
1  
@Pete . Correct! The absence of a pre-existing theory makes it silly. – IrishStat May 6 '11 at 0:32
@Pete: What R^2 do you get for your model? – knorv May 6 '11 at 10:08
@knorv: I don't quite remember but it was > 0.90. When plotted about the regression line the points appeared to have a little bit of an "S"/cubic shape so I'm guessing the function "f" was a mathematical creation where someone typed 100A + 50(B+C) + higher order terms involving D & E. – Pete May 6 '11 at 12:39
show 1 more comment

Broadly speaking, there's no free lunch in machine learning:

In particular, if algorithm A outperforms algorithm B on some cost functions, then loosely speaking there must exist exactly as many other functions where B outperforms A

/edit: also, a radial SVM with C = 4 and sigma = 0.206 easily yields an R2 of .99. Extracting the actual equation used to derive this dataset is left as an exercise to the class. Code is in R.

setwd("~/wherever")
library('caret')
Data <- read.csv("CV.csv", header=TRUE)
FL <- as.formula("FF ~ AA+BB+CC+DD+EE")
model <- train(FL,data=Data,method='svmRadial',tuneGrid = expand.grid(.C=4,.sigma=0.206))
R2( predict(model, Data), Data$FF)
share|improve this answer

All Models are wrong but some are useful : G.E.P.Box

Y(T)= - 4709.7
+ 102.60*AA(T)- 17.0707*AA(T-1)
+ 62.4994*BB(T) + 41.7453*CC(T) + 965.70*ZZ(T)

where ZZ(T)=0 FOR T=1,10 =1 OTHERWISE

There appears to be a "lagged relationship" between Y and AA AND an explained shift in the mean for observations 11-25 .

Curious results if this is not chronological or spatial data.

share|improve this answer
@IrishStats What is "G.E.P. Box"? – knorv May 6 '11 at 9:40
IrishStat: The data is not chronological. So the ordering of the observations is not of importance. The shift in the mean for observations #11-25 is merely a side-effect on how I retrieved the dataset. – knorv May 6 '11 at 10:07
@knorv en.wikipedia.org/wiki/George_E._P._Box is a statistician/chemist who influenced many to study time series. He was one of my instructors in the subject. – IrishStat May 6 '11 at 10:34
@knorv: a side-effect ? Very interesting ! I can't wait to find out more about this. – IrishStat May 6 '11 at 10:36
@IrishStat: I meant that I just happened to retrieve the records in a certain order (think ORDER BY). The rows have no inherent special order. So you can safely re-arrange them without losing any information. Sorry if I confused you :-) – knorv May 6 '11 at 16:35
show 1 more comment

r square of 97.2

Estimation/Diagnostic Checking for Variable Y Y
X1 AAS
X2 BB
X3 BBS
X4 CC

Number of Residuals (R) =n 25
Number of Degrees of Freedom =n-m 20
Residual Mean =Sum R / n -.141873E-05
Sum of Squares =Sum R**2 .775723E+07
Variance =SOS/(n) 310289.
Adjusted Variance =SOS/(n-m) 387861.
Standard Deviation RMSE =SQRT(Adj Var) 622.785
Standard Error of the Mean =Standard Dev/ (n-m) 139.259
Mean / its Standard Error =Mean/SEM -.101877E-07
Mean Absolute Deviation =Sum(ABS(R))/n 455.684
AIC Value ( Uses var ) =nln +2m 326.131
SBC Value ( Uses var ) =nln +m*lnn 332.226
BIC Value ( Uses var ) =see Wei p153 340.388
R Square = .972211
Durbin-Watson Statistic =[-A(T-1)]*2/A*2 1.76580

**
MODEL COMPONENT LAG COEFF STANDARD P T
# (BOP) ERROR VALUE VALUE

1CONSTANT                         -.381E+04   466.       .0000    -8.18

INPUT SERIES X1 AAS AA SQUARED

2Omega (input) -Factor #  1    0   .983       .410E-01   .0000    23.98

INPUT SERIES X2 BB BB AS GIVEN

3Omega (input) -Factor #  2    0   108.       14.9       .0000     7.27

INPUT SERIES X3 BBS BB SQUARED

4Omega (input) -Factor #  3    0  -.577       .147       .0008    -3.93

INPUT SERIES X4 CC CC AS GIVEN

5Omega (input) -Factor #  4    0   49.9       4.67       .0000    10.67

 Residual PLOT

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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