Stata Code Fragment: 
Reading and Analyzing the Hospital Doctor Patient Dataset

You can read the Hospital Doctor Patient Dataset into Stata and run many linear and generalized linear mixed effects models into Stata using this code. The output is not included, but the syntax is. For more details on the dataset, you should see the original R page that simulates the data HDP Simulation.


*Grab the most recent version from the internet
insheet using "http://www.ats.ucla.edu/stat/data/hdp.csv", comma

foreach i of varlist familyhx smokinghx sex cancerstage school {
  encode `i', gen(`i'2)
  drop `i'
  rename `i'2 `i'
}

xtmixed tumorsize i.familyhx lengthofstay i.cancerstage i.smokinghx##c.age || did: lengthofstay

xtmixed co2 i.familyhx lengthofstay i.cancerstage i.smokinghx##c.age || did: lengthofstay

xtmixed pain i.sex c.il6##c.crp || did:

xtmixed wound rbc i.married##i.sex experience || hid: || did: rbc

xtmixed mobility age bmi experience i.school lawsuits medicaid || hid: || did:

xtmepoisson ntumors age c.bmi##i.familyhx lengthofstay il6 crp i.cancerstage c.experience##i.cancerstage || hid: || did:

xtmepoisson nmorphine age i.sex lengthofstay bmi i.cancerstage || did: bmi

xtmelogit remission age lengthofstay i.familyhx il6 crp i.cancerstage experience || hid: || did: lengthofstay

*not technically correct, should be a logit link with a beta distribution
xtmelogit lungcapacity rbc c.il6#c.crp i.smokinghx##i.familyhx experience i.school || did:

How to cite this page

Report an error on this page or leave a comment

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.