stata$in$the$everyday$life$of$a$ health$economist · blog •...

33
Stata in the everyday life of a health economist Pedro Pita Barros 1

Upload: others

Post on 07-Jun-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

Stata  in  the  everyday  life  of  a  health  economist  

Pedro  Pita  Barros  

1  

Page 2: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

Stata  and  me:  what  I  do?  

•  Research  ar7cles  •  Books  •  Data  management  •  Blog  and  other  things  

2  

Page 3: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

Blog  •  Need  treatment  of  simple  data,  usually  small  samples  

•  Problem:  they  are  in  a  variety  of  formats  •  Solu7on:  import  from  Excel  files  has  become  the  easier  solu7on  –  most  data  sources  now  have  this  possibility  –  Sta7s7cs  Portugal,  Pordata,  AMECO  /  Eurostat,  OECD  Health  Data  

•  Problem:  formaOng  changes  from  7me  to  7me    •  Solu7on:  import  to  “my”  Excel  format,  which  is  read  by  Stata  easily  

3  

Page 4: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

4  

Page 5: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

5  

Page 6: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

•  Next  step:  export  outputs  •  Graph  tools  from  Stata  are  great  –  high  degree  of  flexibility;  standard  “schemes”  are  fine  (though  beYer  in  color  than  black/white)  

•  Export  format  is  ok  (png  works  well  with  wordpress)  

 

6  

Page 7: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

7  

Page 8: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

8  

500

1000

1500

2000

Jan-12 Jul-12 Jan-13 Jul-13 Jan-14 Jul-14 Jan-15 Jul-15Mês-Ano

Dívida Dez2011/Mai2012Jan/Out2013 Dez2013/Ago2014Set/Nov2014 Dez2014/Fev2015Fev/Jul2015

Page 9: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

•  Expor7ng  tables  of  regressions  –  could  be  easier  –  user-­‐made  commands  help,  but  are  not  perfect  for  html/blog  

•  Print  screens  look  nice  graphically  but  not  easy  to  read  

•  Wish:  have  direct  export  to  html  (the  copy  table  as  html  does  not  work  well  in  my  Mac)  

9  

Page 10: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

10  

Page 11: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

•  Version:0.9  

•  StartHTML:0000000105  

•  EndHTML:0000001132  

•  StartFragment:0000000136  

•  EndFragment:0000001099  

•  <HTML><BODY><!-­‐-­‐StartFragment-­‐-­‐><TABLE  BORDER><tr><td>.  esYab  m1  m2,  b  not  

•  (1)                          (2)        •  divida_epe            divida_epe        

•  tend1                              80.42***                80.42***  •  tend2                            -­‐190.5***              -­‐190.5***  •  tend3                              34.07***                                  •  tend4                              28.47*                                      •  tend5                            -­‐8.370                                        •  tend6                              41.56                                        •  tend7                            -­‐1.611                                        •  ct1                                  554.7                      554.7        •  ct2                                5406.7***              5406.7***  •  ct3                                -­‐152.8                    -­‐96.77        •  ct4                                  825.0***                825.0***  •  ct5                                -­‐430.7                    -­‐583.9*      •  ct6                                1206.6                      941.9        •  ct7                              -­‐1472.3                  -­‐1004.6**    •  ct8                                  613.8                      674.7        •  tend346                                                          32.20***  •  tend57                                                          -­‐2.737        

•  N                                            44                            44        

•  *  p<0.05,  **  p<0.01,  ***  p<0.001  •  </td></tr></TABLE><!-­‐-­‐EndFragment-­‐-­‐></BODY></HTML>  

11  

Page 12: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

Data  management  

•  Management  of  large  data  sets  – Volume  of  data  –  3,3  million  observa7ons  per  month,  24  months  –  using  cycles  in  “do  files”,  size  of  joint  database  is  very  large  (each  file  about  168-­‐180  MB)  

–  Joining  repeated  cross-­‐sec7ons  –  Ex:  Standard  Income  and  Living  Condi7ons  –  Eurostat  

– Merging  different  data  sets  (ex:  individual  hospital  admissions  with  residen7al  data)  

12  

Page 13: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

13  

Page 14: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

14  

Average  price  per  day,  each  month  from  a  different  file    All  data  in  a  single  file    makes  it  very  slow  (close  to  2,5  GB)    

Page 15: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

Research  papers  

•  Use  of  regression  models  available  •  Flexibility  for  new  likelihood  func7ons  •  New  commands  available  •  User-­‐built  commands  

15  

Page 16: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

Example  

16  

-­‐  Health  –  latent  variable  –  5  states  -­‐  Pharma  consump7on  (yes/no)  -­‐  Visits  to  doctor  –  number  of  visits  –  count  variable  

Page 17: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

17  

Page 18: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

18  

Page 19: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

19  

Page 20: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

20  

About  11,000  observa7ons;  2  itera7ons  takes  roughly  5  hours  

Page 21: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

Results  

21  

Page 22: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

22  

Page 23: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

23  

Our  interest:  role  of  subsystems  –  impact  on  number  of  visits,  but  not  pharma    or  health  directly  

Page 24: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

•  Problems:  a  “do  file”  that  runs  in  Stata  13  does  not  in  Stata  14  –  not  easy  to  find  out  why…  

•  Look  for  more  efficient  coding  to  reduce  7me  to  solve  the  problem  

24  

Page 25: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

New  commands  

•  Example:    – Treatment  effects  –  matching  es7mator  (new  command)  

– Krls  –  user  command  for  machine-­‐learning  technique  to  fit  non-­‐linear  func7on  

– Tradi7onal  regression  •  Suicides  during  the  crisis  period  

25  

Page 26: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

What  happened  

26  

46

810

12suicidio_ine

1980 1990 2000 2010 2020ano

Page 27: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

Aver  2004  (5  years  each  side)  

27  

46

810

12suicidio_ine

1980 1990 2000 2010 2020ano

Page 28: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

28  

Page 29: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

29  

89

1011

12

2004 2006 2008 2010 2012 2014ano

Linear prediction s2suicidio_ine

Non-­‐significant  differences  –  the  three  methods  are  roughly  giving  the  same  info  

Page 30: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

Go  back  10  years:  since  1994    

30  

46

810

12suicidio_ine

1980 1990 2000 2010 2020ano

Page 31: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

31  

Impact  of  crisis  –  there  are  differences  but  not  too    different  

Page 32: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

32  

-10

010

2030

1995 2000 2005 2010 2015ano

Linear prediction s2_93suicidio_ine

We  look  at  predicted  effect  –  the  krls  is  wildly  non-­‐linear  (unreasonable  so)  

Page 33: Stata$in$the$everyday$life$of$a$ health$economist · Blog • Need!treatmentof!simple!data,!usually!small! samples! • Problem:!they!are!in!avariety!of!formats! • Solu7on:!importfrom!Excel!files!has!become!the!

Stata  in  the  life  of  a  health  economist  

•  Helpful  in  many  ways  •  Could  be  improved  to  interact  with  new  social  media    

•  Works  very  well  for  management  of  large  data  sets  (speed  can  be  an  issue)  

•  Flexible  enough  to  accommodate  new  models  /  likelihood  func7ons  

•  Great  to  test  different  technique  using  both  official  and  community-­‐based  commands  

33