Date: Wed, 27 Nov 2002 11:14:35 -0800
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: Macro to write many ESTIMATE statements
In-Reply-To: <BCB409391040E040A3B7F77238076C6F0BBF7E@leo.phibred.com>
Content-Type: text/plain; charset=us-ascii
I, too, missed the | symbol indicating a random effects model
being estimated employing the MIXED procedure. I would still
offer the use of the LSMEANS statement with the E option as a
method of generating the linear combination that are desired,
only there would need be a three step approach to building the
coefficients that you need. In the first step, fit the model
with all effects entered as fixed effects. The results for
this model do not need to be obtained. Write out the
LSMEANS coefficients for the terms of interest to a dataset.
The second step reads the LSMEANS coefficient dataset and
constructs the coefficient vectors for each of the estimate
statements, writing out a properly constructed ESTIMATE
statement for each linear combination as a macro variable.
In the third step, PROC MIXED is invoked again, with the proper
random effects specification. The estimate statements which
were written as macro variables are applied.
A shell program would be something like the following:
%macro condlsm(Data=,
Class=,
Response=,
FixedModel=,
RandomModel=,
LSMs=);
ods listing close;
ods output coef=lsmcoef;
proc mixed data=&Data;
class &Class;
model &Response = &FixedModel &RandomModel;
%let i=1;
%do while(%scan(&LSMs,&i,%str( ))^=%str());
lsmeans %scan(&LSMs,&i,%str( )) / e;
%let i=%eval(&i+1);
%end;
run;
data _null_;
set lsmcoef;
<The rest of this code needs to be filled out, but will create>
<the appropriate string for each estimate statement, noting >
<which effects are in the FixedModel macro variable and which >
<effects are in the RandomModel macro variable. The strings >
<are then written to macro variables EST1, EST2, ..., ESTk >
<where k is the number of linear combinations which were >
<generated by the LSMEANS statements in the first invocation >
<of proc mixed. Also, the macro variable K needs to be >
<written. >
run;
ods listing;
proc mixed data=&Data;
class &Class;
model &Response = &FixedModel / s;
random &RandomModel;
%do i=1 %to &k;
&&est&i
%end;
run;
%mend;
Sorry, I don't have time to flesh out the middle step. But this
should not be too hard. If Steve has a need to construct more
estimate statements for other models, then perhaps he would
endeavor to fill out the remainder of the program.
HTH,
Dale
--- "Wall, Steven" <steve.wall@pioneer.com> wrote:
> Dale & John,
>
> First of all, thanks to both of you for taking the time to try and
> help me
> out. Second, let me
> apologize for not telling the whole story in my original request. I
> left
> out some complicating factors that I know will affect Dale's solution
> and
> possibly John's too.
>
> Disclaimer: I'm more of a programmer than a statistician and this
> request
> originated from another person in my group so I don't know all the
> details.
>
> The whole MIXED section of her code looks like this:
>
>
> proc mixed data=era ;
>
> class rng plt dens water hybrid ;
>
> model yield_bu_a_15_ = dens|water rng(water*dens) plt(water*dens)
> ;
>
> random hybrid hybrid*dens hybrid*water hybrid*dens*water /
> solution ;
>
>
>
> Estimate 'hyb1 dens1 water1 new'
>
> intercept
>
> 1
>
> dens
>
> 1 0
>
> water
>
> 1 0 0
>
> dens*water
>
> 1 0 0 0 0 0
>
> |
>
> hybrid
>
> 1 0 0 0 0 0 0 0
>
> hybrid*dens
>
> 1 0 0 0 0 0 0 0
>
> 0 0 0 0 0 0 0 0
>
> hybrid*water
>
> 1 0 0 0 0 0 0 0
>
> 0 0 0 0 0 0 0 0
>
> 0 0 0 0 0 0 0 0
>
> hybrid*dens*water
>
> 1 0 0 0 0 0 0 0
>
> 0 0 0 0 0 0 0 0
>
> 0 0 0 0 0 0 0 0
>
> 0 0 0 0 0 0 0 0
>
> 0 0 0 0 0 0 0 0
>
> 0 0 0 0 0 0 0 0 ;
>
> run;
>
> quit ;
>
>
> As you can see, there is a RANDOM statement in there which I believe
> is the
> reason we can't go with Dale's solution. Effects appearing in an
> LSMEANS (I
> think) must previously appear in the MODEL statement. I don't know
> enough
> about MIXED to know what effect this new information has on John's
> suggestion.
>
> Bottom line is I have been able to write a very pseudo-general macro
> solution for her using PROC IML to generate the ESTIMATE coefficients
> we
> wanted. If you're interested, I could send it to you, but it's
> pretty
> specific so I doubt it has much utility to a general audience.
>
> Again, I appreciate you both taking a stab at this.
>
> sjw
=====
---------------------------------------
Dale McLerran
Fred Hutchinson Cancer Research Center
mailto: dmclerra@fhcrc.org
Ph: (206) 667-2926
Fax: (206) 667-5977
---------------------------------------
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
|