Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- t-stat for intercept difference

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 09-17-2019 03:54 AM
(580 views)

Hi

I have run a regression on a dataset that has 2 different IDs, there is one X and one Y variable. I have an intercept and a coefficient for each one of these two IDs. My ultimate purpose is to Subtract intercept of ID5 from the intercept of ID1 (b0 (ID5) - b0 (ID1)) and measure NeweyWest t-stat of this difference. Please guide me in this regard, thanks.

See the code below that I am using for regression:

```
ods exclude all;
proc model data=Have;
by ID;
endo Y;
exog X;
instruments _exog_;
parms b0 b1;
Y=b0 + b1*X;
fit Y / gmm kernel=(bart,5,0) vardef=n;
ods output parameterestimates=Want;
run;
ods exclude none;
```

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

What is the model? Are the Month and Year variables important? Do you want the slopes to depend on the ID, or just the intercepts?

If the model is Y = X and the ID only affects the intercept, you can use

```
proc glm data=Have;
class ID(ref='5');
model Y = X ID / solution;
run;
```

In the ParameterEstimates table, the row for 'ID 1' shows the difference between the ID=1 level and the reference level (which is ID=5). The 't Value' column gives the value of the t statistic and the ''Pr > |t|)' column is the p value for the statistic.

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Do you want OLS or time series regression?

For OLS regression, you can use the CLASS statement and set the reference level of the ID variable to ID1. For example, here is an example that sets the reference level for the TYPE variable in an OLS regression?

```
proc glm data=sashelp.cars;
where type in ('Sedan' 'SUV' 'Truck' 'Wagon' 'Sports');
class type(ref='SUV'); /* set reference level for classification variable */
model mpg_city = weight type / solution;
run;
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@Rick_SAS: Thanks for your reply. I think my question was not very clear. I have attached a sample of my data. I want to run OLS regression (not time series) on this data, and find t-stat for the difference in intercepts of these two IDs. Please guide. Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

What is the model? Are the Month and Year variables important? Do you want the slopes to depend on the ID, or just the intercepts?

If the model is Y = X and the ID only affects the intercept, you can use

```
proc glm data=Have;
class ID(ref='5');
model Y = X ID / solution;
run;
```

In the ParameterEstimates table, the row for 'ID 1' shows the difference between the ID=1 level and the reference level (which is ID=5). The 't Value' column gives the value of the t statistic and the ''Pr > |t|)' column is the p value for the statistic.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@Rick_SAS: My Y variable is monthly Returns, and X is Volatility. I want to run a simple OLS model i.e. Y=a+bX, grouped by ID. This means one intercept and beta from ID1, and one intercept and beta from ID5 should be shown by the regression. Year and Month are not of a concern in this regression. I am using proc model because I need Newey-West corrected standard errors and t-stat. If proc glm is used to measure the significance of intercepts difference, how would Newey-West approach be applied then? Please guide. Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I believe I answered your first question. The intercept for ID=5 is the Intercept term in the model. The intercept for ID=1 is (Intercept + the estimate for ID=1). If you also want the slope to depend on the ID variable, change the model to

MODEL Y = X | ID / solution;

I don't know anything about Newey-West corrected standard errors, but you can ask questions about PROC MODEL and time series in the SAS Forecasting and Econometric community. From Wikipedia, it appears that Newey-West corrections are for autocorrelated and heteroskedastic errors in time series data. OLS regression assumes that you do not have autocorrelation or heteroskedasticity.

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.