Contributor
Posts: 71

Thanksfor modifying my program that now can produce R^2 too. But I have asked a question many time from PaigeMiller but he (I think he is not receiving the notification) is not answering to my question. Please PaigeMiller answer to my question that the R^2 that is produced with this modification is adjusted R^2 or coefficient of determination (R^2).

Many thanks.

data large;

input sow stw time;

datalines;

4 3.366 3

4 3.052 6

4 2.666 9

4 2.755 12

4 2.203 15

4 1.886 18

1. 3.982 1.525 21
2. 3.882 1.547 24
3. 3.393 0.81 27
4. 3.586 0.76 30
5. 2.295 0.27 33
6. 3.475 0.67 36

;

proc nlin data=large method=marquardt;

parms B=0.5 R=0.1;

delta=0.000001;

s=sow**(1-B)-R*(1-B)*time;

if s>0 then stx=s**(1/(1-B));

else stx=0;

model stw=stx;

sb=(sow**(1-B+delta)-R*(1-B+delta)*time);

if sb>0 then sdb=(stx-sb**(1/(1-B+delta)))/delta;

else sdb=0;

1. der.B=sdb;

sr=(sow**(1-B)-(R-delta)*(1-B)*time);

if sr>0 then sdr=(stx-sr**(1/(1-B)))/delta;

else sdr=0;

1. der.R=sdr;

output out=largep p=pstw;

run;

output out=smallp p=pstw;

to

output out=smallp p=pstw r=stw_residual;

Then, this ought to work (untested code)

proc summary data=smallp;

var stw_residual stw;

output out=stats css(stw)=sstot uss(stw_residual)=ssres;

run;

data final;

set stats;

rsquared=1-(ssres/sstot);

run;

Super User
Posts: 23,700

Its the weekend. He may be on vacation or at the lake but is in no way obligated to answer your question anyways. According to Wikipedia's definition it appears to be the r-squared value.

https://en.m.wikipedia.org/wiki/Coefficient_of_determination

Contributor
Posts: 71

Dear Reeza,

it is clear that the r^2 which produced through this modification is simple r^2. Can you please modify it more with this for adjusted r^2. I need to write adjusted r^2 in my research paper.

Adjusted R2 can  be calculated as 1-[(1-R2)(n-1)(n-k-1)-1]

where n is the number of data points and k is the number of regressors (parameters in your cases)

- and you already now are able to calculate R2.

Thanks

Super User
Posts: 23,700