LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2004, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 6 May 2004 17:00:57 -0700
Reply-To:     Dale McLerran <stringplayer_2@YAHOO.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Dale McLerran <stringplayer_2@YAHOO.COM>
Subject:      Re: how to get coefficents alone when using proc genmod?
Comments: To: Chunling Lu <chunling_lu@yahoo.com>
In-Reply-To:  <20040506211621.8516.qmail@web40603.mail.yahoo.com>
Content-Type: text/plain; charset=us-ascii

Chunling,

Rather than writing out the parameter estimates to a dataset and then passing the data values and parameter estimates through PROC SCORE, allow PROC GENMOD to score the data. This is easily done by constructing the data you pass to GENMOD as the combined training (fitting) and testing (scoring) data with training data given a weight of 1 and testing data given a weight of 0. Observations with weight 0 (observations from the data to be scored) will not be used to estimate the parameters of the model. However, if you ask GENMOD to produce an output dataset with predicted values of the response (or simply xbeta), then all observations will be scored regardless of whether they have a zero or nonzero weight. The following code illustrates.

/* Construct training data with variables x and y */ data train; do i=1 to 50; x = ranuni(1234579); y = 3 + 2*x + rannor(1234579); output; end; run;

/* Construct test data with variables x and y */ data test; do i=1 to 25; x = ranuni(1234579); y = 3 + 2*x + rannor(1234579); output; end; run;

/* Combine training and test data into one dataset */ /* Construct weight as an indicator of training data */ data all; set train(in=a) test(in=b); weight = a; run;

/* Fit weighted regression model to data ALL. Note that the */ /* listing indicates only 50 observations used to fit the model. */ proc genmod data=all; weight weight; model y = x; output out=preds pred=yhat xbeta=eta; run;

/* Print scored data. Both training and testing data are scored. */ proc print data=preds; run;

/* Compute residuals for all observations */ data preds; set preds; resid = y - yhat; run;

/* Compute residual statistics for training and testing data */ proc means data=preds; class weight; var resid; run;

You will observe that GENMOD employed only 50 observations when fitting the model. You can also see from the residual statistics that the residuals for the training data have mean zero while the residuals for the testing (scored) data do not have mean zero. This should confirm that GENMOD scored the test data without using the test data to fit the model.

I believe this is easier than PROC SCORE. Others may disagree, but this is the approach which I would employ.

Dale

--- Chunling Lu <chunling_lu@YAHOO.COM> wrote: > Hi all, > > I would like to get an coefficient estimates set from "proc genmod" > and then apply this set to another data by using "proc score". I know > in "proc reg", we may use "outest" to get estimates alone. I used > ODS in proc genmod and get infomration of coefficients. I then delete > some unwanted information (such as std, CI, etc), and use the > estimates in "proc score", however, it didn't work. Can anybody give > some hints? > > Thanks in advance. > > Chunling > > > > > --------------------------------- > Do you Yahoo!? > Win a $20,000 Career Makeover at Yahoo! HotJobs

===== --------------------------------------- Dale McLerran Fred Hutchinson Cancer Research Center mailto: dmclerra@fhcrc.org Ph: (206) 667-2926 Fax: (206) 667-5977 ---------------------------------------

__________________________________ Do you Yahoo!? Win a $20,000 Career Makeover at Yahoo! HotJobs http://hotjobs.sweepstakes.yahoo.com/careermakeover


Back to: Top of message | Previous page | Main SAS-L page