And my original answer today was
@umarkhan You didn't add the r=stw_residual to the PROC NLIN program in the output statement.
The PROC summary should point to this data set instead of the smallp dataset in Paige Miller code.
Full code:
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
3.982 1.525 21
3.882 1.547 24
3.393 0.81 27
3.586 0.76 30
2.295 0.27 33
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;
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;
der.R=sdr;
output out=largep p=pstw r=stw_residual;
run;
proc summary data=largep;
var stw_residual stw;
output out=stats css(stw)=sstot uss(stw_residual)=ssres;
run;
data final;
set stats;
rsquared=1-(ssres/sstot);
run;
Did you read my full code? There no result about R^2 still.
UmarKhan wrote:
Did you read my full code? There no result about R^2 still.
Yes. My original answer was wrong, but you didn't implement it anyways.
Did you open the final dataset?
proc print data=final;run;
It finally works Many thanks to Paige Miller and Reeza. the generated R^2 is Coefficient of determination or adjusted R^2?
Dear Reeza
The R^2 that is produced with this proc modification is adjusted R^2 or coefficient of determination? Please answer.
Dear Paige Miller
The R^2 that is produced with this proc is adjusted R^2 or coefficient of determination? Please answer
Paige Miller sent you a link to a Wikipedia article. If you read the article, you can learn about the R-squared statistic and see that the formula is 1-(SSres/SStot). That same article contains a section about the adjusted R-squared statistic, in the event that you want to compute that statistic as well.
Dear Rick
I try but couldn't fit that formula in it.
Can you please modify it more with this for adjusted r^2. I need to write adjusted r^2 in my research paper.
I took the formula for adjusted R2 and 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.
But I don't have any good knowledge of these programming, that's I need yous help in modifying the program further to produce adjusted r2.
Many thanks for the response.
I feel confident that you can complete this step on your own if you give it a try. Time for you to try to learn some SAS programming! This is an easy computation, so it is a good opportunity for you to practice.
In the DATA step, right after you compute the rsquared variable, define a new variable like this:
adjrsquared = /* put formula here */;
In your formula, use the rsquared variable from the previous line, and substitute values for n and k from your problem. For example, if you have n=100 nonmissing abservations and k=2 parameters in your model, you would use 100 and 2 in the formula.
You should also know that multiplication is performed using the '*' symbol and division by using the '/' symbol. I suggest you use division instead of raising the last quantity to the -1 power. And be sure to end each SAS statement with a semicolon. Good luck!
Si, no result just errors !
proc summary data=expp;
var stw_residual stw;
output out=stats css(stw)=sstot uss(stw_residual)=ssres;
run;
data expp;
set stats;
rsquared=1-(ssres/sstot);
run;
proc print data=expp;
run;
data expp;
adjrsquared = (1-((1-rsquared)(16-2-1)/1));
run;
Multiplication is denoted by *.
No error but no result
data expp;
adjrsquared = (1-(1-rsquared*16-1**16-2-1)/1);
run;
proc print data=expp;
run;
You didn't follow the instructions from Rick.
In the DATA step, right after you compute the rsquared variable, define a new variable like this:
adjrsquared = /* put formula here */;
Add your line In the DATA FINAL step from the working code, not a new data step.
Also, I think your formula is incorrect.
EDIT: I would calculate it by hand and then tweak the program until I generated the correct results.
Additionally, if you go to the SAS Analytics U portion of this site there are FREE training courses on programming in SAS as well as YouTube videos.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.