[ADMB Users] example

dave fournier otter at otter-rsch.com
Fri Apr 23 09:03:00 PDT 2010


I see that at the ADMB meeting there was discussion about examples etc.
Here is an example from the R list.  It is supposed to show that a
linear mixed model
with only 4 levels of the random effect is a bad idea, ostensibly
because  lmer
does not perform well.  You can find the discussion at.
 
https://stat.ethz.ch/pipermail/r-sig-mixed-models/2010q2/003713.html

I think the main point is at
Random effects:
 Groups   Name        Variance Std.Dev.
 fac      (Intercept) 1.1162   1.0565
 Residual             1.0298   1.0148

where the estimate for the std dev of the random effects is 1.0565 while
the value used for simulating the data was 4.0.

I suspect that the real problem is with the  mediocre estimation methods
used in lmer. I built the model in ADMBRE
and estimated the parameters.  The estimate for sigma_u  was 3.8290
  4   sigma_u  3.8290e+00 1.3538e+00

Here is the TPL file.  Note that I sorted the R ouput data by factor
value i.e by random effect index.


DATA_SECTION
  init_int n
  init_int m
  int nm
 !! nm=n*m;
  vector y
  vector x
  init_matrix data(1,nm,1,3)
 !! y=column(data,1);
 !! x=column(data,2);
PARAMETER_SECTION
  init_number a
  init_number b
  init_bounded_number sigma(.1,10.)
  init_bounded_number sigma_u(.1,10.)
  random_effects_vector u(1,m)
  objective_function_value f
PROCEDURE_SECTION
  int ii=0;
  for (int i=1;i<=m;i++)
  {
    f1(a,b,u(i),sigma,sigma_u,ii);
  }
                                                           
SEPARABLE_FUNCTION void f1(const prevariable& a,const prevariable&
b,const prevariable& ui,const prevariable& sigma,const prevariable&
sigma_u,int& ii)

  dvariable v=square(sigma);
  f+=0.5*square(ui);
  for (int j=1;j<=n;j++)
  {
    ii++;
    dvariable pred=a+b*x(ii)+sigma_u*ui;
    dvariable diff=y(ii)-pred;
    f+=log(sigma)+0.5*square(diff)/v;
  }

I wonder if the R experts are interested?









More information about the Users mailing list