Programming the statistical procedures from SAS

Expressing logistic and linear regression output into an equation

Reply
Contributor
Posts: 20

Expressing logistic and linear regression output into an equation

I need to express my linear regression model as an equation so that I can calculate the predictions separately (ie, outside SAS). Ditto for my logistic regression model. Could you confirm whether I'm doing this correctly?

 

---------------------------------------------------------------------------------

LINEAR regression parameter estimates (using proc genmod)

  • Intercept: 3.9273
  • var1: 0.0015

I've expressed the equation as:     prediction   =   3.9273 + 0.0015*var1

 

---------------------------------------------------------------------------------

LOGISTIC regression parameter estimates (using proc logistic, binary, solving for "1")

  • Intercept: -2.8240
  • var2: 1.2638

I've expressed the equation as:    probability   =   exp(-2.8240 + 1.2638*var2)   /   (1 + exp(-2.8240 + 1.2638*var2))

 

---------------------------------------------------------------------------------

Yes, no, maybe so??? I need to confirm because when I do this, the answers do not match what I get when scoring in SAS directly. Thank you! 

Grand Advisor
Posts: 16,926

Re: Expressing logistic and linear regression output into an equation

Here's a good thread on this topic.

 

https://communities.sas.com/t5/SAS-Statistical-Procedures/How-to-determine-logistic-regression-formu...

 

It has a worked example, the Neuralgia dataset is in SAS documentation if you want to test the code.

 

Also, look at the CODE statement in those procs if you're in SAS/STAT 13+

This will generate sas data step code that will score your data. 

Or you can use PROC SCORE or the SCORE statement within those procs.

SAS Employee
Posts: 187

Re: Expressing logistic and linear regression output into an equation

See this note.

Contributor
Posts: 20

Re: Expressing logistic and linear regression output into an equation

Not finding the answer yet. Sorry for being a numbskull. I'll try to be more specific.

 

PART 1: My linear regression code:

proc genmod data = mydataset;
model amount = var1 / 
link = log dist = gamma type3; output
out = myoutput p = pred; run;

The resulting parameter estimates:

  • Intercept: 3.9273
  • var1: 0.0015

This is a gamma distribution with a log link, so I guess that complicates matters. How should I translate this into an actual mathematical equation? 

 

PART 2: My logistic regression code:

proc logistic data = my_training_dataset
outmodel = my_model_info;
model responded (event = '1') = var2 /
selection = stepwise lackfit rsq; run; proc logistic inmodel = my_model_info; score data = my_dataset_to_score out = my_scored_dataset; run;

The resulting parameter estimates:

  • Intercept: -2.8240
  • var2: 1.2638

How should I translate this into an actual mathematical equation? 

Grand Advisor
Posts: 16,926

Re: Expressing logistic and linear regression output into an equation

Use the CODE statement in either proc and examine the output. 

 

The initial thread I linked too walked through the solution for LOGISTIC regression in detail so I'm not sure what I could add besides replicating it specifically for your exact values. 

Ask a Question
Discussion stats
  • 4 replies
  • 194 views
  • 0 likes
  • 3 in conversation