Port a line of code from earlier version of Mathematica to version 8
I have a an old line of code from Mathematica version 6 or 7 that I need to port to Mathematica 8.
I don't have a working version of 6 or 7 so I can't run the original code to do a side by side test to see if I get the same results. I thought someone here might know just from looking at the code.
Earlier version:
Regress[data, x, x, RegressionReport -> {FitResiduals}][[1]][[2]]
I've tried the following in version 8:
LinearModelFit[data, x, x]["FitResiduals"]
I have no way to tell if the new code will give me either the output and/or the format of开发者_如何学JAVA the output of the earlier version.
Any help appreciated.
Thanks to all for making this such a great resource!
J.
Yes, the output of this code from Version 6:
FitResiduals /. Regress[data, x, x, RegressionReport -> {FitResiduals}]
... is indeed equivalent to this code from Version 8:
LinearModelFit[data, x, x]["FitResiduals"]
... for the sets of random reals I tried. The difference between the two results is effectively zero:
In[26]:= fromV6 == fromV8
Out[26]= True
In[27]:= fromV6 - fromV8
Out[27]= {0., 1.11022*10^-16, 0., 0., 1.11022*10^-16}
Regress
returns a list of rules, and the [[1]][[2]]
business extracts the RHS of the first rule. The method I used above (FitResiduals /. Regress[...]
) is a better way to do that.
HTH!
According to the upgrade tutorial for the old statistics module, Regress
was last seen in version 6. Based on the fact that "FitResiduals" is not in the list of renamed properties at the bottom of the page, I would say that the output of your new version should be pretty close to the old version.
If you want somebody to test for you, I would suggest putting up a small working dataset and post the output from the new code -- then somebody will probably post the output from v5 or v6. The documentation for the old module is here.
HTH
精彩评论