You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Piotr Kochański <pi...@uw.edu.pl> on 2004/01/27 22:57:13 UTC
[math] Re: - Multiple Linear Regression
Inger, Matthew napisa�(a):
> returning a RealMatrix for the coefficients doesn't make sense
> to me, since a matrix implies N x M dimensions, and the coefficient
> matrix has a fixed number of rows (1). I'd rather return an double[]
> instance. However, that array is available through LinearFunction
> as i have outlined it below, so it's not really hard to get to it:
>
> results.getFuntion().getCoefficients();
This way of obtaining coefficients might be natural and elegant
for a Java programmer, but I think that average statistician would
prefere to get them in a simpler way, without digging through
interfaces, methods, etc. just to find such a basic result.
As I understand rationale behind returning RealMatrix is that
there is a number of usefull methods that makes manipulation
with the result easier, but I would not complain if I get double[],
I would not have to think about some additional interface (RealMatrix).
In addition double[] can be easily converted to RealMatrix if it is needed.
Piotr
>
> -----Original Message-----
> From: Phil Steitz [mailto:steitzp@yahoo.com]
> Sent: Monday, January 26, 2004 4:59 PM
> To: Jakarta Commons Developers List
> Subject: RE: [math] - Multiple Linear Regression
>
>
> --- "Inger, Matthew" <in...@Synygy.com> wrote:
> > Is there any plan to possibly have a MultivariateRealFunction interface?
> > I had planned to return the linear regression coefficients in
> > the form of a linear function:
> >
> > public interface MultivariateRealFunction
> > {
> > public double value(double x[]);
> > }
> >
> > // in package "linear"
> >
> > // a function of the form:
> > // y = b0 + b1*x1 + b2*x2 + ... bn*xn
> > public class LinearFunction
> > implements MultivariateRealFunction
> > {
> > public double value(double x[]) { ... };
> > public int getCoefficientCount() { ... };
> > public double getCoefficientAt(int idx) { ... };
> > public double[] getCoefficients() { ... };
> > }
> >
> >
> > public class LinearRegressionResults
> > {
> > public LinearFunction getFunction() { ... };
> > public double[] getResidual();
> > ...
> > // put in all the other statistical values here
> > }
> >
> > public class LinearRegresion
> > {
> > public LinearRegressionResults
> > solve(double x[][], double y[]) { ... };
> > }
> >
> > Thoughts?
> >
> That is an interesting approach, but I suspect that users of this class are
> going to be primarily interested in the vector of estimated coefficients as
> well as standard errors and other model statistics. I would prioritize
> getting the parameter estimates and standard errors represented and
> available. I have no problem including a predict() method (or even
> returning a function) that uses the coefficients to produce predicted
> values based on the model, but I would be happy (actually happier) with a
> (row) RealMatrix of coefficients.
>
> Phil
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!
> http://webhosting.yahoo.com/ps/sb/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [math] Re: - Multiple Linear Regression
Posted by Phil Steitz <st...@yahoo.com>.
--- Piotr Kocha�ski <pi...@uw.edu.pl> wrote:
> Inger, Matthew napisa�(a):
>
> > returning a RealMatrix for the coefficients doesn't make sense
> > to me, since a matrix implies N x M dimensions, and the coefficient
> > matrix has a fixed number of rows (1).
A row matrix is a perfectly good matrix!
I'd rather return an double[]
> > instance. However, that array is available through LinearFunction
> > as i have outlined it below, so it's not really hard to get to it:
> >
> > results.getFuntion().getCoefficients();
>
> This way of obtaining coefficients might be natural and elegant
> for a Java programmer, but I think that average statistician would
> prefere to get them in a simpler way, without digging through
> interfaces, methods, etc. just to find such a basic result.
>
> As I understand rationale behind returning RealMatrix is that
> there is a number of usefull methods that makes manipulation
> with the result easier, but I would not complain if I get double[],
> I would not have to think about some additional interface (RealMatrix).
> In addition double[] can be easily converted to RealMatrix if it is
> needed.
I am fine with returning a double[]. The coefficients are the important
thing. The matrix representation is natural (to me at least) because the
estimated regression model is a linear transformation.
It is not obvious to me what is the best way to think about / represent
multivariate real functions generally, or under what circumstances we
actually need them (since that will determine how best to represent them).
Matrices should be used to represent linear transformations, IMHO, since in
addition to evaluation, they expose all of the structure. That is what I
meant above.
Phil
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org