BookmarkSubscribeRSS Feed
jawon
Fluorite | Level 6

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! 

4 REPLIES 4
Reeza
Super User

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.

jawon
Fluorite | Level 6

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? 

Reeza
Super User

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. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 4 replies
  • 1525 views
  • 0 likes
  • 3 in conversation