Programming the statistical procedures from SAS

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

Reply
Occasional Contributor
Posts: 9

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

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
SAS Super FREQ
Posts: 3,543

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

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.

Occasional Contributor
Posts: 9

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

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;

 

SAS Super FREQ
Posts: 3,543

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

[ Edited ]

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. 

 

Occasional Contributor
Posts: 9

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

Thanks once again, 

you are very helpful

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

 

Best Regards

Javad

Occasional Contributor
Posts: 9

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

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

 

 

 

SAS Super FREQ
Posts: 3,543

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

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;
PROC Star
PROC Star
Posts: 185

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

[ Edited ]

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

 

Occasional Contributor
Posts: 9

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

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

PROC Star
PROC Star
Posts: 185

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

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

 

 

 

 

Occasional Contributor
Posts: 9

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

Thanks

SLD

You are great ..

Javad

PROC Star
PROC Star
Posts: 185

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

You are welcome Smiley Happy

Ask a Question
Discussion stats
  • 11 replies
  • 159 views
  • 2 likes
  • 3 in conversation