Help and Support
 

powered byLive Search

INF: How to Use the Linear Regression Functions

Article ID:307276
Last Review:February 20, 2007
Revision:3.4
This article was previously published under Q307276
On This Page

SUMMARY

This article explains and illustrates the use of the following Linear Regression functions in a calculated member:
LinRegIntercept
LinRegPoint
LinRegR2
LinRegSlope
LinRegVariance

Back to the top

MORE INFORMATION

Linear Regression is a statistical method that predicts the value of one variable, based on knowledge of another variable and the statistical relationship between the two. The Linear Regression functions use the method of least squares to calculate the equation of the best-fit line for a series of points. The general equation for linear regression is

Y'=aX+b

where Y' is the predicted value, a is the slope of the regression line, b is the intercept of the regression line, and X is a value of the X axis.

Back to the top

LinRegIntercept

The LinRegIntercept function returns the intercept of a regression line. In this example, you add a calculated member named "Intercept" to the Sales cube of the FoodMart sample. To add the calculated member, use these steps:
1.Open the Sales cube of the FoodMart sample for editing.
2.Add a new calculated measure with the following properties:
Parent Dimension = Measures
Member Name = Intercept
Value = LinRegIntercept(LastPeriods(10),[Measures].[Unit Sales],[Measures].[Store Sales])

Back to the top

LinRegSlope

The LinRegSlope function returns the slope of a regression line. In this example, you add a calculated member named "Regression Slope" to the Sales cube of the FoodMart sample. To add the calculated member, use these steps:
Add a new calculated measure with the following properties:
Parent Dimension = Measures
Member Name = Regression Slope
Value = LinRegSlope(LastPeriods(10),[Measures].[Unit Sales],[Measures].[Store Sales])

Back to the top

LinRegPoint

The LinRegPoint function returns a predicted value of one variable, based on the statistical relationship between the variables. In this example, you add a calculated member named "Predict" to the Sales cube of the FoodMart sample. To add the calculated member, use these steps:
Add a new calculated measure with the following properties:
Parent Dimension = Measures
Member Name = Predict
Value = LinRegPoint([Measures].[Unit Sales],LastPeriods(10),[Measures].[Unit Sales],[Measures].[Store Sales])
Format String = Standard
An alternate approach to returning a predicted value of one variable, based on the statistical relationship between the two sets of variables is to use the values returned by the LinRegIntercept and LinRegSlope functions. In this example, you add a calculated member named "Predict Formula" to the Sales cube of the FoodMart sample. To add the calculated member, use these steps:
Add a new calculated measure with the following properties:
Parent Dimension = Measures
Member Name = Predict Formula
Value = ([Measures].[Slope]*[Measures].[Unit Sales])+[Measures].[Intercept]
Format String = Standard
Click the Data tab and compare the values you see in the Predict and Predict Formula columns. The values in the two columns should be identical.

Back to the top

LinRegR2

The LinRegR2 function returns the statistical R2 that describes the goodness of fit of the linear regression equation to the points. In this example, you add a calculated member named "Good Fit" to the Sales cube of the FoodMart sample. To add the calculated member, use these steps:
Add a new calculated measure with the following properties:
Parent Dimension = Measures
Member Name = Good Fit
Value = LinRegR2(LastPeriods(10), [Measures].[Unit Sales],[Measures].[Store Sales])
Format String = #,#.00

Back to the top

LinRegVariance

The LinRegVariance function returns the statistical variance that describes the fit of the linear equation to the points. In this example, you add a calculated member named "Variance" to the Sales cube of the FoodMart sample. To add the calculated member, use these steps:
Add a new calculated measure with the following properties:
Parent Dimension = Measures
Member Name = Variance
Value = LinRegVariance(LastPeriods(10),[Measures].[Unit Sales],[Measures].[Store Sales])

Back to the top


APPLIES TO
Microsoft SQL Server OLAP Services
Microsoft SQL Server 2000 Analysis Services

Back to the top

Keywords: 
kbinfo KB307276

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by E-mail, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.