/*-----------------------------------------------------------------
            S A S   S A M P L E   L I B R A R Y                   
                                                                  
      NAME: MIXEX3                                                
     TITLE: Documentation Example 3 for PROC MIXED                
            Plotting the Likelihood                               
   PRODUCT: STAT, GRAPH                                           
    SYSTEM: ALL                                                   
      KEYS: Mixed Linear Models                                   
     PROCS: MIXED, PRINT, TEMPLATE, SGRENDER                      
      DATA:                                                       
                                                                  
   SUPPORT: Tianlin Wang                                          
       REF:                                                       
      MISC:                                                       
                                                                  
-----------------------------------------------------------------*/

*---------------Plotting the Likelihood-------------*
| The data are from Hemmerle and Hartley (1973) and |
| are used here to construct a data set containing  |
| the likelihood surface.                           |
*---------------------------------------------------*;
data hh;
   input a b y @@;
   datalines;
1 1 237   1 1 254    1 1 246
1 2 178   1 2 179
2 1 208   2 1 178    2 1 187
2 2 146   2 2 145    2 2 141
3 1 186   3 1 183
3 2 142   3 2 125    3 2 136
;
ods output ParmSearch=parms;
proc mixed data=hh asycov mmeq mmeqsol covtest;
   class a b;
   model y = a / outp=predicted;
   random b a*b;
   lsmeans a;
   parms (17 to 20 by .1) (.3 to .4 by .005) (1.0);
run;
proc print data=predicted;
run;
proc template;
   define statgraph surface;
      begingraph;
         layout overlay3d;
            surfaceplotparm x=CovP1 y=CovP2 z=ResLogLike;
         endlayout;
      endgraph;
   end;
run;
proc sgrender data=parms template=surface;
run;