DMUG-Archiv 2008

Frühere   Chronologischer Index   Spätere
Vorherige   Thematischer Index   Nächste

Re[3]: RSquared in NonlinearRegress

Hallo Christian,

man kann Ihre Aufgabe problemlos mit Fit oder mit Regress
(das ist Fit mit Diagnostik) lösen und bekommt RSquared:

In[3]:= Fit[data, {1, y, y^2, x, x y, x y^2, x^2, x^2 y, x^2 y^2,
  x^3, x^3 y, x^3 y^2}, {x, y}]

Out[3]= -7.69632 + 43.5567 x - 76.0286 x^2 + 43.4198 x^3 +
 14.2256 y - 75.481 x y + 131.096 x^2 y - 74.9574 x^3 y -
 5.36262 y^2 + 28.3483 x y^2 - 49.208 x^2 y^2 + 28.179 x^3 y^2

In[6]:= Needs["LinearRegression`"];
Regress[data, {1, y, y^2, x, x y, x y^2, x^2, x^2 y, x^2 y^2, x^3,
  x^3 y, x^3 y^2}, {x, y},
 RegressionReport -> {BestFit, RSquared}]

Out[7]= {BestFit -> -7.69632 + 43.5567 x - 76.0286 x^2 +
   43.4198 x^3 + 14.2256 y - 75.481 x y + 131.096 x^2 y -
   74.9574 x^3 y - 5.36262 y^2 + 28.3483 x y^2 - 49.208 x^2 y^2 +
   28.179 x^3 y^2, RSquared -> 0.857626}

Die Lösung liefert dieselben Parameter wie NonlinearRegress[] (welches,
wenn es clever ist, bei einem linearen Ansatz auf Fit zurückschalten wird :-))

Gibt es einen Grund dafuer, dass RSquared in NonlinearRegress nicht zu Verfuehgung steht? Ich haette gedacht, dass dieses einer der standard Werte ist um die Qualitaet des Fits abzuschaetzen!

Es steht geschrieben:

Fit[data, funs, vars] finds a least-squares fit to
a list of data as a linear combination of the functions funs of variables vars.

NonlinearRegress[data, expr, pars, vars] finds numerical values
of the parameters pars that make the model
expr give a best fit to data as a function of vars and provides
diagnostics for the fitting.

Der Unterschied ist, dass Fit[] eine Linearkombination der Basisfunktionen
anfittet, (deshalb kann man in Fit[] die zu fittenden Koeffizienten oder
Parameter nicht benennen), während NonlinearRegress[] einen allgemeinen, vom Nutzer gegebenen Ausdruck anfittet, von dem der Nutzer sagen muss, welches die
Parameter sind und welches die Variablen sind:

NonlinearRegress[data2, (theta1 theta3 x1)/(
 1 + theta1 x1 + theta2 x2), {theta1, theta2, theta3}, {x1, x2}]

In Falle eines solchen allgemeineren Modells sind auch die
Qualitätsmerkmale komplexer und es steht weiter geschrieben:

ANOVATable provides a partitioning of the sum of squares. Both the
uncorrected total sum of squares (without intercept term) and the
corrected total sum of squares (with intercept term) are included.
The corrected total sum of squares is useful for calculating a
value for R^2 comparable to that produced by Regress, so that
the fit of a nonlinear model can be compared to the fit of a linear
model. For example, one possible definition of R^2 for a nonlinear
regression is the ratio of the difference between the corrected
total sum of squares and the residual sum of squares to the corrected
total sum of squares. The other objects in this table have meanings
similar to those of analogous RegressionReport values for the linear
regression function Regress.

Da wäre sogar ein Vorschlag, wie man RSquared (R^2) für NonlinearRegress[]
definieren kann - aber es besteht kein Grund, bei dem von Ihnen
gewählten Modell NonlinearRegress[] aufzurufen.

Gruss
Udo.








Antworten:
Verweise:
Frühere   Chronologischer Index   Spätere
Vorherige   Thematischer Index   Nächste

DMUG DMUG-Archiv, http://www.mathematica.ch/archiv.html