
log using impress1.log
use impresss, clear
sort id date HOUSE AUCT_LOC

*transforming variables
gen llow=ln(LOW_EST)
gen lhigh=ln(HIGH_EST)
gen lprice=ln(S_PRICE)
gen year=year(date)
tab year, gen(year)

gen sold=1 if S_PRICE~=.
replace sold=0 if sold==.

gen house=1 if HOUSE=="SO"
replace house=0 if house ==. 
gen loc=1 if AUCT_LOC=="NY"
replace loc=0 if loc==.

egen newsold=mean(sold), by(AUCTION)

sort id date HOUSE AUCT_LOC
replace ARTIST=ARTIST[_n-1] if ARTIST==. & id==id[_n-1] & id~=.
replace ART_MED=ART_MED[_n-1] if ART_MED==. & id==id[_n-1] & id~=.
replace DIM_A=DIM_A[_n-1] if DIM_A==. & id==id[_n-1] & id~=.
replace DIM_B=DIM_B[_n-1] if DIM_B==. & id==id[_n-1] & id~=.
replace SIGNED=SIGNED[_n-1] if SIGNED==. & id==id[_n-1] & id~=.
replace DATE_PTG=DATE_PTG[_n-1] if DATE_PTG==. & id==id[_n-1] & id~=.


replace ARTIST=ARTIST[_n+1] if ARTIST==. & id==id[_n+1] & id~=.
replace ART_MED=ART_MED[_n+1] if ART_MED==. & id==id[_n+1] & id~=.
replace DIM_A=DIM_A[_n+1] if DIM_A==. & id==id[_n+1] & id~=.
replace DIM_B=DIM_B[_n+1] if DIM_B==. & id==id[_n+1] & id~=.
replace SIGNED=SIGNED[_n+1] if SIGNED==. & id==id[_n+1] & id~=.
replace DATE_PTG=DATE_PTG[_n+1] if DATE_PTG==. & id==id[_n+1] & id~=.


replace AUCTION=date if AUCTION==.


egen tabauct=group(AUCTION)


tab tabauct, gen(a)

gen chalk=1 if ART_MED==3
gen charcoal=1 if ART_MED==6
gen crayon=1 if ART_MED==9
gen goache=1 if ART_MED==12
gen ink=1 if ART_MED==15
gen oil=1 if ART_MED==18 | ART_MED==21 | ART_MED==39
gen pastel=1 if ART_MED==24
gen pen=1 if ART_MED==27
gen pencil=1 if ART_MED==30
gen tempura=1 if ART_MED==33
gen wash=1 if ART_MED==36
gen waterc=1 if ART_MED==39
gen other=1 if ART_MED==1 | ART_MED==7 | ART_MED==10 | ART_MED==13 | ART_MED==14
replace other =1 if ART_MED==16 | ART_MED==17 | ART_MED==19 | ART_MED==20 | ART_MED==22
replace other=1 if ART_MED==26 | ART_MED==28 | ART_MED==29 | ART_MED==31 | ART_MED==35
replace other =1 if ART_MED==37 | ART_MED==38 | ART_MED==61 | ART_MED==700
replace chalk=0 if chalk==.
replace charcoal=0 if charcoal==.
replace crayon=0 if crayon==.
replace goache=0 if goache==.
replace ink=0 if ink==.
replace oil=0 if oil==.
replace pastel=0 if pastel==.
replace pen=0 if pen==.
replace pencil=0 if pencil==.
replace tempura=0 if tempura==.
replace wash=0 if wash==.
replace waterc=0 if waterc==.
replace other=0 if other==.

gen Bonnard   =1 if ANAME== "BONNARDPIERRE"
gen Boudin    =1 if ANAME==  "BOUDINEUGENE"
gen Brauner   =1 if ANAME==  "BRAUNERVICTOR"
gen Carriere =1 if ANAME==    "CARRIEREEUGENE"
gen Cezanne  =1 if ANAME==    "CEZANNEPAUL"
gen Chagall  =1 if ANAME==   "CHAGALLMARC"
gen Corot     =1 if ANAME==   "COROTJEANBAPT"
gen Dali      =1 if ANAME==  "DALISALVADOR"
gen Degas     =1 if ANAME==  "DEGASEDGAR"
gen Delvaux  =1 if ANAME==   "DELVAUXPAUL"
gen Derain   =1 if ANAME==   "DERAINANDRE"
gen Dufy_J   =1 if ANAME==     "DUFYJEAN"
gen Dufy_R    =1 if ANAME==   "DUFYRAOUL"
gen Ensor     =1 if ANAME== "ENSORJAMES"
gen Ernst     =1 if ANAME==   "ERNSTMAX"
gen Erte     =1 if ANAME==   "ERTEROMADET" | ANAME=="ERTEROMANDET"
gen Forain   =1 if ANAME==   "FORAINJEANLOU"
gen Foujita  =1 if ANAME==   "FOUJITATSUGHOU"
gen Gauguin   =1 if ANAME==  "GAUGUINPAUL"
gen Gris      =1 if ANAME==  "GRISJUAN"
gen Grosz     =1 if ANAME==  "GROSZGEORG"
gen Guillami=1 if ANAME==   "GUILLAMINJEAN"
gen Helleu   =1 if ANAME==   "HELLEUPAULDES"
gen Kandinsk=1 if ANAME==   "KANDINSKYWASSI"
gen Knopff    =1 if ANAME==  "KHNOPFFFERNAND"
gen Kirchner  =1 if ANAME==  "KIRCHNERERNST"
gen Kisling   =1 if ANAME==  "KISLINGMOISE"
gen Klee     =1 if ANAME==   "KLEEPAUL"
gen Klimt    =1 if ANAME==   "KLIMTGUSTAV"
gen Kokoschk=1 if ANAME==   "KOKOSCHKAOSKAR"
gen Laurenci =1 if ANAME==  "LAURENCINMARIE"
gen Laurens   =1 if ANAME==  "LAURENSHENRI"
gen Leger     =1 if ANAME==  "LEGERFERNAND"
gen Loiseau  =1 if ANAME==   "LOISEAUGUSTAVE"
gen Magritte =1 if ANAME==   "MAGRITTERENE"
gen ManeKatz =1 if ANAME==    "MANEKATZ"
gen Manet     =1 if ANAME==  "MANETEDOUARD"
gen Matisse   =1 if ANAME==  "MATISSEHENRI"
gen Miro      =1 if ANAME==   "MIROJOAN"
gen Modiglia=1 if ANAME==  "MODIGLIANIAMED"
gen Monet    =1 if ANAME==   "MONETCLAUDE"
gen Morisot  =1 if ANAME==   "MORISOTBERTHE"
gen Munch     =1 if ANAME==  "MUNCHEDVARD"
gen Picasso   =1 if ANAME==   "PICASSOPABLO"
gen Pissarro  =1 if ANAME==  "PISSARROCAMILL"
gen Renoir   =1 if ANAME==   "RENOIRPIERREA"
gen Rousseau =1 if ANAME==   "ROUSSEAUHENRI"
gen Severini =1 if ANAME==   "SEVERINIGINO"
gen Signac    =1 if ANAME==  "SIGNACPAUL"
gen Sisley    =1 if ANAME==  "SISLEYALFRED"
gen Toulouse  =1 if ANAME==  "TOULOUSELAUTREC"
gen Utrillo  =1 if ANAME==   "UTRILLOMAURICE"
gen Valtat   =1 if ANAME==   "VALTATLOUIS"
gen vanDonge=1 if ANAME==   "VANDONGENKEES"
gen vanGogh   =1 if ANAME==  "VANGOGHVINCEN"
gen vanRysse  =1 if ANAME==  "VANRYSSELBERGHE"
gen Vlaminck  =1 if ANAME==  "VLAMINCKMAURIC"
gen Vuillard =1 if ANAME==   "VUILLARDEDOUAR"

replace Bonnard =0 if      Bonnard   ==.
replace Boudin  =0  if       Boudin  ==.
replace Brauner =0  if      Brauner  ==.
replace Carriere=0  if      Carriere ==.
replace Cezanne =0  if      Cezanne  ==.
replace Chagall =0  if      Chagall  ==.
replace Corot   =0  if      Corot    ==.
replace Dali    =0  if      Dali     ==.
replace Degas   =0  if      Degas    ==.
replace Delvaux =0  if      Delvaux  ==.
replace Derain  =0  if      Derain   ==.
replace Dufy_J  =0  if      Dufy_J   ==.
replace Dufy_R  =0  if      Dufy_R   ==.
replace Ensor   =0  if      Ensor    ==.
replace Ernst   =0  if      Ernst    ==.
replace Erte    =0  if      Erte     ==.
replace Forain  =0  if      Forain   ==.
replace Foujita =0  if      Foujita  ==.
replace Gauguin =0  if      Gauguin  ==.
replace Gris    =0  if      Gris     ==.
replace Grosz   =0  if      Grosz    ==.
replace Guillami=0  if      Guillami ==.
replace Helleu  =0  if      Helleu   ==.
replace Kandinsk=0  if      Kandinsk ==.
replace Knopff  =0  if      Knopff   ==.
replace Kirchner=0  if      Kirchner ==.
replace Kisling =0  if      Kisling  ==.
replace Klee    =0  if      Klee     ==.
replace Klimt   =0  if      Klimt    ==.
replace Kokoschk=0  if      Kokoschk ==.
replace Laurenci=0  if      Laurenci ==.
replace Laurens =0  if      Laurens  ==.
replace Leger   =0  if      Leger    ==.
replace Loiseau =0  if      Loiseau  ==.
replace Magritte=0  if      Magritte ==.
replace ManeKatz=0  if      ManeKatz ==.
replace Manet   =0  if      Manet    ==.
replace Matisse =0  if      Matisse  ==.
replace Miro    =0  if      Miro     ==.
replace Modiglia=0  if      Modiglia ==.
replace Monet   =0  if      Monet    ==.
replace Morisot =0  if      Morisot  ==.
replace Munch   =0  if      Munch    ==.
replace Picasso =0  if      Picasso  ==.
replace Pissarro=0  if      Pissarro ==.
replace Renoir  =0  if      Renoir   ==.
replace Rousseau=0  if      Rousseau ==.
replace Severini=0  if      Severini ==.
replace Signac  =0  if      Signac   ==.
replace Sisley  =0  if      Sisley   ==.
replace Toulouse=0  if      Toulouse ==.
replace Utrillo =0  if      Utrillo  ==.
replace Valtat  =0  if      Valtat   ==.
replace vanDonge=0  if      vanDonge ==.
replace vanGogh =0  if      vanGogh  ==.
replace vanRysse=0  if      vanRysse ==.
replace Vlaminck=0  if      Vlaminck ==.
replace Vuillard=0  if     Vuillard  ==.




 *Transforming relevant variables for regressions with covariates
 *drop if DATE_PTG==.| DIM_A==. | DIM_B==.


 egen mindate=min(DATE_PTG)
 gen mindat1=mindate-1
 replace DATE_PTG=DATE_PTG-mindat1
gen ldate=ln(DATE_PTG)
gen llen=ln(DIM_A)
 gen lwid=ln(DIM_B)
 gen s1=1 if SIGNED==1
 replace s1=0 if s1==.
 gen s2=2 if SIGNED==2
 replace s2=0 if s2==.
 gen s3=3 if SIGNED==3
 replace s3=0 if s3==.
*drop if S_PRICE==. | lav==.
*Regressions with covariates
*drop if S_PRICE==.
gen LO=1 if AUCT_LOC=="LO"
replace LO=0 if LO==.

gen CH=1 if HOUSE=="CH"

replace CH=0 if CH==.

gen lav=ln((LOW_EST+HIGH_EST)/2)
*drop if hal23==1

drop if hal23==1 
*keep if ldate~=. & llen~=. & lwid~=.

replace lprice=llow+ln(.80) if sold==0
replace S_PRICE=LOW_EST*.80 if sold==0
keep if ldate~=. & llen~=. & lwid~=.

reg lprice ldate llen lwid s1 s2 s3 chalk-waterc Bonnard-Brauner Cezanne-Vlaminck hal2-hal23 if LO==1 


testparm chalk-waterc
testparm Bonnard-Vlaminck
testparm hal2-hal23


predict pprice1 
predict flagl if  e(sample)
predict resid1, resid 
gen index1=_b[hal2]*hal2+_b[hal3]*hal3 +_b[hal4]*hal4+_b[hal5]*hal5+_b[hal6]*hal6+_b[hal7]*hal7+_b[hal8]*hal8 +_b[hal9]*hal9+_b[hal10]*hal10+_b[hal11]*hal11+_b[hal12]*hal12+_b[hal13]*hal13 +_b[hal14]*hal14+_b[hal15]*hal15+_b[hal16]*hal16+_b[hal17]*hal17+_b[hal18]*hal18 +_b[hal19]*hal19+_b[hal20]*hal20+_b[hal21]*hal21+_b[hal22]*hal22+_b[hal23]*hal23 

reg lprice ldate llen lwid s1 s2 s3 chalk-waterc Bonnard-Brauner Cezanne-Vlaminck hal2-hal23 if LO==0 


testparm chalk-waterc
testparm Bonnard-Vlaminck
testparm hal2-hal23
predict flagn if e(sample)
predict pprice2 
predict resid2, resid 
gen index2=_b[hal2]*hal2+_b[hal3]*hal3 +_b[hal4]*hal4+_b[hal5]*hal5+_b[hal6]*hal6+_b[hal7]*hal7+_b[hal8]*hal8 +_b[hal9]*hal9+_b[hal10]*hal10+_b[hal11]*hal11+_b[hal12]*hal12+_b[hal13]*hal13 +_b[hal14]*hal14+_b[hal15]*hal15+_b[hal16]*hal16+_b[hal17]*hal17+_b[hal18]*hal18 +_b[hal19]*hal19+_b[hal20]*hal20+_b[hal21]*hal21+_b[hal22]*hal22+_b[hal23]*hal23 



gen pprice=pprice1 if LO==1
replace pprice=pprice2 if LO==0

gen resid=resid1 if LO==1
replace resid=resid2 if LO==0

  
 




*gen london prices in dollars
gen lS_PRICE=S_PRICE*CNV_RATE
gen lLOW_EST=LOW_EST*CNV_RATE
gen lHIGH_EST=HIGH_EST*CNV_RATE
gen predp=exp(pprice)


sum HOUSE   lS_PRICE ANAME lLOW_EST lHIGH_EST DIM_A DIM_B predp if flagl~=.

sum HOUSE   S_PRICE ANAME LOW_EST HIGH_EST DIM_A DIM_B predp if flagn~=.

sum sold if flagl>lprice & flagl~=.

sum sold if flagn>lprice & flagn~=.


sort id date HOUSE AUCT_LOC

gen luscpi=ln(uscpi)
gen lukcpi=ln(ukcpi)
gen difus=-luscpi+luscpi[_n-1] if id==id[_n-1] & id~=.
gen difuk=-lukcpi+lukcpi[_n-1] if id==id[_n-1] & id~=.


gen difdate=date-date[_n-1] if id==id[_n-1] & id~=.




replace difdate=difdate/30

gen expprice=exp(pprice)

*drop if  hal23==1 


*adding in buyer?s premiums
*gen prem=ln(1.10)
*replace lprice=lprice+prem

sort id date AUCT_LOC HOUSE
gen llprice=lprice[_n-1] if id==id[_n-1] & id~=. & AUCT_LOC==AUCT_LOC[_n-1] & sold[_n-1]==1

gen lpprice=pprice[_n-1] if id==id[_n-1] & id~=. & AUCT_LOC==AUCT_LOC[_n-1]

gen lossgain=lprice[_n-1]-pprice if id==id[_n-1] & sold[_n-1]==1 & id~=. & AUCT_LOC==AUCT_LOC[_n-1]



gen lresid=resid[_n-1] if id==id[_n-1] & id~=. & AUCT_LOC==AUCT_LOC[_n-1]


*note: difdate is not in logs as fit is better



sum sold difdate HOUSE lS_PRICE ANAME lLOW_EST lHIGH_EST DIM_A DIM_B predp if  id==id[_n-1] & id~=. & llow~=. & pprice~=. & lossgain~=. & lresid~=. & AUCT_LOC==AUCT_LOC[_n-1] & LO==1
sum sold difdate HOUSE S_PRICE ANAME LOW_EST HIGH_EST DIM_A DIM_B predp if  id==id[_n-1] & id~=. & llow~=. & pprice~=. & lossgain~=. & lresid~=. & AUCT_LOC==AUCT_LOC[_n-1] & LO==0
 

sum sold if llprice>lpprice & id==id[_n-1] & id~=. & llow~=. & pprice~=. & lossgain~=. & lresid~=. & AUCT_LOC==AUCT_LOC[_n-1] & LO==1 & llprice~=.

sum sold if llprice<lpprice & id==id[_n-1] & id~=. & llow~=. & pprice~=. & lossgain~=. & lresid~=. & AUCT_LOC==AUCT_LOC[_n-1] & LO==1 & lpprice~=.

sum sold if llprice==lpprice & id==id[_n-1] & id~=. & llow~=. & pprice~=. & lossgain~=. & lresid~=. & AUCT_LOC==AUCT_LOC[_n-1] & LO==1 & llprice~=.

sum sold if llprice>lpprice & id==id[_n-1] & id~=. & llow~=. & pprice~=. & lossgain~=. & lresid~=. & AUCT_LOC==AUCT_LOC[_n-1] & LO==0 & pprice~=.




sum sold if llprice<lpprice & id==id[_n-1] & id~=. & llow~=. & pprice~=. & lossgain~=. & lresid~=. & AUCT_LOC==AUCT_LOC[_n-1] & LO==0 & lpprice~=.
sum sold if llprice==lpprice & id==id[_n-1] & id~=. & llow~=. & pprice~=. & lossgain~=. & lresid~=. & AUCT_LOC==AUCT_LOC[_n-1] & LO==0 & llprice~=.





sort id date AUCT_LOC HOUSE


regress llow lossgain pprice lresid difdate if lresid~=., robust
regress lprice lossgain pprice lresid difdate if lresid~=., robust
log close

*this does the graph
collapse index1 index2 date year, by(hal)
sort hal
replace year=year+.5 if year==year[_n-1]
gen eindex1=exp(index1)
gen eindex2=exp(index2)
label variable eindex1 "London Index"
label variable eindex2 "New York Index"
label variable hal  " "
label variable year "Year"

tw scatter eindex1 eindex2 year, xlabel(1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990) title(Impressionist Art 1980-1990) msymbol(0 x) c(l l)



end


