NPavan ☆ India, 2009-01-27 08:53 (5945 d 06:10 ago) Posting: # 3133 Views: 5,900 |
|
Dear all, Can anybody please give me SAS code for calculating quadratic regression equation y=ax2+bx+c using weighting factors 1/x and 1/x2. -- Edit: Category changed. [Helmut] — Regards, Pavan |
d_labes ★★★ Berlin, Germany, 2009-01-27 09:26 (5945 d 05:37 ago) @ NPavan Posting: # 3134 Views: 5,056 |
|
Dear Pavan, have a very short look into the description of the SAS/Stat Proc REG and all your questions will be answered (RTFM in crude net-speak). Then, if you have any specific question, come back. — Regards, Detlew |
NPavan ☆ India, 2009-01-28 12:41 (5944 d 02:21 ago) @ d_labes Posting: # 3153 Views: 5,100 |
|
Dear D.Labes, Thank you for your reply. For the below data, I got the R2 values as follows
X | Y In Analyst Software For Linear equation, 1) Using weighting index=1/x, R2 = 0.9956 2) Using weighting index=1/x2, R2 = 0.9875 3) For Quadratic equation using weighting index=1/x, R2= 0.9984 In SAS Analyst Using Simple Regression For Linear equation, 1) Using weighting index =1/x, R2= 0.5069 2) Using weighting index =1/x2, R2 = 0.2734 3) For quadratic equation using weighting index 1/x, R2 = 0.7925 example for linear equation using weighting index 1/x2 SAS code is *** Simple Regression ***; Note: B=1/x2 Now my questions are, 1) Why my SAS R2 values are different compared to the Analyst R2 values? 2) Is there any mistake in my calculation? Thanks in advance -- Edit: Reformatted using BBCodes. Please don't use tabs in your posts; the result in different browsers is unpredicable. [Helmut] — Regards, Pavan |
d_labes ★★★ Berlin, Germany, 2009-01-28 14:53 (5944 d 00:09 ago) @ NPavan Posting: # 3154 Views: 5,083 |
|
Dear Pavan, ❝ *** Simple Regression ***; ❝ options pageno=1; ❝ proc reg data=Work.Sas; ❝ model Y = B; ❝ run; quit; ❝ note: B=1/x2 ❝ ❝ Now my questions are, ❝ 1) Why my SAS R2 values are different compared to the Analyst R2 values? ❝ 2) Is there any mistake in my calculation? Answer to question 2: Not any, many! Answer to question 1: see answer to question 2. Hint: If you can analyze your data correctly within the 'ANALYST' application in SAS have a look at the code generated by it. It is shown below the analysis results. The emphasis lies on correctly! So use test data with known results. To shorten the process of repeated Q&A here in this forum, which is not a SAS forum: Steps to follow 1. Prepare a dataset with your y and x data. 2. Define an additional variable with the x value squared (f.i. x2=x*x;) 3. Define variables with your weights (f.i. w1=1/x; w2=1/(x*x);) 4. Code:
*linear model BTW: I strongly recommend that you attend a basic SAS course or buy a beginners SAS book! Ok, both are not cheap. So have a look at preceedings of SAS User conferences found here with many beginners lessions. BTW2: For the other members of this forum interested in coding: See the elegant and intuitive way in doing polynomial regression in SAS. In another piece of this great software Proc GLM the same model is written model y=x x*x; Sic!It is a programming language of the 4th generation ![]() — Regards, Detlew |
NPavan ☆ India, 2009-01-29 12:42 (5943 d 02:21 ago) @ d_labes Posting: # 3161 Views: 5,025 |
|
Dear D.Labes, Thank you for your reply. I have one more question, In another data set the R2 values of both linear and quadratic are equal (ie 0.9954) in this situation, How we can identify the best fit? Is there any statistical test to decide which one is the best fit in all best fits of the linear and quadratic. — Regards, Pavan |
Helmut ★★★ ![]() ![]() Vienna, Austria, 2009-01-29 14:54 (5943 d 00:09 ago) @ NPavan Posting: # 3162 Views: 4,946 |
|
Dear Pavan! ❝ In another data set the R2 values of both linear and quadratic ❝ are equal (ie 0.9954) in this situation, ❝ ❝ How we can identify the best fit? R2 (coefficient of determination) and R (coefficient of correlation) are ineffectual decision tools. To identify the best model first prepare a residual plot (x: calculated value, y: residual = calculated - measured):
❝ Is there any statistical test to decide which one is the best fit in all ❝ best fits of the linear and quadratic. In my example you see that correlation is unsuitable; 0.9995 (w=1/x) seems to be better than 0.9994 (w=1/x2). Decision should be based on residuals and back-calculated x-values. The better model may be chosen based on the minimum AIC (Akaike's Information Criterion) which comes up with 149.5 for w=1/x and with 109.9 for w=1/x2. Another possibility would be an F-test. Remember: According to FDA's guideline you have to justify the chosen model during validation. You may remove calibration points (during validation as well as in the study) only as long as the model will not change. — Dif-tor heh smusma 🖖🏼 Довге життя Україна! ![]() Helmut Schütz ![]() The quality of responses received is directly proportional to the quality of the question asked. 🚮 Science Quotes |
NPavan ☆ India, 2009-01-30 13:14 (5942 d 01:49 ago) @ Helmut Posting: # 3166 Views: 4,834 |
|
Dear HS, Thank you for your reply. — Regards, Pavan |