commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Italo Maia <italom...@hotmail.com>
Subject RE: [math]
Date Fri, 06 Jul 2012 22:45:40 GMT

Had this to calculate the rsquared:

OLSMultipleLinearRegression regression = new OLSMultipleLinearRegression();
regression.newSampleData(curve_totals, data);
System.out.println("rsquared:" + regression.calculateRSquared());

Where curve_totals is the value calculated with Fnc.fnc and the calculated a, b and c.

Used this as reference: http://commons.apache.org/math/userguide/stat.html

Is that right? 

By the way, there is a typo in the link: double rSquared = regression.caclulateRSquared();

Where could I report it?


> Date: Sat, 7 Jul 2012 00:29:51 +0200
> From: gilles@harfang.homelinux.org
> To: user@commons.apache.org
> Subject: Re: [math]
> 
> On Fri, Jul 06, 2012 at 09:39:30PM +0000, Italo Maia wrote:
> > 
> > Hummm, so my assumption that my previous values for a, b and c were the best are
wrong. I calculated the resid and it is really smaller. Real thanks for that!
> 
> I wouldn't take the difference too seriously, given that the data are not
> really close to the curve. The errors seem quite large.
> 
> > Any tips on calculating the r-squared?
> 
> No.
> 
> Gilles
> 
> > 
> > Date: Fri, 6 Jul 2012 22:05:26 +0200
> > From: gilles@harfang.homelinux.org
> > To: user@commons.apache.org
> > Subject: Re: [math]
> > 
> > Hi.
> >  
> > If you are using the function
> >  
> >   a * Math.pow(t, b) * Math.exp(-c * t)
> >  
> > the gradient is:
> >  
> >   { Math.pow(t, b) * Math.exp(-c * t),
> >     a * Math.log(t) * Math.pow(t, b) * Math.exp(-c * t),
> >     -a * t  Math.pow(t, b) * Math.exp(-c * t) }
> >  
> > > // No idea what goes here. Nothing seems to work.
> >  
> > Well, the gradient (partial derivatives w.r.t the parameters) is the thing
> > that will work; the attached figure shows the data and the function that
> > fits it with
> >  a = 1.097378664278161
> >  b = 0.4273818336149512
> >  c = 0.01457006142420487
> >  
> > > 
> > > a, b and c for this example should be: A: 1.0782   B: 0.4583   C: 0.0166
> >  
> > The fit is slightly better with the values found by "CurveFitter"
> > (the "LevenbergMarquardt" algorithm actually).
> >  
> > Regards,
> > Gilles
> >  
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> > For additional commands, e-mail: user-help@commons.apache.org 		 	   		  
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
 		 	   		  
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message