<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, Determining an Equation's Accuracy</title>
    <link>http://www.mapleprimes.com/questions/40171-Determining-An-Equations-Accuracy</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Tue, 09 Jun 2026 06:36:50 GMT</lastBuildDate>
    <pubDate>Tue, 09 Jun 2026 06:36:50 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, Determining an Equation's Accuracy</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, Determining an Equation's Accuracy</title>
      <link>http://www.mapleprimes.com/questions/40171-Determining-An-Equations-Accuracy</link>
    </image>
    <item>
      <title>idea</title>
      <link>http://www.mapleprimes.com/questions/40171-Determining-An-Equations-Accuracy?ref=Feed:MaplePrimes:Determining an Equation's Accuracy:Comments#answer73896</link>
      <itunes:summary>It sounds to me as if you would like to compute the residuals and the sum of squares of the residuals, given a forced least-squares function (model).

You could of course compute the sums of squares of the residuals easily in Maple. Simply evaluate the model at each X value, and square the difference with the Y value, and add those up. That's probably one or two lines of Maple code. But you asked whether the Statistics routines could be used for the purpose, in a canned way.

You could specify a parameter that doesn't actually appear in your candidate model equation. And then use the solutionmodule output to get the extra details.

Here's an example, based on one from the ?Statistics,Fit help-page. Notice that the variable `dummy` doesn't appear in the model, which is the basis of the trick. The model equation is thus fully supplied by the user, with no parameters to actually be estimated (except some incidental estimation of the dummy, which is of no consequence).

&lt;pre&gt;
&gt; X := Vector([1, 2, 3, 4, 5, 6], datatype=float):
&gt; Y := Vector([2, 3, 4.8, 10.2, 15.6, 30.9], datatype=float):
&gt; Digits:=trunc(evalhf(Digits)):

&gt; # Here is the forced model.

&gt; eq:=0.887576142919275224+0.606352318207692531*exp(0.649251558313310717*t):

&gt; # Here are the simple commands to get the results,
&gt; # without using Statistics.

&gt; add( (eval(eq,t=X[i])-Y[i])^2, i=1..op(1,X) );

                               2.29446465108687
 
&gt; seq( (eval(eq,t=X[i])-Y[i]), i=1..op(1,X) );

0.04819978094862, 0.10913477921538, 0.33987862305974, -1.17305895930964,
 
    0.8671971243695, -0.1913514547231

&gt; # And here is Statistics:-Fit computing those results.

&gt; sol := Statistics:-Fit( eq, X, Y, t, parameternames=[dummy], output=solutionmodule):

&gt; sol:-Results(["residualsumofsquares","residuals"]);

2.29446465108658, [0.0481997809486180984, 0.109134779215386946,
 
    0.339878623059754581, -1.17305895930959636, 0.867197124369345929,
 
    -0.191351454723299952]
&lt;/pre&gt;

acer</itunes:summary>
      <description>It sounds to me as if you would like to compute the residuals and the sum of squares of the residuals, given a forced least-squares function (model).

You could of course compute the sums of squares of the residuals easily in Maple. Simply evaluate the model at each X value, and square the difference with the Y value, and add those up. That's probably one or two lines of Maple code. But you asked whether the Statistics routines could be used for the purpose, in a canned way.

You could specify a parameter that doesn't actually appear in your candidate model equation. And then use the solutionmodule output to get the extra details.

Here's an example, based on one from the ?Statistics,Fit help-page. Notice that the variable `dummy` doesn't appear in the model, which is the basis of the trick. The model equation is thus fully supplied by the user, with no parameters to actually be estimated (except some incidental estimation of the dummy, which is of no consequence).

&lt;pre&gt;
&gt; X := Vector([1, 2, 3, 4, 5, 6], datatype=float):
&gt; Y := Vector([2, 3, 4.8, 10.2, 15.6, 30.9], datatype=float):
&gt; Digits:=trunc(evalhf(Digits)):

&gt; # Here is the forced model.

&gt; eq:=0.887576142919275224+0.606352318207692531*exp(0.649251558313310717*t):

&gt; # Here are the simple commands to get the results,
&gt; # without using Statistics.

&gt; add( (eval(eq,t=X[i])-Y[i])^2, i=1..op(1,X) );

                               2.29446465108687
 
&gt; seq( (eval(eq,t=X[i])-Y[i]), i=1..op(1,X) );

0.04819978094862, 0.10913477921538, 0.33987862305974, -1.17305895930964,
 
    0.8671971243695, -0.1913514547231

&gt; # And here is Statistics:-Fit computing those results.

&gt; sol := Statistics:-Fit( eq, X, Y, t, parameternames=[dummy], output=solutionmodule):

&gt; sol:-Results(["residualsumofsquares","residuals"]);

2.29446465108658, [0.0481997809486180984, 0.109134779215386946,
 
    0.339878623059754581, -1.17305895930959636, 0.867197124369345929,
 
    -0.191351454723299952]
&lt;/pre&gt;

acer</description>
      <guid>73896</guid>
      <pubDate>Sun, 27 Jan 2008 11:33:41 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>residual mean square</title>
      <link>http://www.mapleprimes.com/questions/40171-Determining-An-Equations-Accuracy?ref=Feed:MaplePrimes:Determining an Equation's Accuracy:Comments#answer73894</link>
      <itunes:summary>I suggest using the residual sum of squares or the residual mean square. Further to acer's comment, the Statistics package has options to return these directly.  For example, if the function that you are fitting is &lt;maple&gt;a+b*t+c*t^2&lt;/maple&gt;, then try 

&lt;pre&gt;Statistics:-LinearFit([1,t,t^2], X, Y, t, output = 'residualmeansquare');&lt;/pre&gt;

For more information, see the Options section in &lt;code&gt;?LinearFit&lt;/code&gt;.</itunes:summary>
      <description>I suggest using the residual sum of squares or the residual mean square. Further to acer's comment, the Statistics package has options to return these directly.  For example, if the function that you are fitting is &lt;maple&gt;a+b*t+c*t^2&lt;/maple&gt;, then try 

&lt;pre&gt;Statistics:-LinearFit([1,t,t^2], X, Y, t, output = 'residualmeansquare');&lt;/pre&gt;

For more information, see the Options section in &lt;code&gt;?LinearFit&lt;/code&gt;.</description>
      <guid>73894</guid>
      <pubDate>Sun, 27 Jan 2008 18:29:28 Z</pubDate>
      <itunes:author>DJKeenan</itunes:author>
      <author>DJKeenan</author>
    </item>
    <item>
      <title>Question</title>
      <link>http://www.mapleprimes.com/questions/40171-Determining-An-Equations-Accuracy?ref=Feed:MaplePrimes:Determining an Equation's Accuracy:Comments#comment84345</link>
      <itunes:summary>Thank you so much for your help and time. I tried it and it worked. However, I don't quite understand everything that is going on here. As a matter of fact, I don't really understand anything that is going on here. I am only a high school student and have not taken Statistics. What does everything mean, and what is relevant for me to look at? All I know (or think I know) is that the closer an r^2 value is to one, the closer the equation is to fitting the points. Could you enlighten me?

Thank you for all your help already, and sorry for my ignorance.

Also, on a related but different topic, is it possible to define the X and Y values in one fell swoop? For example, I have them in a 8X2 Matrix, would it be possible to define X as one column of this Matrix and Y as another, instead of having to break up the Matrix into an X Vector and a Y Vector, as I am doing now?</itunes:summary>
      <description>Thank you so much for your help and time. I tried it and it worked. However, I don't quite understand everything that is going on here. As a matter of fact, I don't really understand anything that is going on here. I am only a high school student and have not taken Statistics. What does everything mean, and what is relevant for me to look at? All I know (or think I know) is that the closer an r^2 value is to one, the closer the equation is to fitting the points. Could you enlighten me?

Thank you for all your help already, and sorry for my ignorance.

Also, on a related but different topic, is it possible to define the X and Y values in one fell swoop? For example, I have them in a 8X2 Matrix, would it be possible to define X as one column of this Matrix and Y as another, instead of having to break up the Matrix into an X Vector and a Y Vector, as I am doing now?</description>
      <guid>84345</guid>
      <pubDate>Sun, 27 Jan 2008 11:59:05 Z</pubDate>
      <itunes:author>Evan</itunes:author>
      <author>Evan</author>
    </item>
    <item>
      <title>coefficient of determination</title>
      <link>http://www.mapleprimes.com/questions/40171-Determining-An-Equations-Accuracy?ref=Feed:MaplePrimes:Determining an Equation's Accuracy:Comments#comment92595</link>
      <itunes:summary>So, you may be interested in the so-called "coefficient of determination", or R^2.

See &lt;a href="http://en.wikipedia.org/wiki/Coefficient_of_determination"&gt;this link&lt;/a&gt; for details and explanations.

What I showed before is the residual sum of squares, which that page describes as its SS_err term. That pages also gives some formulae for R^2. Perhaps you would like to use the formula which computes R^2 via regression sum of squares.

If your X and Y data lie in the first and second columns of Matrix M, then in your code you can access the entries as M[i,1] instead of X[i] and M[i,2] instead of Y[i]. That saves your having to form the X and Y Vectors explicitly.

acer</itunes:summary>
      <description>So, you may be interested in the so-called "coefficient of determination", or R^2.

See &lt;a href="http://en.wikipedia.org/wiki/Coefficient_of_determination"&gt;this link&lt;/a&gt; for details and explanations.

What I showed before is the residual sum of squares, which that page describes as its SS_err term. That pages also gives some formulae for R^2. Perhaps you would like to use the formula which computes R^2 via regression sum of squares.

If your X and Y data lie in the first and second columns of Matrix M, then in your code you can access the entries as M[i,1] instead of X[i] and M[i,2] instead of Y[i]. That saves your having to form the X and Y Vectors explicitly.

acer</description>
      <guid>92595</guid>
      <pubDate>Sun, 27 Jan 2008 12:57:49 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>Is there any way to compute</title>
      <link>http://www.mapleprimes.com/questions/40171-Determining-An-Equations-Accuracy?ref=Feed:MaplePrimes:Determining an Equation's Accuracy:Comments#comment92597</link>
      <itunes:summary>Is there any way to compute the R^2 value directly in maple?

Or have it give me the SStot so I can calculate the R^2 value myself?

If not, what would be the syntax to calculate the SStot using my values from a Matrix? </itunes:summary>
      <description>Is there any way to compute the R^2 value directly in maple?

Or have it give me the SStot so I can calculate the R^2 value myself?

If not, what would be the syntax to calculate the SStot using my values from a Matrix? </description>
      <guid>92597</guid>
      <pubDate>Sun, 27 Jan 2008 23:59:57 Z</pubDate>
      <itunes:author>Evan</itunes:author>
      <author>Evan</author>
    </item>
    <item>
      <title>Maple implementation for R^2</title>
      <link>http://www.mapleprimes.com/questions/40171-Determining-An-Equations-Accuracy?ref=Feed:MaplePrimes:Determining an Equation's Accuracy:Comments#comment92611</link>
      <itunes:summary>The procedure Rsquared below could allow you to compute R^2 for data appearing in the first and second columns of a Matrix and for a given fitting formula in variable t.

&lt;pre&gt;
Rsquared := proc( formula, T::symbol,  m::Matrix )
local N, ybar, SS_err, SS_tot, SS_reg;
  Digits:=trunc(evalhf(Digits));
  N := op([1,1],m);
  ybar := add( m[i,2], i=1..N )/N;
  SS_tot := add( ( m[i,2] - ybar )^2, i=1..N );
  SS_reg := add( ( eval(formula,T=m[i,1]) - ybar )^2, i=1..N );
  SS_err := add( ( m[i,2] - eval(formula,T=m[i,1]) )^2, i=1..N );
  return 1-SS_err/SS_tot;
end proc:

M := Matrix(6,2, [[1,2],[2,3],[3,4.8],[5,10.2],[6,30.9]] );

form := 0.888 + 0.606*exp(0.649*t);

Rsquared( form, t, M );
&lt;/pre&gt;

You could fix it up to do proper argument checking and validation. Comments could be added to the code. Or you could just examine it and compare to the formulas on that web-page, and try and figure out a bit more of how the Maple programming language works.

acer</itunes:summary>
      <description>The procedure Rsquared below could allow you to compute R^2 for data appearing in the first and second columns of a Matrix and for a given fitting formula in variable t.

&lt;pre&gt;
Rsquared := proc( formula, T::symbol,  m::Matrix )
local N, ybar, SS_err, SS_tot, SS_reg;
  Digits:=trunc(evalhf(Digits));
  N := op([1,1],m);
  ybar := add( m[i,2], i=1..N )/N;
  SS_tot := add( ( m[i,2] - ybar )^2, i=1..N );
  SS_reg := add( ( eval(formula,T=m[i,1]) - ybar )^2, i=1..N );
  SS_err := add( ( m[i,2] - eval(formula,T=m[i,1]) )^2, i=1..N );
  return 1-SS_err/SS_tot;
end proc:

M := Matrix(6,2, [[1,2],[2,3],[3,4.8],[5,10.2],[6,30.9]] );

form := 0.888 + 0.606*exp(0.649*t);

Rsquared( form, t, M );
&lt;/pre&gt;

You could fix it up to do proper argument checking and validation. Comments could be added to the code. Or you could just examine it and compare to the formulas on that web-page, and try and figure out a bit more of how the Maple programming language works.

acer</description>
      <guid>92611</guid>
      <pubDate>Tue, 29 Jan 2008 02:52:07 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
  </channel>
</rss>