Wednesday, April 22, 2009

Weighted Linear Regression In Java and Excel

I've ported a weighted linear regression algorithm from C# by Walt Fair Jr. that I found on codeproject.com to Java. I believe my math skills are not bad, but I lack confidence in solving the linear regression equations by myself :). However, it seems that the original author is not known, and the code dated to as early as 1972.

I've also made a simple Excel file based on that algorithm, but only for one polynomial order, so that we can input the values of the variables and see the results back directly as Excel charts. The Java application (Netbeans) can be downloaded here and the Excel file can be downloaded here.

Note that I used one function to invert a matrix in Excel called Minverse, and it may not work for early versions of Excel. I've also only tested the ported Java application with only one polynomial order, so please let me know if it works (or doesn't) for higher polynomial orders.

1 comments:

Anonymous said...

Thanks so much for porting the code to Java, I've been looking for weighted linear regression in Java for some time now :)

Post a Comment