Developer Forums | About Us | Site Map


Useful Lists

Web Host
site hosted by netplex

Online Manuals

Simple linear regression with PHP: Part 1
By Paul Meagher - 2004-05-12 Page:  1 2 3 4 5 6 7 8

What have you learned?

For one, you don't have to be a rocket scientist to develop a significant PHP-based math package. Adhering to standard object-oriented techniques, as well as explicitly adopting a backward-chaining problem-solving approach, makes implementing some of the more basic statistical procedures using PHP relatively straightforward.

From an educational point of view, I would argue that this exercise is useful if for no other reason than it forces you to think at both a higher and lower level of abstraction about a statistical test or routine. In other words, a good way to complement your learning of a statistical test or procedure is to implement that procedure as an algorithm.

To implement a statistical test often requires going beyond the information given and engaging in creative problem solving and discovery. It is also a good way to discover holes in your knowledge of a subject.

On a negative note, you discovered that PHP has no native access to sampling distributions, which is a requirement for implementing most statistical tests. You shelled out to R to get these values, but I am worried that you will not have the time or inclination to install R. A native PHP implementation of some common probability functions would resolve that.

Another problem is that the class generates many intermediate and summary values, but the summary output really didn't take advantage of this. I provided some teaser output, but this was not sufficently extensive nor well organized so that you could adequately interpret the results of the analysis. In fact, I was entirely silent about how output methods might be integrated into this class. This needs to be addressed.

Finally, understanding your data means more than just looking at summary values. You also need to get a sense of how individual data points are distributed. One of the best ways to do this is by graphing your data. Again, I have been silent on this topic, but it needs to be addressed if the class is to be used for analysis of real data.

In the next article in this series, I'll implement some probability functions using native PHP code, extend the SimpleLinearRegression class with several output methods, and generate a report that presents intermediate and summary values in tabular and graphical formats so that conclusions can more readily be drawn from the data. Stay tuned!

View Simple linear regression with PHP: Part 1 Discussion

Page:  1 2 3 4 5 6 7 8 Next Page: Resources

First published by IBM developerWorks

Copyright 2004-2023 All rights reserved.
Article copyright and all rights retained by the author.