BookmarkSubscribeRSS Feed
shaterian
Calcite | Level 5
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
Rick_SAS
SAS Super FREQ

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.

shaterian
Calcite | Level 5

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

1118.6625502118.6625502493.32<.0001
114.843873914.843873961.71<.0001
10.37178420.37178421.550.2452

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

1108.3875717108.3875717450.60<.0001
13.45687363.456873614.370.0043
10.37178420.37178421.550.2452

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

2.980191458B0.578289945.150.0006
0.735567010B0.0497976314.77<.0001
-3.122248485B0.82360741-3.790.0043
0.000000000B...
0.091520566B0.073615251.240.2452
0.000000000B..

.

 

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;

 

Rick_SAS
SAS Super FREQ

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. 

 

shaterian
Calcite | Level 5

Thanks once again, 

you are very helpful

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

 

Best Regards

Javad

shaterian
Calcite | Level 5

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

 

 

 

Rick_SAS
SAS Super FREQ

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;
sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

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.)

 

shaterian
Calcite | Level 5

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

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

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

 

 

 

 

shaterian
Calcite | Level 5

Thanks

SLD

You are great ..

Javad

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

You are welcome 🙂

user20
Fluorite | Level 6
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?
Rick_SAS
SAS Super FREQ

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.

SAS Innovate 2025: Call for Content

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Discussion stats
  • 13 replies
  • 8304 views
  • 2 likes
  • 4 in conversation