Hi folks, Probably a silly question for most of you, but I'm trying to switch to Mathematica for doing fits, linear and nonlinear. In working through the tutorials for LinearModelFit[ ], I cant get this to run:
data = Table[{3 + i + RandomReal[{-3, 7}], i + RandomReal[{-2, 5}]}, {i, 1, 20}];
model = LinearModelFit[data, x, x]
Show[ListPlot[data], Plot[model["BestFit"], {x, 0, 20}]]
The error is:
LinearModelFit::ivar: {0} is not a valid variable. >>
I guess that it has something to do with the initialization of the variable x ? ... I just copied the tutorial from the LinearModelFit page and tried to run it. Any help would be most appreciated, J.