problem with fitting data using lsquares




On Mon, 14 Jun 2010, Hugo Coolens wrote:

< Thank you for this useful suggestion Robert, I tried it out, unfortunately a
< problem with Gnuplot now pops up:
< This is my input:
< m:matrix([100,16000],[200,8000],[500,3636],[1000,1818],[2000,870],[5000,323],[10000,160],[20000,83],[50000,33],[100000,20]);
< lsquares_estimates (m, [x, y], y = sqrt(a^2 + (10e7/(2*%pi*x*b))^2),[a, b],
< initial=[10, 10]);
< /* => [[a = 19.2898942613692, b = 9.89381119455951]]*/
< /* b = 10 is the exact value for b.*/
< /* I'll construct the mean square error as a function of a alone*/
< /* and then plot it. */
< mse : lsquares_mse (m, [x, y], y = sqrt(a^2 + (10e7/(2*%pi*x*b))^2));
< mse1 (a) := ''(subst (b=10, mse));
< plot2d (mse1, [a, 0, 100]);

Try:

plot2d(mse1(a), [a,0,100]);

since plot2d expects an expression and not a function.

Leo

< This is the error message:
< gnuplot> plot [0.:100.]'/home/coolens/maxout.gnuplot_pipes' index 0 notitle
< with lines 3
< 
< ^
<          line 0: warning: Skipping data file with no valid points
< 
< gnuplot> plot [0.:100.]'/home/coolens/maxout.gnuplot_pipes' index 0 notitle
< with lines 3
< 
< ^
<          line 0: all points y value undefined!
< 
< I'm using using Gnuplot 4.5 patchlevel 0 and Maxima 5.13.0 on a Debian Lenny
< system
< 
< Any idea how to modify the input-file to make Gnuplot do what it should do?
< 
< hugo
< 
< 
< On Mon, 14 Jun 2010, Robert Dodier wrote:
< 
< > On 6/13/10, Hugo Coolens <coolens at kahosl.be> wrote:
< > 
< > > m:matrix([100,16000],[200,8000],[500,3636],[1000,1818],[2000,870],[5000,323],[10000,160],[20000,83],[50000,33],[100000,20]);
< > 
< > With these data (the last one has been corrected, right?)
< > and the original model I get the following.
< > 
< > lsquares_estimates (m, [x, y], y = sqrt(a^2 + (10e7/(2*%pi*x*b))^2),
< > [a, b], initial=[10, 10]);
< > => [[a = 19.2898942613692, b = 9.89381119455951]]
< > 
< > I gather that b = 10 is the exact value for b. (If that's not so,
< > just substitute the correct value in the following.)
< > I'll construct the mean square error as a function of a alone
< > and then plot it.
< > 
< > mse : lsquares_mse (m, [x, y], y = sqrt(a^2 + (10e7/(2*%pi*x*b))^2));
< > mse1 (a) := ''(subst (b=10, mse));
< > plot2d (mse1, [a, 0, 100]);
< > 
< > In the plot there is a very shallow minimum around a = 20.
< > So at this point I have two observations; one is that a is not very
< > strongly determined by the available data (since the MSE is almost
< > the same for a wide range of a values), and anyway the lsquares
< > estimates can't be too far off the mark (in the neighborhood of a = 20).
< > 
< > You might try to make a contour plot of MSE as a function
< > of both a and b.
< > 
< > Hope this helps in some way.
< > 
< > Robert Dodier
< > 
< _______________________________________________
< Maxima mailing list
< Maxima at math.utexas.edu
< http://www.math.utexas.edu/mailman/listinfo/maxima
< 
< 

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.