Developer Forums | About Us | Site Map
Search  
HOME > TUTORIALS > SERVER SIDE CODING > PHP TUTORIALS > SIMPLE LINEAR REGRESSION WITH PHP: PART 1


Sponsors





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

The burnout study

To demonstrate how the class is used, I can use data from a study on burnout in human services. Michael Leiter and Kimberly Ann Meechan studied the relationship between a measure of burnout called the Exhaustion Index and an independent variable they called Concentration. Concentration refers to the proportion of a person's social contacts that come from their work environment.

To examine the relationship between Exhaustion Index scores and Concentration scores for individuals from their sample, load these scores into appropriately named arrays and instantiate the class with these array values. After instantiating the class, display some of the summary values generated by the class to assess the degree to which a linear model fits the data.

Listing 5 shows a script that loads the data and displays summary values:

Listing 5. A script for loading data and displaying summary values


<?php 

// BurnoutStudy.php

// Copyright 2003, Paul Meagher 
// Distributed under GPL   

include "SimpleLinearRegression.php"; 

// Load data from burnout study 

$Concentration   = array(20,60,38,88,79,87, 
                         68,12,35,70,80,92, 
                         77,86,83,79,75,81, 
                         75,77,77,77,17,85,96);  
                          
$ExhaustionIndex = array(100,525,300,980,310,900, 
                         410,296,120,501,920,810, 
                         506,493,892,527,600,855, 
                         709,791,718,684,141,400,970);  
                          
$slr = new SimpleLinearRegression($Concentration, $ExhaustionIndex);  

$YInt      = sprintf($slr->format, $slr->YInt);
$Slope     = sprintf($slr->format, $slr->Slope);    
$SlopeTVal = sprintf($slr->format, $slr->SlopeTVal);    
$SlopeProb = sprintf("%01.6f", $slr->SlopeProb);    

?>

<table border='1' cellpadding='5'>

  <tr>
    <th align='right'>Equation:</th>
    <td></td>
  </tr>
  <tr>

    <th align='right'>T:</th>
    <td></td>
  </tr>
  <tr>
    <th align='right'>Prob > T:</th>

    <td><td>
  </tr>
</table>

Run this script through a Web browser to produce the following output:

Equation:Exhaustion = -29.50 + (8.87 * Concentration)
T:6.03
Prob > T:0.000005

The bottom row of this table tells that the probability of obtaining a T value this large by chance is very low. You can conclude that a simple linear model offers more predictive power than simply using the mean of the Exhaustion scores.

Knowing the concentration of workplace contacts for an individual can be used to predict the degree of burnout they are likely to be experiencing. The equation tells us that for each one-unit increase in concentration scores, a person in the social services field experiences an eight-unit increase in Exhaustion scores. This provides some evidence that to reduce the potential for burnout, individuals in the social services field should consider making friends outside of their workplace.

This is a quick sketch of what these results might mean. To fully explore the implications of this dataset, you would want to study the data in more detail to make sure this is the proper interpretation. In the next article I discuss what additional analyses should be performed.



View Simple linear regression with PHP: Part 1 Discussion

Page:  1 2 3 4 5 6 7 8 Next Page: What have you learned?

First published by IBM developerWorks


Copyright 2004-2017 GrindingGears.com. All rights reserved.
Article copyright and all rights retained by the author.