Fluorite | Level 6

## Proc Logistic. Why is predicted probability different than calculated from a regression equation?

As in a subject.

```data have;
set sashelp.cars;
isUSA = Origin="USA";
run;

proc logistic data=have;
model isUSA=EngineSize Cylinders Horsepower;
output out=pred p=p;
run;

data want;
keep p p_manual;
set pred;
p_manual = 1/(1+EXP(-1 * 0.3199 -3.091*EngineSize
+0.5735*Cylinders
+0.0334*Horsepower));
run;```

Why is p different than p_manual variable in the want dataset?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: Proc Logistic. Why is predicted probability different than calculated from a regression equation

How different?
Here's an example showing results that match exactly.
https://communities.sas.com/t5/Statistical-Procedures/How-to-determine-logistic-regression-formula-f...

You were missing a set of brackets in your formula:

```p_manual = 1/(1+EXP(-1 * (0.3199 -3.091*EngineSize
+0.5735*Cylinders
+0.0334*Horsepower)));```

@Jedrek369 wrote:

As in a subject.

```data have;
set sashelp.cars;
isUSA = Origin="USA";
run;

proc logistic data=have;
model isUSA=EngineSize Cylinders Horsepower;
output out=pred p=p;
run;

data want;
keep p p_manual;
set pred;
p_manual = 1/(1+EXP(-1 * 0.3199 -3.091*EngineSize
+0.5735*Cylinders
+0.0334*Horsepower));
run;```

Why is p different than p_manual variable in the want dataset?

Thanks.

3 REPLIES 3
Super User

## Re: Proc Logistic. Why is predicted probability different than calculated from a regression equation

How different?
Here's an example showing results that match exactly.
https://communities.sas.com/t5/Statistical-Procedures/How-to-determine-logistic-regression-formula-f...

You were missing a set of brackets in your formula:

```p_manual = 1/(1+EXP(-1 * (0.3199 -3.091*EngineSize
+0.5735*Cylinders
+0.0334*Horsepower)));```

@Jedrek369 wrote:

As in a subject.

```data have;
set sashelp.cars;
isUSA = Origin="USA";
run;

proc logistic data=have;
model isUSA=EngineSize Cylinders Horsepower;
output out=pred p=p;
run;

data want;
keep p p_manual;
set pred;
p_manual = 1/(1+EXP(-1 * 0.3199 -3.091*EngineSize
+0.5735*Cylinders
+0.0334*Horsepower));
run;```

Why is p different than p_manual variable in the want dataset?

Thanks.

Fluorite | Level 6

## Re: Proc Logistic. Why is predicted probability different than calculated from a regression equation

Shoot. That's embarrassing. Thanks anyway.

## Re: Proc Logistic. Why is predicted probability different than calculated from a regression equation

Tip: The formula

`p_manual = 1/(1+EXP(-1 * (...)));`

can be simplified to

`p_manual = logistic(...);`

(see LOGISTIC function).

Discussion stats
• 3 replies
• 605 views
• 13 likes
• 3 in conversation