BookmarkSubscribeRSS Feed
afgdurrani0
Pyrite | Level 9

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;

4 REPLIES 4
Reeza
Super User

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

afgdurrani0
Pyrite | Level 9

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

Reeza
Super User

You have the formula and presumably the n and p. Try modifying the DATA FINAL step in the original code. If you can't get it post what you've tried and I might help.

Rick_SAS
SAS Super FREQ

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 632 views
  • 6 likes
  • 3 in conversation