Programming the statistical procedures from SAS

Specify slope

Reply
Contributor
Posts: 40

Specify slope

I would like to specify a value of '1' to my slope and estimate the intercept. Is there a way to do that in proc GLM or another proc?
Thanks
Respected Advisor
Posts: 2,655

Re: Specify slope

I suppose that you currently have something like:

proc glm data=one;
model y=x;
run;

if so, then try:

data two;
set one;
diff=y-x;
run;

proc glm data=two;
model diff=;
run;

The standard error of the estimate will be slightly biased, but the point estimate should be OK.

Steve Denham
Contributor
Posts: 40

Re: Specify slope

I finally got around to trying the code and it worked really well for my requirement.
Thanks to both of you for the suggestions. the code that I used was the first one that Steve suggested - proc glm modeling the difference.

Thanks for the help!
Regular Contributor
Posts: 169

Re: Specify slope

Many of the SAS procedures which allow you to fit a regression model allow specification of an "offset" parameter. The GLM procedure is one of the procedures which allow specification of an offset parameter. When you specify that a variable is an offset parameter, then that variable enters the right hand side of the model with slope coefficient fixed at 1.

With the GLM procedure, code for fitting a regression model including an offset parameter would be something like the following:

proc glm data=mydata;
   class x1 x2;
   model y = x1 x2 x3 / offset=z s;
run;

In the above code, there is a variable Z which is to have a slope coefficient of 1. It should be pointed out that you can only name one variable as being an offset parameter. The documentation for the GLM procedure also states that "This variable cannot be a CLASS variable, and it cannot be the response variable or one of the explanatory variables." Only a moments thought would prove that all of these conditions make sense.
Respected Advisor
Posts: 2,655

Re: Specify slope

Dale,

Did you mean GLIMMIX, rather than GLM? I got sensible answers from GLIMMIX, but only error messages from GLM. Maybe I missed something in the syntax.

Steve Denham
Contributor
Posts: 40

Re: Specify slope

Thank you all so much for you responses. I have not had a chance to try any of your suggestions yet but will do so soon and let you know. Thanks again for the help.
Regular Contributor
Posts: 169

Re: Specify slope

Steve,

I think that I must have clicked on the GENMOD procedure rather than the GLM procedure in the SAS documentation. I thought it was a bit odd that there would be an OFFSET parameter in GLM. I should have double-checked. The GLIMMIX procedure also supports an OFFSET parameter specification. However, not everyone has GLIMMIX installed.

If GLIMMIX is available, the code which I showed previously would work directly with only a change of the procedure name from GLM to GLIMMIX. If GLIMMIX is not available and GENMOD is employed, then one would need to remove the option S from the model statement.

Thus, we would write either:

proc glimmix data=mydata;
   class x1 x2;
   model y = x1 x2 x3 / offset=z s;
run;

or

proc genmod data=mydata;
   class x1 x2;
   model y = x1 x2 x3 / offset=z;
run;

Dale
Ask a Question
Discussion stats
  • 6 replies
  • 207 views
  • 0 likes
  • 3 in conversation