UCLA Academic Technology Services HomeServicesClassesContactJobs

SAS Code Fragments
Random effect tobit model in nlmixed

The example data for running the following models can be downloaded here.

* right censored;
proc nlmixed data = nls qpoints=15 EBOPT;
  parms  _cons = 1 _age= .01  s2 = .3 sigma = .3;
  xb = _cons  + _age*age + u ;
  if ln_wage <1.8 then  ll = -.5*log(2*constant('PI'))- log(sigma) -(ln_wage-xb)**2/(2*sigma**2);
  if ln_wage >=1.8 then ll = log(1 - cdf('NORMAL', (1.8-xb)/sigma));
  model ln_wage ~ general(ll);
  random u ~ normal (0,s2) subject=id;
run;

* left censored;

proc nlmixed data = nls qpoints=15 EBOPT;
  parms  _cons = 1 _age= .01  s2 = .3 sigma = .3;
  xb = _cons  + _age*age + u ;
  if ln_wage >.5 then  ll = -.5*log(2*constant('PI'))- log(sigma) -(ln_wage-xb)**2/(2*sigma**2);
  if ln_wage <=.5 then ll = log(cdf('NORMAL', (.5-xb)/sigma));
  model ln_wage ~ general(ll);
  random u ~ normal (0,s2) subject=id;
run;

* right and left-censored;
proc nlmixed data = nls qpoints=15 EBOPT;
  parms  _cons = 1 _age= .01  s2 = .3 sigma = .3;
  xb = _cons  + _age*age + u ;
  if ln_wage >.5 & ln_wage < 1.8 then  ll = -.5*log(2*constant('PI'))- log(sigma) -(ln_wage-xb)**2/(2*sigma**2);
  if ln_wage <=.5 then ll = log(cdf('NORMAL', (.5-xb)/sigma));
  if ln_wage >=1.8 then ll = log(1 - cdf('NORMAL', (1.8-xb)/sigma));
  model ln_wage ~ general(ll);
  random u ~ normal (0,s2) subject=id;
run;

How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.