Linear Models

Example: Linear Regression with Fixed Effects

To create this example:
  1. Create the Work.Cigar data set. For more information, see CIGAR Data Set.
  2. In the Tasks section, expand the Econometrics folder, and then double-click Panel Data Models. The user interface for the Panel Data Models task opens.
  3. On the Data tab, select the WORK.CIGAR data set.
    Tip
    If the data set is not available from the drop-down list, click Select a table icon. In the Choose a Table window, expand the library that contains the data set that you want to use. Select the data set for the example and click OK. The selected data set should now appear in the drop-down list.
  4. Assign columns to these roles:
    Role
    Column Name
    Panel Structure
    Cross-sectional ID
    state
    Time ID
    year
    Roles
    Dependent variable
    sales
    Continuous variables
    price
    cpi
    ndi
  5. On the Model tab, select Linear as the model type.
  6. To run the task, click Submit SAS Code Icon.
Here is a subset of the results:
Fixed One-Way Estimates

Assigning Data to Roles

To perform an analysis of a linear model, you must assign an input data set. To filter the input data source, click Filter Icon.
You also must assign variables to the Cross-sectional ID, Time ID, and Dependent variable roles. The task sorts the values in the input data set by the variables that you assign to the Cross-sectional ID and Time ID roles. Within each cross section, the values of the time ID must be unique.
Role
Description
Panel Structure
Cross-sectional ID
specifies the cross section for each observation. The task verifies that the input data is sorted by the cross-sectional ID and by the time series ID within each cross section.
Time ID
specifies the time period for each observation. For each cross section, the values of the time ID must be unique.
Roles
Dependent variable
specifies the numeric variable to use in the analysis.
Continuous variables
specifies the independent covariates (regressors) for the regression model. If you do not specify a continuous variable, the task fits a model that contains only an intercept.
Categorical variables
specifies the classification variables. The task generates dummy variables for each level of the categorical variable.
Additional Roles
Group analysis by
enables you to obtain separate analyses of observations for each unique group.
Note: This role is not available if you have a categorical variable.

Setting the Model Options

To create a linear model:
  1. From the Model type drop-down list, select Linear.
  2. Specify the effects for the model.
    You can display the main effects model or create a custom model. To create a custom model, select the Custom Model option, and then click Edit. The Model Effects Builder opens. All continuous variables and categorical variables are listed in the Variables pane.
    • To create a main effect, select the variable in the Variables pane, and then click Add.
    • To create a crossed effect, select the variables in the Variables pane. (You can use Ctrl to select multiple variables.) Then click Cross.
    When you finish, click OK. The effects that you specified now appear on the Model tab.
    Here is an example of model effects on the Model tab.
    price and price*productLine effects
  3. From the Linear model drop-down list, select the type of linear model. You can choose from these options:
    • Fixed effects. For the type of fixed effects, you can select from these options: One-way fixed effects, One-way, time, and Two-way effects. You can also specify whether to display the fixed effects.
    • Random effects. For the type of random effects, you can select from a one-way or two-way effect. Then specify the method to use for estimating the variance component.
    • Hausman-Taylor. In this type of model, the variables that you assigned to the Continuous variables role on the Data tab can be assigned to the Correlated variables role.
    • Amemiya-MaCurdy. In this type of model, the variables that you assigned to the Continuous variables role on the Data tab can be assigned to the Correlated variables role.
    • First-order autoregressive
    • Moving average. For the Da Silva method, you can specify the order of the moving average process and the method for estimating the variance component.

Setting the Options

Option Name
Description
Methods
Covariance matrix estimator
specifies the method to calculate the covariance matrix of parameter estimates.
You can use the default value, or you can choose from these methods:
  • Newey and West
  • OLS estimator specifies that the variance-covariance matrix is not corrected.
  • HCCMEn specifies a heteroscedasticity-corrected covariance matrix. n is a value from 0–4.
If you select one of the HCCME0-3 options for the covariance matrix estimator, you can also specify whether to include the cluster correction for the variance-covariance matrix.
Statistics
Select the statistics to display in the results.
Here are the additional statistics that you can include in the results:
  • correlations of the parameter estimates
  • covariances of the parameter estimates
  • iteration history of the objective function and parameter estimates
  • tests for random effects: one-way Breusch-Pagan test and two-way Breusch-Pagan test
These tests are also available for first-order autoregressive linear models:
  • estimated covariances of the observations
  • estimated autocorrelation coefficients
Plots
Select the plots to include in the results. By default, a histogram of residuals is included in the results. You can include these plots:
  • diagnostic plots: predicted and actual values by observation, QQ plot of residuals, residuals by observation, and a histogram of residuals
  • cross-section plots: actual values by time series, predicted values by time series, stacked residuals by time series, and residuals by time series
You can display these as a panel of plots or as individual plots. If you select Individual plots from the Display as drop-down list, you can specify the number of cross sections in one time series plot.

Creating the Output Data Sets

You can create these output data sets:
  • an output data set that contains the statistics from the analysis
  • a parameter estimates data set
  • a transformed series data set
    Note: This option is available only if you are creating a linear model that contains one-way fixed effects and one-way random effects.