Turn on suggestions

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

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Re: need SAS commands to compare regression slopes, for the following...

Options

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

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

Posted 05-31-2017 01:18 PM
(8094 views)

Hi

I need SAS commands to compare regression slopes, for the following data set,

most apprericated any help...

Options S = 40 LS = 78 NODATE center;

Data Comp;

Input Year $ Y X @@;

Cards;

1YR 3.8 4.5 2YR 6.8 4.5

1YR 6.2 7.5 2YR 15.2 16.5

1YR 7.2 9.5 2YR 8.5 8.0

1YR 8.7 10.5 2YR 9.1 9.5

1YR 10.2 13.0 2YR 12.0 11.5

1YR 13.5 16.0 2YR 12.6 13.0

2YR 13.3 14.0

;

Regards

Javad

13 REPLIES 13

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

I assume you want a model like this:

```
proc glm data=Comp;
class Year;
model Y = X | Year / solution;
run;
```

and then look at the parameter estimates. The estimate for X gives the baseline estimate (for Year=2Yr) and the estimate of the interaction term (X*(Year=1Yr) gives the incremental increase in for the Year=1Yr group.

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

Mr Rick

Thanks a lot, for the commands,

I guess I am almost close to the comparsion but not yet though.

I got estimates for different years, but NOT being compared

There letter B in separate columb, it seem there are non-formality implied there?

Source DF Type I SS Mean Square F Value Pr > F X Year X*Year

1 | 118.6625502 | 118.6625502 | 493.32 | <.0001 |

1 | 14.8438739 | 14.8438739 | 61.71 | <.0001 |

1 | 0.3717842 | 0.3717842 | 1.55 | 0.2452 |

Source DF Type III SS Mean Square F Value Pr > F X Year X*Year

1 | 108.3875717 | 108.3875717 | 450.60 | <.0001 |

1 | 3.4568736 | 3.4568736 | 14.37 | 0.0043 |

1 | 0.3717842 | 0.3717842 | 1.55 | 0.2452 |

Parameter Estimate Standard

Error t Value Pr > |t| Intercept X Year 1YR Year 2YR X*Year 1YR X*Year 2YR

2.980191458 | B | 0.57828994 | 5.15 | 0.0006 |

0.735567010 | B | 0.04979763 | 14.77 | <.0001 |

-3.122248485 | B | 0.82360741 | -3.79 | 0.0043 |

0.000000000 | B | . | . | . |

0.091520566 | B | 0.07361525 | 1.24 | 0.2452 |

0.000000000 | B | . | . | . |

looking at a similar question, I found the following commands but not working as it is: what do you think ?

ROC REG;

Model Y = X test b=the slope of model A ;

run;

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

Sorry, I thought you wanted the values of the slopes. If you want to test whether the slopes are statistically different, you can do a hypothesis test, as described in this SAS Note. For your data it would look like

ESTIMATE '1Yr VS 2Yr' Year 1 -1;

Yes, the "B" indicate the reference levels for the GLM parameterization. You can read about how to interpret the /SOLUTION output in the same SAS note.

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

Thanks once again,

you are very helpful

great reminder of what I was doing years ago, with contrast and estimate

Best Regards

Javad

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

Hi Rick

I was wondering if I can use estimate or contrast slopes of two years ( B1 vs B2) from regression lines, which are not titled in the data

any comment on these commands :

PROC REG;

Model Y = X test b=the slope of model A ;

run;

Yi = B0 + B1x + µ

Yii = B0 + B2x + µ

'B1 vs B2' ??

Thanks

Javad

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

I don't understand why you are now using PROC REG. Perhaps this is a different question. My guess is that you are asking for a hypothesis test to see if it is likely that a parameter estimate equals some value of the parameter. The TEST statement in PROC REG runs an F test for that hypothesis:

```
proc reg data=sashelp.class plots=none;
model weight = height;
H4: test height=4; /* F test for H0: b1=4 */
run;
quit;
```

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

I'm not sure that this is an answer to the original question, but...to obtain estimates of intercepts and slopes for both regressions (without algebra or ESTIMATE statements) and an easy way to test whether slopes are equal; plus testing slope equal to a particular value:

/* Fit reparameterized ANCOVA model that directly provides estimates of intercepts and slopes. Note use of NOINT in combination with different fixed effects terms. */ proc glimmix data=comp; class year; model y = year x*year / noint solution; estimate "Slope comparison 1YR versus 2YR" x*year 1 -1; store out=comp_model; run; /* Test hypotheses that a particular slope is equal to a particular value */ proc plm restore=comp_model; estimate "1YR slope= 0" x*year 1 / testvalue= 0; /* compare to solution output in model above */ estimate "1YR slope= -3" x*year 1 / testvalue= -3; run;

(I got the PLM tip from Kathleen Kiernan at SAS.)

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

Many thanks to Rick and SLD

I was wondering where I can find more info. on the use of Proc glimix and

Proc plm restore comands

I mean paricularity of their usages in experiment setting and analysis

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

Here are some resource ideas:

1. www.lexjansen.com provides a fabulously easy way to search all of the SAS user group proceedings, including SGF. Try "plm" or "glimmix" in the search window.

2. https://www.sas.com/store/books/categories/usage-and-reference/sas-for-mixed-models-second-edition/p... uses MIXED primarily, but the concepts and usage can be extended to GLIMMIX. The 3rd ed http://support.sas.com/publishing/authors/stroup.html is due out later this year and will feature lots of GLIMMIX.

3. https://www.crcpress.com/Generalized-Linear-Mixed-Models-Modern-Concepts-Methods-and-Applications/St... by Walt Stroup

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

Thanks

SLD

You are great ..

Javad

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

You are welcome 🙂

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

Hi Rick, I know this is a very old post, but I think to test whether the slopes are statistically different in the context of this question, we need to do

ESTIMATE '1Yr VS 2Yr' X*Year 1 -1;

Am I correct?

ESTIMATE '1Yr VS 2Yr' X*Year 1 -1;

Am I correct?

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

Yes, this is a very old post, and I don't want to open it for further discussion. The thread discusses several different models and goals and also contains some mistakes. If you want to understand how to formulate an ESTIMATE statement, see http://support.sas.com/kb/38/384.html

If you have questions that are not covered in the SAS KB article, feel free to open a new thread and post your code, model, and sample data.

Are you ready for the spotlight? We're accepting content ideas for **SAS Innovate 2025** to be held May 6-9 in Orlando, FL. The call is **open **until September 16. Read more here about **why** you should contribute and **what is in it** for you!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.