Regression by a grouping variable

This macro performs a regression analysis of Y on X.1 - X.n for each level of a grouping variable.

This macro performs a regression analysis of Y on X.1 - X.n for each level of a grouping variable.

Download the Macro

Be sure that Minitab knows where to find your downloaded macro. Choose File > Options > General. Under Macro location browse to the location where you save macro files.

Important

If you use an older web browser, when you click the Download button, the file may open in Quicktime, which shares the .mac file extension with Minitab macros. To save the macro, right-click the Download button and choose Save target as.

Required Inputs

  • A column of dependent values
  • One or more columns of independent, continuous predictor variables
  • A column of grouping values

Running the Macro

Suppose the dependent variable (Y) is in C2, the independent predictor variables (X's) are in C3 - C8, and the grouping variable is C10. To run the macro, choose View > Command Line/History and type:
%BYREG C2 C3 - C8 C10

Click Run.

Note

The last column listed is assumed to be the grouping variable. The macro will skip any group that does not have at least p + 2 observations where p is the number of independent predictor variables.