Date: Fri, 17 Oct 2003 11:12:56 -0400
Reply-To: "DePuy, Venita" <depuy001@DCRI.DUKE.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "DePuy, Venita" <depuy001@DCRI.DUKE.EDU>
Subject: Re: R-square from a cubic regression
Just a few opinions on it:
1) Why do you need to use GLM not REG?
Unless I'm missing something, you'll have to define x2 = x**2 and x3
= x**3 in a data step, then you can do:
Proc reg data=datafile outest=outfile;
model y = x1 x2 x3;
2) If you do want to use GLM:
You're trying to get the R2 in output, I think that's the question?
You can do an ODS statement -
ODS output FitStatistics = outfile;
in the GLM code and that will output the R2 to the output file.
3) You can do a similar ODS statement with Proc Reg.
Hope this helps!
> From: Nigel Pain[SMTP:Nigel.Pain@SCOTLAND.GSI.GOV.UK]
> Sent: Friday, October 17, 2003 10:58 AM
> Subject: R-square from a cubic regression
> The following question is from a statistician that I provide IT support
> It doesn't mean a thing to me so I'm just reproducing her query word for
> Simple linear regression we use PROC REG. The model statement is the y=x.
> So its fitting Y=Mx+c
> PROC REG DATA=work.reg11
> OUTEST=work.ncon4l(KEEP=year subject level intercept avoth _rsq_
> LABEL='Concurrent analysis at S4 by subject
> and level') EDF;
> MODEL award=avoth ;
> With the use of the Simple linear regression OUTEST option in PROC REG you
> get the following which is the estimate of the slope and intercept and the
> _RSQ_ VALUE.
> So this is really good
> data from PROC REG
> Obs Intercept slope
> 1 0.36136 1.01971
> However we need to fit a cubic regression with quadratic and linear terms
> and the intercept!! So need to use PROC GLM as PROC REG is not sufficient.
> PROC REG syntax goes as follows where the terms B1 is the linear term, b2
> the quadratic term and B3 is the cubic term
> Y= b1x+ b2x +b3x +c
> proc glm data=work.reg11 outstat=work.model1 ;
> model AWARD=b1 b2 b3 /solution ss1 ;
> quit ;
> run ;
> I would really like the R-square value above and the estimates for
> intercept, b1, b2 and b3.
> The OUTSTAT datasets gives you :-
> Obs _NAME_ _SOURCE_ _TYPE_ DF
> SS F PROB
> 1 AWARD ERROR ERROR 58111
> 47596.19 . .
> 2 AWARD b1 SS1 1
> 103556.33 126433.69 0
> 3 AWARD b2 SS1 1
> 5880.38 7179.46 0
> 4 AWARD b3 SS1 1
> 71.53 87.34 9.4628E-21
> I could calculate the r2 = 103556.33+5880.38+71.53/
> 103556.33+5880.38+71.53+47596.19=0.69, from above SS values but really
> the estimates??!
> I'd like a dataset which comes automatically from the SAS PROCEDURE which
> will contain the estimates and the R squared value from the cubic
> Currently I read in the output as a text file, and find the appropriate
> columns!!!! I've also tried PROC MIXED!!!!
> Nigel Pain
> Scottish Executive
> Analytical Services Team
> Victoria Quay
> EH6 6QQ
> Tel +44 131 244 7237
> Website: http:\\www.scotland.gov.uk <http:\\www.scotland.gov.uk>