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

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- how to obtain the regression coefficients for vari...

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-06-2014 10:56 PM

I want to obtain the coefficients, T value, R square, intercept, and residual for EACH OBS through regression and then output/outest the result into a new dataset.

For example, there are 10 obs in a sample and there are 2 independent variables (X1 and X2). I want to generate a dataset like below:

obs

1 coefficient of X1 coefficient of X2 intercept T value Adj R square residual

2 coefficient of X1 coefficient of X2 intercept T value Adj R square residual

3 coefficient of X1 coefficient of X2 intercept T value Adj R square residual

4 coefficient of X1 coefficient of X2 intercept T value Adj R square residual

5 coefficient of X1 coefficient of X2 intercept T value Adj R square residual

6 coefficient of X1 coefficient of X2 intercept T value Adj R square residual

7 coefficient of X1 coefficient of X2 intercept T value Adj R square residual

8 coefficient of X1 coefficient of X2 intercept T value Adj R square residual

9 coefficient of X1 coefficient of X2 intercept T value Adj R square residual

10 coefficient of X1 coefficient of X2 intercept T value Adj R square residual

Please be noted what I want is not the set of parameter estimates, t value, adjusted R square etc for the WHOLE sample.

What I know is to obtain the residual for each obs (through below code) and output into a new dataset, but how to write the code for obtaining the other iterms? Thank you.

proc reg data=dataset;

model y = x1 x2;

output out=dataset_reg

r=residual;

run;

quit;

Accepted Solutions

Solution

05-08-2014
10:57 AM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to comeon2012

05-08-2014 10:57 AM

No, Maybe it is just a question of vocabulary but in my mind, a statistical model is a way to summarize and sometimes understand a phenomenon underlying data with a smaller amount of information. I don't understand the purpose of getting one model per data point, as you seem to want.

PG

PG

All Replies

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to comeon2012

05-06-2014 11:30 PM

I don't know about the concept of observation r-square, but for the rest, you could do:

**proc reg data=sashelp.class outest=oe;**

**model weight = height age;**

**output out=op predicted=predicted residual=residual student=tValue;**

**run;**

**quit;**

**proc sql;**

**create table want as**

**select op.*,**

** oe.height*op.height as heightCoef,**

** oe.age*op.age as ageCoef,**

** oe.intercept**

**from oe, op;**

**select * from want;**

**quit;**

PG

PG

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PGStats

05-08-2014 01:32 AM

Hi PG,

Thank you for your help. It goes well but the intercept keeps the same for all obs. Is it possible to get the intercept for EACH obs?

Thanks.

Solution

05-08-2014
10:57 AM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to comeon2012

05-08-2014 10:57 AM

No, Maybe it is just a question of vocabulary but in my mind, a statistical model is a way to summarize and sometimes understand a phenomenon underlying data with a smaller amount of information. I don't understand the purpose of getting one model per data point, as you seem to want.

PG

PG

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PGStats

05-08-2014 11:41 PM

I double checked the paper I followed and realised that I misunderstood its methodology.

Yes, my question doesn't make sense. Thank you anyways.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to comeon2012

05-08-2014 11:19 AM

Your question doesn't make sense.

That would mean a regression model for each observation, which isn't statistically valid.

Or are you looking for the values of X1, X2 instead of the coefficients?