
. 
. * MKTBOX2.DO *
. 
. * Program for analyzing data for revision of movie project with David Reinste
> in *
. * Regressions involving total market box office in weekend. Reads in and merg
> es new data *
. * Version for second revise and resubmit for JIE
. 
. set more 1

. set mat 200

. set mem 20m
(20480k)

. 
. use movie

. 
. * Complicated merge. Total market box office may be weekend or some other day
>  in week.
. * So need to do a series of merges to take care of the problem
. 
. * start complicated merge here
. 
. gen weekend = opendate + 6 - openwday

. 
. gen x4 = weekend

. gen x3 = x4 - 1

. gen x2 = x3 - 1

. gen x1 = x2 - 1

. 
. keep x1 x2 x3 x4 weekend

. 
. sort weekend

. 
. drop if weekend[_n] == weekend[_n-1]
(287 observations deleted)

. 
. reshape long x, i(weekend) j(temp)
(note:  j = 1 2 3 4)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                      361   ->    1444
Number of variables                   5   ->       3
j variable (4 values)                     ->   temp
xij variables:
                           x1 x2 ... x4   ->   x
-----------------------------------------------------------------------------

. 
. sort x

. 
. keep weekend x

. 
. save chris1, replace
file chris1.dta saved

. 
. clear

. 
. use movie

. 
. gen weekend = opendate + 6 - openwday

. 
. sort weekend

. 
. save chris2, replace
file chris2.dta saved

. 
. clear

. 
. infile x mktbox using mktbox.txt
(361 observations read)

. 
. sort x

. 
. merge x using chris1

. 
. drop if _merge~=3
(1083 observations deleted)

. 
. drop x _merge

. 
. sort weekend

. 
. merge weekend using chris2

. 
. * end complicated merge here
. 
. gen oscar  = 0

. replace oscar = 1 if oscarmaj > 0 | oscarmin > 0
(27 real changes made)

. 
. gen lwk1cpi  = ln(wk1cpi)

. gen wk1per   = wk1cpi / openscr

. gen lwk1per  = ln(wk1per)

. gen boxres   = grosscpi - wk1cpi

. gen lboxres  = ln(boxres)

. gen boxresp  = boxres / openscr

. gen lboxresp = ln(boxresp) 

. gen openper  = wk1cpi / grosscpi

. gen lgross   = ln(grosscpi)

. gen mbcpi    = mktbox * grosscpi / gross

. gen lmbcpi  = ln(mbcpi)

. 
. drop if pre == 1
(39 observations deleted)

. 
. 
. * Generate market variables
. 
. sort weekend

. 
. egen num    = count(lmbcpi), by(weekend)

. egen numaft = sum(aft), by(weekend)

. egen numdur = sum(dur), by(weekend)

. egen numou  = sum(ou), by(weekend)

. egen numuu  = sum(uu), by(weekend)

. egen numoud = sum(oudur), by(weekend)

. egen numoua = sum(ouaft), by(weekend)

. egen numuud = sum(uudur), by(weekend)

. egen numuua = sum(uuaft), by(weekend)

. egen numscr = sum(openscr), by(weekend)

. egen nummalt = sum(maltin), by(weekend)

. egen numvote = sum(votes), by(weekend)

. egen samgros = sum(wk1cpi), by(weekend)

. egen numact  = sum(action), by(weekend)

. egen numdram = sum(drama), by(weekend)

. egen numcom  = sum(comedy), by(weekend)

. 
. gen numupd = numoud + numuud

. gen numupa = numoua + numuua

. 
. sort weekend

. 
. drop if weekend[_n] == weekend[_n-1]
(262 observations deleted)

. 
. gen ratio = samgros/mbcpi

. gen resid = mbcpi-samgros

. gen lresid = ln(resid)
(1 missing value generated)

. 
. summ ratio

Variable |     Obs        Mean   Std. Dev.       Min        Max
---------+-----------------------------------------------------
   ratio |     347    .1914716   .1591611   .0105094   2.196551  

. 
. summ samgros

Variable |     Obs        Mean   Std. Dev.       Min        Max
---------+-----------------------------------------------------
 samgros |     347    1.16e+07    9662392     313594   6.30e+07  

. 
. drop if ratio > 1
(1 observation deleted)

. 
. * Weekend market box office 
. 
. *reg lresid numdur numoud numuud numou numuu fourday num numact numdram numco
> m month1-month11 year2-year9 numscr nummalt numvote, robust
. reg lresid numdur numoud numuud numou numuu fourday month1-month11 year2-year
> 9 numscr nummalt, robust

Regression with robust standard errors                 Number of obs =     346
                                                       F( 27,   318) =   44.19
                                                       Prob > F      =  0.0000
                                                       R-squared     =  0.6772
                                                       Root MSE      =  .19122

------------------------------------------------------------------------------
         |               Robust
  lresid |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
  numdur |    .009733   .0251805      0.387   0.699      -.0398084    .0592744
  numoud |   .0265092     .04217      0.629   0.530      -.0564583    .1094767
  numuud |  -.0829835   .0556049     -1.492   0.137      -.1923835    .0264165
   numou |  -.0330524   .0392053     -0.843   0.400      -.1101869    .0440821
   numuu |   .0704449   .0545774      1.291   0.198      -.0369335    .1778233
 fourday |   .3118941   .0523473      5.958   0.000       .2089033    .4148849
  month1 |   .1395864   .0655304      2.130   0.034       .0106586    .2685143
  month2 |   .0578058   .0636655      0.908   0.365       -.067453    .1830646
  month3 |  -.0404306   .0570715     -0.708   0.479      -.1527161    .0718548
  month4 |  -.0875128   .0607724     -1.440   0.151      -.2070795     .032054
  month5 |  -.1597064   .0701147     -2.278   0.023      -.2976536   -.0217591
  month6 |   .1031174   .0671695      1.535   0.126      -.0290353      .23527
  month7 |   .3643051    .059991      6.073   0.000       .2462756    .4823345
  month8 |   .2208893   .0593307      3.723   0.000        .104159    .3376195
  month9 |  -.2061797   .0594888     -3.466   0.001      -.3232211   -.0891383
 month10 |  -.1239479   .0595721     -2.081   0.038      -.2411532   -.0067427
 month11 |   .0714836   .0786595      0.909   0.364      -.0832751    .2262423
   year2 |   .1612261   .0360965      4.467   0.000        .090208    .2322442
   year3 |   .1902718   .0481657      3.950   0.000        .095508    .2850355
   year4 |   .2675357    .041722      6.412   0.000       .1854495    .3496218
   year5 |   .3316543   .0356402      9.306   0.000       .2615339    .4017746
   year6 |   .4158512   .0402135     10.341   0.000       .3367331    .4949693
   year7 |   .4591026   .0375553     12.225   0.000       .3852144    .5329908
   year8 |     .58407   .0427959     13.648   0.000       .4998712    .6682688
   year9 |   .7230445   .0419413     17.239   0.000        .640527    .8055621
  numscr |  -.0000404    .000014     -2.883   0.004       -.000068   -.0000128
 nummalt |  -.0073492   .0132352     -0.555   0.579      -.0333889    .0186905
   _cons |   17.35785   .0585115    296.657   0.000       17.24273    17.47297
------------------------------------------------------------------------------

. 
. test year2 year3 year4 year5 year6 year7 year8 year9

 ( 1)  year2 = 0.0
 ( 2)  year3 = 0.0
 ( 3)  year4 = 0.0
 ( 4)  year5 = 0.0
 ( 5)  year6 = 0.0
 ( 6)  year7 = 0.0
 ( 7)  year8 = 0.0
 ( 8)  year9 = 0.0

       F(  8,   318) =   45.30
            Prob > F =    0.0000


. test month1 month2 month3 month4 month5 month6 month7 month8 month9 month10 m
> onth11

 ( 1)  month1 = 0.0
 ( 2)  month2 = 0.0
 ( 3)  month3 = 0.0
 ( 4)  month4 = 0.0
 ( 5)  month5 = 0.0
 ( 6)  month6 = 0.0
 ( 7)  month7 = 0.0
 ( 8)  month8 = 0.0
 ( 9)  month9 = 0.0
 (10)  month10 = 0.0
 (11)  month11 = 0.0

       F( 11,   318) =   33.61
            Prob > F =    0.0000


. *test num numact numdram numcom
. 
. ********************************************************
. * Now redo everything in terms of means rather than sums
. ********************************************************
. 
. clear

. 
. use movie

. 
. * Complicated merge. Total market box office may be weekend or some other day
>  in week.
. * So need to do a series of merges to take care of the problem
. 
. * start complicated merge here
. 
. gen weekend = opendate + 6 - openwday

. 
. gen x4 = weekend

. gen x3 = x4 - 1

. gen x2 = x3 - 1

. gen x1 = x2 - 1

. 
. keep x1 x2 x3 x4 weekend

. 
. sort weekend

. 
. drop if weekend[_n] == weekend[_n-1]
(287 observations deleted)

. 
. reshape long x, i(weekend) j(temp)
(note:  j = 1 2 3 4)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                      361   ->    1444
Number of variables                   5   ->       3
j variable (4 values)                     ->   temp
xij variables:
                           x1 x2 ... x4   ->   x
-----------------------------------------------------------------------------

. 
. sort x

. 
. keep weekend x

. 
. save chris1, replace
file chris1.dta saved

. 
. clear

. 
. use movie

. 
. gen weekend = opendate + 6 - openwday

. 
. sort weekend

. 
. save chris2, replace
file chris2.dta saved

. 
. clear

. 
. infile x mktbox using mktbox.txt
(361 observations read)

. 
. sort x

. 
. merge x using chris1

. 
. drop if _merge~=3
(1083 observations deleted)

. 
. drop x _merge

. 
. sort weekend

. 
. merge weekend using chris2

. 
. * end complicated merge here
. 
. gen oscar  = 0

. replace oscar = 1 if oscarmaj > 0 | oscarmin > 0
(27 real changes made)

. 
. gen lwk1cpi  = ln(wk1cpi)

. gen wk1per   = wk1cpi / openscr

. gen lwk1per  = ln(wk1per)

. gen boxres   = grosscpi - wk1cpi

. gen lboxres  = ln(boxres)

. gen boxresp  = boxres / openscr

. gen lboxresp = ln(boxresp) 

. gen openper  = wk1cpi / grosscpi

. gen lgross   = ln(grosscpi)

. gen mbcpi    = mktbox * grosscpi / gross

. gen lmbcpi  = ln(mbcpi)

. 
. drop if pre == 1
(39 observations deleted)

. 
. 
. * Generate market variables
. 
. sort weekend

. 
. egen num    = count(lmbcpi), by(weekend)

. egen mnaft = mean(aft), by(weekend)

. egen mndur = mean(dur), by(weekend)

. egen mnou  = mean(ou), by(weekend)

. egen mnuu  = mean(uu), by(weekend)

. egen mnoud = mean(oudur), by(weekend)

. egen mnoua = mean(ouaft), by(weekend)

. egen mnuud = mean(uudur), by(weekend)

. egen mnuua = mean(uuaft), by(weekend)

. egen mnscr = mean(openscr), by(weekend)

. egen mnmalt = mean(maltin), by(weekend)

. egen mnvote = mean(votes), by(weekend)

. egen samgros = mean(wk1cpi), by(weekend)

. egen mnact  = mean(action), by(weekend)

. egen mndram = mean(drama), by(weekend)

. egen mncom  = mean(comedy), by(weekend)

. 
. gen mnupd = mnoud + mnuud

. gen mnupa = mnoua + mnuua

. 
. sort weekend

. 
. drop if weekend[_n] == weekend[_n-1]
(262 observations deleted)

. 
. gen ratio = samgros/mbcpi

. gen resid = mbcpi-samgros

. gen lresid = ln(resid)

. 
. summ ratio

Variable |     Obs        Mean   Std. Dev.       Min        Max
---------+-----------------------------------------------------
   ratio |     347    .1195506   .0940685   .0105094   .7321838  

. 
. summ samgros

Variable |     Obs        Mean   Std. Dev.       Min        Max
---------+-----------------------------------------------------
 samgros |     347     7416173    7206219     313594   5.39e+07  

. 
. drop if ratio > 1
(0 observations deleted)

. 
. * Weekend market box office 
. 
. *reg lresid mndur mnoud mnuud mnou mnuu fourday num mnact mndram mncom month1
> -month11 year2-year9 mnscr mnmalt, robust
. reg lresid mndur mnoud mnuud mnou mnuu fourday month1-month11 year2-year9 mns
> cr mnmalt, robust

Regression with robust standard errors                 Number of obs =     347
                                                       F( 27,   319) =   37.87
                                                       Prob > F      =  0.0000
                                                       R-squared     =  0.5392
                                                       Root MSE      =  .26809

------------------------------------------------------------------------------
         |               Robust
  lresid |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
   mndur |   -.026198   .0486293     -0.539   0.590      -.1218728    .0694767
   mnoud |   .0918201   .0697893      1.316   0.189      -.0454854    .2291256
   mnuud |    -.04621   .0794749     -0.581   0.561      -.2025711    .1101511
    mnou |  -.0769167   .0636938     -1.208   0.228      -.2022297    .0483964
    mnuu |   .0884449   .0725394      1.219   0.224      -.0542713     .231161
 fourday |   .2738601   .0609745      4.491   0.000       .1538971     .393823
  month1 |   .0957526   .0651053      1.471   0.142      -.0323375    .2238427
  month2 |   .0464168   .0593799      0.782   0.435      -.0704089    .1632424
  month3 |   -.054722   .0557731     -0.981   0.327      -.1644516    .0550076
  month4 |  -.1043061   .0582909     -1.789   0.074      -.2189893    .0103772
  month5 |  -.1502209   .0668867     -2.246   0.025      -.2818157   -.0186261
  month6 |    .127871   .0661049      1.934   0.054      -.0021857    .2579277
  month7 |   .3425037    .056654      6.046   0.000        .231041    .4539664
  month8 |   .1642257   .0603136      2.723   0.007        .045563    .2828883
  month9 |  -.2064886   .0561721     -3.676   0.000      -.3170032   -.0959739
 month10 |  -.2323286   .1298084     -1.790   0.074      -.4877174    .0230602
 month11 |    .102737   .0716127      1.435   0.152      -.0381558    .2436297
   year2 |   .0429095   .1079782      0.397   0.691      -.1695299    .2553489
   year3 |   .1858644   .0439997      4.224   0.000       .0992981    .2724306
   year4 |   .2596787   .0433123      5.995   0.000       .1744649    .3448924
   year5 |   .3299048   .0405132      8.143   0.000        .250198    .4096115
   year6 |   .4016381   .0455395      8.820   0.000       .3120424    .4912338
   year7 |   .4546334   .0421025     10.798   0.000       .3717997    .5374671
   year8 |    .588267   .0406637     14.467   0.000       .5082642    .6682698
   year9 |   .7114526    .044792     15.883   0.000       .6233276    .7995776
   mnscr |  -.0000419   .0000279     -1.502   0.134      -.0000969     .000013
  mnmalt |  -.0584969   .0439635     -1.331   0.184      -.1449919    .0279982
   _cons |   17.55228   .1267387    138.492   0.000       17.30293    17.80163
------------------------------------------------------------------------------

. 
. test year2 year3 year4 year5 year6 year7 year8 year9

 ( 1)  year2 = 0.0
 ( 2)  year3 = 0.0
 ( 3)  year4 = 0.0
 ( 4)  year5 = 0.0
 ( 5)  year6 = 0.0
 ( 6)  year7 = 0.0
 ( 7)  year8 = 0.0
 ( 8)  year9 = 0.0

       F(  8,   319) =   46.66
            Prob > F =    0.0000


. test month1 month2 month3 month4 month5 month6 month7 month8 month9 month10 m
> onth11

 ( 1)  month1 = 0.0
 ( 2)  month2 = 0.0
 ( 3)  month3 = 0.0
 ( 4)  month4 = 0.0
 ( 5)  month5 = 0.0
 ( 6)  month6 = 0.0
 ( 7)  month7 = 0.0
 ( 8)  month8 = 0.0
 ( 9)  month9 = 0.0
 (10)  month10 = 0.0
 (11)  month11 = 0.0

       F( 11,   319) =   25.94
            Prob > F =    0.0000


. *test num mnact mndram mncom
. 
. 
. *****************************
. * Now do things for Dramas
. * First off, counts
. *****************************
. 
. clear

. 
. use movie

. 
. keep if drama==1
(428 observations deleted)

. 
. * Complicated merge. Total market box office may be weekend or some other day
>  in week.
. * So need to do a series of merges to take care of the problem
. 
. * start complicated merge here
. 
. gen weekend = opendate + 6 - openwday

. 
. gen x4 = weekend

. gen x3 = x4 - 1

. gen x2 = x3 - 1

. gen x1 = x2 - 1

. 
. keep x1 x2 x3 x4 weekend

. 
. sort weekend

. 
. drop if weekend[_n] == weekend[_n-1]
(34 observations deleted)

. 
. reshape long x, i(weekend) j(temp)
(note:  j = 1 2 3 4)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                      186   ->     744
Number of variables                   5   ->       3
j variable (4 values)                     ->   temp
xij variables:
                           x1 x2 ... x4   ->   x
-----------------------------------------------------------------------------

. 
. sort x

. 
. keep weekend x

. 
. save chris1, replace
file chris1.dta saved

. 
. clear

. 
. use movie

. 
. gen weekend = opendate + 6 - openwday

. 
. sort weekend

. 
. save chris2, replace
file chris2.dta saved

. 
. clear

. 
. infile x mktbox using mktbox.txt
(361 observations read)

. 
. sort x

. 
. merge x using chris1

. 
. drop if _merge~=3
(733 observations deleted)

. 
. drop x _merge

. 
. sort weekend

. 
. merge weekend using chris2

. 
. * end complicated merge here
. 
. gen oscar  = 0

. replace oscar = 1 if oscarmaj > 0 | oscarmin > 0
(27 real changes made)

. 
. gen lwk1cpi  = ln(wk1cpi)

. gen wk1per   = wk1cpi / openscr

. gen lwk1per  = ln(wk1per)

. gen boxres   = grosscpi - wk1cpi

. gen lboxres  = ln(boxres)

. gen boxresp  = boxres / openscr

. gen lboxresp = ln(boxresp) 

. gen openper  = wk1cpi / grosscpi

. gen lgross   = ln(grosscpi)

. gen mbcpi    = mktbox * grosscpi / gross
(246 missing values generated)

. gen lmbcpi  = ln(mbcpi)
(246 missing values generated)

. 
. drop if pre == 1
(39 observations deleted)

. 
. 
. * Generate market variables
. 
. sort weekend

. 
. egen num    = count(lmbcpi), by(weekend)

. egen numaft = sum(aft), by(weekend)

. egen numdur = sum(dur), by(weekend)

. egen numou  = sum(ou), by(weekend)

. egen numuu  = sum(uu), by(weekend)

. egen numoud = sum(oudur), by(weekend)

. egen numoua = sum(ouaft), by(weekend)

. egen numuud = sum(uudur), by(weekend)

. egen numuua = sum(uuaft), by(weekend)

. egen numscr = sum(openscr), by(weekend)

. egen nummalt = sum(maltin), by(weekend)

. egen numvote = sum(votes), by(weekend)

. egen samgros = sum(wk1cpi), by(weekend)

. egen numact  = sum(action), by(weekend)

. egen numdram = sum(drama), by(weekend)

. egen numcom  = sum(comedy), by(weekend)

. 
. gen numupd = numoud + numuud

. gen numupa = numoua + numuua

. 
. sort weekend

. 
. drop if weekend[_n] == weekend[_n-1]
(262 observations deleted)

. 
. gen ratio = samgros/mbcpi
(166 missing values generated)

. gen resid = mbcpi-samgros
(166 missing values generated)

. gen lresid = ln(resid)
(167 missing values generated)

. 
. summ ratio

Variable |     Obs        Mean   Std. Dev.       Min        Max
---------+-----------------------------------------------------
   ratio |     181    .2053944   .1868561   .0105094   2.196551  

. 
. summ samgros

Variable |     Obs        Mean   Std. Dev.       Min        Max
---------+-----------------------------------------------------
 samgros |     347    1.16e+07    9662392     313594   6.30e+07  

. 
. drop if ratio > 1
(167 observations deleted)

. 
. * Weekend market box office 
. 
. *reg lresid numdur numoud numuud numou numuu fourday num numact numdram numco
> m month1-month11 year2-year9 numscr nummalt numvote, robust
. reg lresid numdur numoud numuud numou numuu fourday month1-month11 year2-year
> 9 numscr nummalt, robust

Regression with robust standard errors                 Number of obs =     180
                                                       F( 27,   152) =   39.94
                                                       Prob > F      =  0.0000
                                                       R-squared     =  0.7408
                                                       Root MSE      =  .18272

------------------------------------------------------------------------------
         |               Robust
  lresid |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
  numdur |   .0113726    .033961      0.335   0.738      -.0557239    .0784691
  numoud |   .0351921   .0600616      0.586   0.559      -.0834712    .1538553
  numuud |  -.0607395   .0644085     -0.943   0.347      -.1879911     .066512
   numou |  -.0250988    .059496     -0.422   0.674      -.1426447    .0924471
   numuu |   .0113173   .0657361      0.172   0.864       -.118557    .1411917
 fourday |    .300531   .0667665      4.501   0.000       .1686208    .4324412
  month1 |   .0354498   .1004283      0.353   0.725      -.1629657    .2338654
  month2 |  -.0376183   .0899755     -0.418   0.676      -.2153824    .1401458
  month3 |  -.1249498   .0883112     -1.415   0.159      -.2994256    .0495261
  month4 |  -.2034144   .0945949     -2.150   0.033      -.3903049   -.0165239
  month5 |  -.2372479   .1036821     -2.288   0.024      -.4420919   -.0324038
  month6 |  -.0349429   .1155555     -0.302   0.763      -.2632453    .1933594
  month7 |   .3051805   .0963449      3.168   0.002       .1148325    .4955285
  month8 |   .1639328   .0855277      1.917   0.057      -.0050437    .3329093
  month9 |  -.2674675   .0894863     -2.989   0.003       -.444265     -.09067
 month10 |  -.2170037   .0911886     -2.380   0.019      -.3971645    -.036843
 month11 |  -.0982697   .1193159     -0.824   0.411      -.3340014    .1374621
   year2 |   .1430534   .0539962      2.649   0.009       .0363733    .2497334
   year3 |   .2208285   .0669518      3.298   0.001       .0885523    .3531048
   year4 |    .262538   .0556584      4.717   0.000       .1525741    .3725019
   year5 |   .3830111   .0437697      8.751   0.000       .2965355    .4694867
   year6 |   .3749746   .0641514      5.845   0.000       .2482311    .5017181
   year7 |   .4819716   .0505622      9.532   0.000       .3820761    .5818671
   year8 |   .5177764   .0483956     10.699   0.000       .4221616    .6133913
   year9 |   .6903612   .0613097     11.260   0.000       .5692321    .8114904
  numscr |  -.0000246   .0000169     -1.462   0.146      -.0000579    8.65e-06
 nummalt |  -.0192291   .0183418     -1.048   0.296       -.055467    .0170087
   _cons |   17.47136   .0926311    188.612   0.000       17.28835    17.65437
------------------------------------------------------------------------------

. 
. test year2 year3 year4 year5 year6 year7 year8 year9

 ( 1)  year2 = 0.0
 ( 2)  year3 = 0.0
 ( 3)  year4 = 0.0
 ( 4)  year5 = 0.0
 ( 5)  year6 = 0.0
 ( 6)  year7 = 0.0
 ( 7)  year8 = 0.0
 ( 8)  year9 = 0.0

       F(  8,   152) =   25.00
            Prob > F =    0.0000


. test month1 month2 month3 month4 month5 month6 month7 month8 month9 month10 m
> onth11

 ( 1)  month1 = 0.0
 ( 2)  month2 = 0.0
 ( 3)  month3 = 0.0
 ( 4)  month4 = 0.0
 ( 5)  month5 = 0.0
 ( 6)  month6 = 0.0
 ( 7)  month7 = 0.0
 ( 8)  month8 = 0.0
 ( 9)  month9 = 0.0
 (10)  month10 = 0.0
 (11)  month11 = 0.0

       F( 11,   152) =   21.50
            Prob > F =    0.0000


. *test num numact numdram numcom
. 
. ********************************************************
. * Now redo everything in terms of means rather than sums
. ********************************************************
. 
. clear

. 
. use movie

. 
. keep if drama == 1
(428 observations deleted)

. 
. * Complicated merge. Total market box office may be weekend or some other day
>  in week.
. * So need to do a series of merges to take care of the problem
. 
. * start complicated merge here
. 
. gen weekend = opendate + 6 - openwday

. 
. gen x4 = weekend

. gen x3 = x4 - 1

. gen x2 = x3 - 1

. gen x1 = x2 - 1

. 
. keep x1 x2 x3 x4 weekend

. 
. sort weekend

. 
. drop if weekend[_n] == weekend[_n-1]
(34 observations deleted)

. 
. reshape long x, i(weekend) j(temp)
(note:  j = 1 2 3 4)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                      186   ->     744
Number of variables                   5   ->       3
j variable (4 values)                     ->   temp
xij variables:
                           x1 x2 ... x4   ->   x
-----------------------------------------------------------------------------

. 
. sort x

. 
. keep weekend x

. 
. save chris1, replace
file chris1.dta saved

. 
. clear

. 
. use movie

. 
. gen weekend = opendate + 6 - openwday

. 
. sort weekend

. 
. save chris2, replace
file chris2.dta saved

. 
. clear

. 
. infile x mktbox using mktbox.txt
(361 observations read)

. 
. sort x

. 
. merge x using chris1

. 
. drop if _merge~=3
(733 observations deleted)

. 
. drop x _merge

. 
. sort weekend

. 
. merge weekend using chris2

. 
. * end complicated merge here
. 
. gen oscar  = 0

. replace oscar = 1 if oscarmaj > 0 | oscarmin > 0
(27 real changes made)

. 
. gen lwk1cpi  = ln(wk1cpi)

. gen wk1per   = wk1cpi / openscr

. gen lwk1per  = ln(wk1per)

. gen boxres   = grosscpi - wk1cpi

. gen lboxres  = ln(boxres)

. gen boxresp  = boxres / openscr

. gen lboxresp = ln(boxresp) 

. gen openper  = wk1cpi / grosscpi

. gen lgross   = ln(grosscpi)

. gen mbcpi    = mktbox * grosscpi / gross
(246 missing values generated)

. gen lmbcpi  = ln(mbcpi)
(246 missing values generated)

. 
. drop if pre == 1
(39 observations deleted)

. 
. 
. * Generate market variables
. 
. sort weekend

. 
. egen num    = count(lmbcpi), by(weekend)

. egen mnaft = mean(aft), by(weekend)

. egen mndur = mean(dur), by(weekend)

. egen mnou  = mean(ou), by(weekend)

. egen mnuu  = mean(uu), by(weekend)

. egen mnoud = mean(oudur), by(weekend)

. egen mnoua = mean(ouaft), by(weekend)

. egen mnuud = mean(uudur), by(weekend)

. egen mnuua = mean(uuaft), by(weekend)

. egen mnscr = mean(openscr), by(weekend)

. egen mnmalt = mean(maltin), by(weekend)

. egen mnvote = mean(votes), by(weekend)

. egen samgros = mean(wk1cpi), by(weekend)

. egen mnact  = mean(action), by(weekend)

. egen mndram = mean(drama), by(weekend)

. egen mncom  = mean(comedy), by(weekend)

. 
. gen mnupd = mnoud + mnuud

. gen mnupa = mnoua + mnuua

. 
. sort weekend

. 
. drop if weekend[_n] == weekend[_n-1]
(262 observations deleted)

. 
. gen ratio = samgros/mbcpi
(166 missing values generated)

. gen resid = mbcpi-samgros
(166 missing values generated)

. gen lresid = ln(resid)
(166 missing values generated)

. 
. summ ratio

Variable |     Obs        Mean   Std. Dev.       Min        Max
---------+-----------------------------------------------------
   ratio |     181     .100943     .07298   .0105094   .7321837  

. 
. summ samgros

Variable |     Obs        Mean   Std. Dev.       Min        Max
---------+-----------------------------------------------------
 samgros |     347     7416173    7206219     313594   5.39e+07  

. 
. drop if ratio > 1
(166 observations deleted)

. 
. * Weekend market box office 
. 
. *reg lresid mndur mnoud mnuud mnou mnuu fourday num mnact mndram mncom month1
> -month11 year2-year9 mnscr mnmalt, robust
. reg lresid mndur mnoud mnuud mnou mnuu fourday month1-month11 year2-year9 mns
> cr mnmalt, robust

Regression with robust standard errors                 Number of obs =     181
                                                       F( 27,   153) =   18.38
                                                       Prob > F      =  0.0000
                                                       R-squared     =  0.5173
                                                       Root MSE      =  .32441

------------------------------------------------------------------------------
         |               Robust
  lresid |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
   mndur |  -.0406622   .1153467     -0.353   0.725      -.2685399    .1872156
   mnoud |   .1772068   .1578059      1.123   0.263      -.1345529    .4889665
   mnuud |   .0092614   .1627276      0.057   0.955      -.3122218    .3307445
    mnou |  -.1056298   .1359167     -0.777   0.438      -.3741455     .162886
    mnuu |   .0432479    .142953      0.303   0.763      -.2391687    .3256645
 fourday |    .277742   .0725189      3.830   0.000       .1344744    .4210096
  month1 |   .0351726    .112553      0.312   0.755       -.187186    .2575313
  month2 |  -.0317419   .0968531     -0.328   0.744      -.2230839    .1596002
  month3 |  -.0975719   .0906241     -1.077   0.283       -.276608    .0814643
  month4 |   -.189304   .1018299     -1.859   0.065      -.3904781    .0118702
  month5 |  -.2383196   .1172062     -2.033   0.044      -.4698711   -.0067681
  month6 |    .036089   .1375597      0.262   0.793      -.2356726    .3078505
  month7 |   .2405214   .1100311      2.186   0.030       .0231451    .4578978
  month8 |   .1110951   .0999636      1.111   0.268       -.086392    .3085823
  month9 |  -.2316678   .0933929     -2.481   0.014      -.4161739   -.0471617
 month10 |  -.3370688   .1906992     -1.768   0.079      -.7138123    .0396746
 month11 |   .0031481   .1011451      0.031   0.975      -.1966731    .2029694
   year2 |  -.1177593   .2685063     -0.439   0.662      -.6482176    .4126991
   year3 |   .1955313   .0654037      2.990   0.003       .0663204    .3247422
   year4 |   .2693457   .0593383      4.539   0.000       .1521176    .3865737
   year5 |   .3606868   .0572251      6.303   0.000       .2476335    .4737402
   year6 |   .3366098   .0728624      4.620   0.000       .1926635    .4805561
   year7 |   .4310171   .0586631      7.347   0.000        .315123    .5469113
   year8 |   .4686737   .0561186      8.351   0.000       .3578064    .5795411
   year9 |   .6148004   .0723204      8.501   0.000       .4719249    .7576759
   mnscr |   .0000703   .0000507      1.387   0.167      -.0000298    .0001703
  mnmalt |  -.0815362   .0844563     -0.965   0.336      -.2483872    .0853147
   _cons |   17.57161   .2775566     63.308   0.000       17.02327    18.11995
------------------------------------------------------------------------------

. 
. test year2 year3 year4 year5 year6 year7 year8 year9

 ( 1)  year2 = 0.0
 ( 2)  year3 = 0.0
 ( 3)  year4 = 0.0
 ( 4)  year5 = 0.0
 ( 5)  year6 = 0.0
 ( 6)  year7 = 0.0
 ( 7)  year8 = 0.0
 ( 8)  year9 = 0.0

       F(  8,   153) =   18.55
            Prob > F =    0.0000


. test month1 month2 month3 month4 month5 month6 month7 month8 month9 month10 m
> onth11

 ( 1)  month1 = 0.0
 ( 2)  month2 = 0.0
 ( 3)  month3 = 0.0
 ( 4)  month4 = 0.0
 ( 5)  month5 = 0.0
 ( 6)  month6 = 0.0
 ( 7)  month7 = 0.0
 ( 8)  month8 = 0.0
 ( 9)  month9 = 0.0
 (10)  month10 = 0.0
 (11)  month11 = 0.0

       F( 11,   153) =   10.20
            Prob > F =    0.0000


. *test num mnact mndram mncom
. 
. 
end of do-file

. exit, clear
