Solved
Contributor
Posts: 58

# Exponential regression and square root model

How to find the exponential regression via SAS?

Accepted Solutions
Solution
‎07-01-2015 11:05 PM
Posts: 5,056

## Re: Exponential regression and square root model

Unfortunately, proc nlin is not very generous in terms of fit diagnostics compared to, say, proc reg. You thus have to do your own calculations, as I did below for the R square and the AIC.

data test;

input y x;

datalines;

3.366 3

3.052 6

2.666 9

2.755 12

2.203 15

1.886 18

1.525 21

1.547 24

0.81 27

0.76 30

0.27 33

0.67 36

;

title "Corrected sum of squares";

proc sql;

select css(y) into :CSSy

from test;

quit;

title "Linear fit";

ods graphics / imagename="LinearFit";

proc nlin data=test plots=fit;

parameters S0=1 b=0;

model y = S0 - b*x;

ods output EstSummary=summLin;

run;

proc sql;

select  N.nValue1 as n format=4.0,

SSE.nValue1 as SSE,

1 - SSE.nValue1/&CSSy as RSquare,

N.nValue1 * log(SSE.nValue1/N.nValue1) + 2*2 as AIC

from summLin as N, summLin as SSE

where N.Label1="Observations Used" and SSE.Label1="Objective";

quit;

title "Exponential fit";

ods graphics / imagename="ExponentialFit";

proc nlin data=test plots=fit;

parameters S0=1 b=0;

model y = S0 * exp( - b*x);

ods output EstSummary=summExp;

run;

proc sql;

select  N.nValue1 as n format=4.0,

SSE.nValue1 as SSE,

1 - SSE.nValue1/&CSSy as RSquare,

N.nValue1 * log(SSE.nValue1/N.nValue1) + 2*2 as AIC

from summExp as N, summExp as SSE

where N.Label1="Observations Used" and SSE.Label1="Objective";

quit;

title """Square root"" fit";

ods graphics / imagename="SquareRootFit";

proc nlin data=test plots=fit;

parameters S0=1 b=0;

model y = (sqrt(S0) - b*x)**2;

ods output EstSummary=summSqrt;

run;

proc sql;

select  N.nValue1 as n format=4.0,

SSE.nValue1 as SSE,

1 - SSE.nValue1/&CSSy as RSquare,

N.nValue1 * log(SSE.nValue1/N.nValue1) + 2*2 as AIC

from summSqrt as N, summSqrt as SSE

where N.Label1="Observations Used" and SSE.Label1="Objective";

quit;

R square and AIC are appropriate for comparing models in this case because the dependent data is the same and the number of fitted parameters is the same for the three models. Turns out that for this data, the linear model fits the best.

PG

PG

All Replies
Posts: 5,056

## Re: Exponential regression and square root model

PROC GENMOD and PROC GLIMMIX can fit models where the response is assumed to possess a probability distribution of the exponential form.

If exponential and square root refer to your model equation, i.e. you are trying to fit a non-linear model, then PROC NLIN will likely accomodate your needs.

PG

PG
Contributor
Posts: 58

## Re: Exponential regression and square root model

My data

 y x 3.366 3 3.052 6 2.666 9 2.755 12 2.203 15 1.886 18 1.525 21 1.547 24 0.81 27 0.76 30 0.27 33 0.67 36

I am just a beginner, I know how to find linear (proc reg) but I don't know how to find the square root and exponential regression (nonlinear regression).

I would be glad if you kindly run these proc's on my data and send the calculation as an example to me.

Posts: 5,056

## Re: Exponential regression and square root model

Here is an example of fitting an exponential function to your data using non-linear regression :

data test;

input y x;

datalines;

3.366 3

3.052 6

2.666 9

2.755 12

2.203 15

1.886 18

1.525 21

1.547 24

0.81 27

0.76 30

0.27 33

0.67 36

;

proc nlin data=test plots=fit;

parameters a=1 b=-1;

model y = a*exp(b*x);

run;

Check out the output listing and the FitPlot graph.

PG

PG
Contributor
Posts: 58

## Re: Exponential regression and square root model

Thank you for your help.

Dearest sir, I run it and it works perfectly for exponential model. It means right now I can run linear model, and exponential model on SAS but what about square root model? I need to run the square model too on my data. Dearest sir, I have to run all these three models (together if possible otherwise separately) for my data using SAS.

*P.S The above exponential method doesn't produce any R2 value.

Many many thanks , kind of you

Posts: 5,056

## Re: Exponential regression and square root model

I don't know what you mean exactly by "square root model" for this data. Please explain. - PG

PG
Super User
Posts: 10,214

## Re: Exponential regression and square root model

Not Sure. Maybe OP means  f(x)=x^2

Posts: 5,056

## Re: Exponential regression and square root model

But look at the data. It is inversly proportional to x.

PG
Contributor
Posts: 58

## Re: Exponential regression and square root model

Here are the equations form of square root model, linear, and exponential. From this plate form with the help of you people I have learnt but now I want to also run square root model. Please have a look at the above picture.

Thanks alot

Solution
‎07-01-2015 11:05 PM
Posts: 5,056

## Re: Exponential regression and square root model

Unfortunately, proc nlin is not very generous in terms of fit diagnostics compared to, say, proc reg. You thus have to do your own calculations, as I did below for the R square and the AIC.

data test;

input y x;

datalines;

3.366 3

3.052 6

2.666 9

2.755 12

2.203 15

1.886 18

1.525 21

1.547 24

0.81 27

0.76 30

0.27 33

0.67 36

;

title "Corrected sum of squares";

proc sql;

select css(y) into :CSSy

from test;

quit;

title "Linear fit";

ods graphics / imagename="LinearFit";

proc nlin data=test plots=fit;

parameters S0=1 b=0;

model y = S0 - b*x;

ods output EstSummary=summLin;

run;

proc sql;

select  N.nValue1 as n format=4.0,

SSE.nValue1 as SSE,

1 - SSE.nValue1/&CSSy as RSquare,

N.nValue1 * log(SSE.nValue1/N.nValue1) + 2*2 as AIC

from summLin as N, summLin as SSE

where N.Label1="Observations Used" and SSE.Label1="Objective";

quit;

title "Exponential fit";

ods graphics / imagename="ExponentialFit";

proc nlin data=test plots=fit;

parameters S0=1 b=0;

model y = S0 * exp( - b*x);

ods output EstSummary=summExp;

run;

proc sql;

select  N.nValue1 as n format=4.0,

SSE.nValue1 as SSE,

1 - SSE.nValue1/&CSSy as RSquare,

N.nValue1 * log(SSE.nValue1/N.nValue1) + 2*2 as AIC

from summExp as N, summExp as SSE

where N.Label1="Observations Used" and SSE.Label1="Objective";

quit;

title """Square root"" fit";

ods graphics / imagename="SquareRootFit";

proc nlin data=test plots=fit;

parameters S0=1 b=0;

model y = (sqrt(S0) - b*x)**2;

ods output EstSummary=summSqrt;

run;

proc sql;

select  N.nValue1 as n format=4.0,

SSE.nValue1 as SSE,

1 - SSE.nValue1/&CSSy as RSquare,

N.nValue1 * log(SSE.nValue1/N.nValue1) + 2*2 as AIC

from summSqrt as N, summSqrt as SSE

where N.Label1="Observations Used" and SSE.Label1="Objective";

quit;

R square and AIC are appropriate for comparing models in this case because the dependent data is the same and the number of fitted parameters is the same for the three models. Turns out that for this data, the linear model fits the best.

PG

PG
Contributor
Posts: 58

## Re: Exponential regression and square root model

Dearest sir,

I can;t express my happiness after running your suggested programming on SAS. It really works and fullfil my needs. I will just say wow excellent sir, hats off to you.

Many many thanks dearest sir.

Contributor
Posts: 58

## Re: Exponential regression and square root model

Dearest sir,

These are the last two models remained. Could make the programming for these above two models too using my data.

In logistic model:

Y = % prey remaining in the stomach

A = estimated parameter

B = scale parameter

C = x-ordinate of the point of inflection of the curve

t = elapsed time after ingestion

In power exponential model:

Y = % prey remaining in the stomach

A = half life of decaying prey

B = shape coefficient

t = elapsed time after ingestion

Many many thanks dearest sir.

Occasional Contributor
Posts: 17

## Re: Exponential regression and square root model

Hi PG Stats,

I am trying to learn about the exponential regression model and was guessing on how you determined the values "a=1 and b=b=-1" (parameters a=1 b=-1. Are they from the dependant variable of the model? Can you please explain that for my understanding? Thank you

Fridge_wpg

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
• 12 replies
• 3068 views
• 8 likes
• 4 in conversation