# FindFormula can't deal with the population data from Wolfram server

Bug introduced in 10.2 and fixed in 10.3

In the documentation of FindFormula, the first application of it is to predict the population of Poland.

data = EntityValue[Entity["Country", "Poland"],
EntityProperty["Country",
"Population", {"Date" ->
Interval[{DateObject[{1950}], DateObject[{2015}]}]}]]
fit = FindFormula[data, x]


However, when I tried to run the code, it did not work and gave the following error:

FindFormula::wrgfmt: Argument {{QuantityMagnitude[Sun 1 Jan 1950 00:00:00GMT+8.],2.4824*10^7},{QuantityMagnitude[Mon 1 Jan 1951 00:00:00GMT+8.],2.52623*10^7},<<47>>,{QuantityMagnitude[Fri 1 Jan 1999 00:00:00GMT+8.],3.8336*10^7},<<16>>} at position 1 does not have the right format. Data should be a numerical array of depth less or equal than 2. >>

It seems that QuantityMagnitude cannot deal with that DateObject, but AbsoluteTime will do the job. My idea to fix this is to change some Mathematica code in FindFormula. I tried Information[FindFormula], but it returned a lot of private packages, and I don't know how to track down then. Is there any workaround to get FindFormula to work with these population data?

• Have you tried converting the dates into something like AbsoluteTime[] instead and fitting with that? Jul 27, 2015 at 4:37
• Yes, I noticed this too. The documentation says FindFormula is experimental. I guess that means "beta", and the docs are out of sync with the development. Many of the other FindFormula documentation examples don't give the same output that's shown in the documentation. Jul 27, 2015 at 7:20
• You might try fit = FindFormula[data // Normal, x]. I can't test this, I don't have V10.2 Jul 27, 2015 at 7:22
• @Szabolcs The differences when evaluating the examples are because FindFormula uses stochastic algorithms with randomized seeds. There is a "RandomSeed" option that should make the function give the same answers always, but it's currently not working properly. Jul 27, 2015 at 18:35
• As to the question posed: This is a bug in FindFormula in 10.2 which we are aware of. Jul 27, 2015 at 18:40

With J. M.'s idea, there is a temporary workaround to convert population data to lists and make it work with FindFormula. Assume data has been set like in the question.

data2 = Transpose[{(AbsoluteTime /@
List /@ Range[First@#[[1]], First@#[[2]],
First@#[[3]]]) &[#[[2]]], #[[1]]}] &[
Flatten[data[[2]][[1 ;; 2]], 1]];
FindFormula[data2, x]


For some unknown reasons, this result is not the same as that in the doc. And the plot in the doc will be modified to this

ListPlot[MapAt[QuantityMagnitude, #, 2] & /@ data2]