BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
marcioadg
Calcite | Level 5

Folks,

I want to fit a model in which the random effects are 'experiment' and 'block(experiment)'  in NLMIXED. Since NLMIXED does not accept two random statements, it is possible to do it in one. However, the challenge is the nesting. In the Littell 2006 book they describe it briefly, but I am not sure how to apply here.

Could anyone please help me with that? There are some parts of the code below that are completely wrong and I am not sure how to fix it;

Thanks a lot!

Marcio

%let nexp = 7214  ;

%let nblock = 39;

data growth;

do exp = 1 to &nexp;

err1 = 3*rannor(339205); *No idea what is this;

do block = 1 to &nblock;

err2 = 2*rannor(0);

ADG12M = 970 + err1 + err2 ;  *No idea what is this;

output;

end;

end;

end;

run;

proc nlmixed data=growth start ;                                                                                    

  title2 'Linear broken line';                                                                                                   

  bounds .145<R<.245;

  array aeffect { 1 };

    array beffect {&nblock };

  parms L= 970  U=-1000 R=.20 .21 s2e=100 1071 2000 ;                                                                                       

  z1=(x<R)*(R-x);       

  mean = L + U *(z1) + expffect{1} + blockeffect{B};

  model ADG12M ~ normal(mean, s2e);                                                                                              

    random eeff beff ~ Normal([0,0], [expvar, 0, blockvar]) subject=exp   out=blups;                               

  predict L + U*(z1) out=ppp;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
marcioadg
Calcite | Level 5

Steve, thanks a lot for the help! I was not able to update my sas right now. But I got it using the code below,

Thanks,

Marcio

proc nlmixed data=dataname start hess corr cov itdetails df=18;

array eeffect { 1 }; 

    array beffect { 6 }; 

  parms b0=190 b1=[.define all parms..]

    mean = b0 + b1*x + b2*x*x + eeffect{1} + beffect{block};

  model y ~ normal(mean, s2e);                                                                                              

    random eeffect1 beffect1 beffect2 beffect3 beffect4 beffect5 beffect6  ~

    Normal([0,0,0,0,0,0,0],

    [expvar,

    0, b_evar,

    0,0, b_evar,

    0,0,0, b_evar,

    0,0,0,0, b_evar,

    0,0,0,0,0, b_evar,

    0,0,0,0,0,0, b_evar]) subject=exp out=blups; *;                                                            

  predict b0 + b1*x + b2*x*x out=ppp;

run;

View solution in original post

4 REPLIES 4
SteveDenham
Jade | Level 19

Hey Marcio,

I'll attack the data generation part first.  The first "no idea" generates a random normal, using a seed of 339205.  It could be anything for the seed, and it is older code.  Newer syntax would use rand('NORMAL') to generate a mean=0, sd=1 value.  It's multiplied by 3 to give the residual error variance component as 9 times the block variance component.  The second (ADGM12=) adds a fixed value (970) for the mean to the two values to give the dependent variable.

In the NLMIXED code, it looks like there are some undefined variables in the parms statement.  Something should be set equal to 1071 and something else to 2000 as starting values. In addition eeff and beff should be linked into expleffect and blockeffect somehow, and expvar and blockvar also defined (these latter two might be the missing parts in the parms statement).

Hope this helps you get started.

Steve Denham

SteveDenham
Jade | Level 19

Marcio,

What version of SAS/STAT are you using?  If you have SAS/STAT13.2 access, all of this can be handled directly now.  If you have 13.2, take a look at Example 70.7 Overdispersion Hierarchical Nonlinear Mixed Model.

Hope you have it (or can get upgrade).

Steve Denham

marcioadg
Calcite | Level 5

Steve, thanks a lot for the help! I was not able to update my sas right now. But I got it using the code below,

Thanks,

Marcio

proc nlmixed data=dataname start hess corr cov itdetails df=18;

array eeffect { 1 }; 

    array beffect { 6 }; 

  parms b0=190 b1=[.define all parms..]

    mean = b0 + b1*x + b2*x*x + eeffect{1} + beffect{block};

  model y ~ normal(mean, s2e);                                                                                              

    random eeffect1 beffect1 beffect2 beffect3 beffect4 beffect5 beffect6  ~

    Normal([0,0,0,0,0,0,0],

    [expvar,

    0, b_evar,

    0,0, b_evar,

    0,0,0, b_evar,

    0,0,0,0, b_evar,

    0,0,0,0,0, b_evar,

    0,0,0,0,0,0, b_evar]) subject=exp out=blups; *;                                                            

  predict b0 + b1*x + b2*x*x out=ppp;

run;

SteveDenham
Jade | Level 19

Cool!  Now I have code to steal, er, borrow.

Steve Denham

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 4 replies
  • 2236 views
  • 3 likes
  • 2 in conversation