[R] Convert SAS NLMIXED code for zero-inflated gamma regression to R

a11msp absorbtion at gmail.com
Wed Sep 14 17:27:43 CEST 2011


I'm trying to run a zero-inflated regression for a continuous response
variable in R. I'm aware of a gamlss implementation, but I'd really like to
try out this algorithm by Dale McLerran that is conceptually a bit more
straightforward. Unfortunately, the code is in SAS and I'm not sure how to
re-write it for something like nlme (if at all possible - with conditions
etc). Does anyone know both languages enough to try translating it? Would
very much appreciate your help!

The code is as follows:

proc nlmixed data=mydata;
  parms b0_f=0 b1_f=0 
        b0_h=0 b1_h=0 
        log_theta=0;


  eta_f = b0_f + b1_f*x1 ;
  p_yEQ0 = 1 / (1 + exp(-eta_f));


  eta_h = b0_h + b1_h*x1;
  mu    = exp(eta_h);
  theta = exp(log_theta);
  r = mu/theta;


  if y=0 then
     ll = log(p_yEQ0);
  else
     ll = log(1 - p_yEQ0)
          - lgamma(theta) + (theta-1)*log(y) - theta*log(r) - y/r;


  model y ~ general(ll);
  predict (1 - p_yEQ0)*mu out=expect_zig;
  predict r out=shape;
  estimate "scale" theta;
run;

From: http://listserv.uga.edu/cgi-bin/wa?A2=ind0805A&L=sas-l&P=R20779

Best,
Mikhail

PS. I cross-posted this to stackoverflow under R and SAS - apologies if
you're reading this twice...

==

Mikhail Spivakov, PhD
European Bioinformatics Institute

--
View this message in context: http://r.789695.n4.nabble.com/Convert-SAS-NLMIXED-code-for-zero-inflated-gamma-regression-to-R-tp3813226p3813226.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list