Hi everyone,



I am concluding my master’s degree and would very much appreciate your experience on Stata.



I am studying the impact of monitoring on the truck driver performance.



About the database:
  • Data from heavy duty trucks
  • Data from the year of 2019
  • Each line is the average of one month of operation of a truck
  • Unbalanced panel (not all trucks have data for the 12 months) – every month new trucks are sold and appear on the database
  • There are several control variables that are mainly connected to the truck (wheel configuration, average weight, transport application etc)
  • The variable ‘Package’ is the one that determines if a truck is monitored or not
  • ‘Package’== ‘Monitoring’, the truck is not monitored
  • ‘Package’ == ’Control 10’, the truck is monitored - TREATMENT
  • The trucks can change the monitoring status throughout the year, e.g. a truck was not monitored during January, February and March, but as from April this truck started to be monitored and it remains being monitored until December.
  • In fact, the status if a truck is monitored or not can change every month.


Analysis needed:



I would like to measure the effect of monitoring on a dependent variable (fuel consumption, max speed, etc) and also I would like to see the impact right after the treatment, one month after, two months after,etc until 11 months after (maximum possible). My hypothesis is to find a U-shaped relationship for the impact of the monitoring overtime.



I thought on using a diff-in-diff / Pooled / Random effects but I don’t know how put this on Stata since the treatments occurred in different points in time



Attention points:

I need to make sure that I always compare a truck that was not being monitored and then it started to be.

The cases that are the other way around need to be dropped, i.e. a truck was being monitored and then the monitoring was suspended.
  • Could you help me out here?
I hope I have made myself clear enough for you to understand, please let me know if you need more information.

Below follows the dataex:



Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float fakeID long YearMonth str10 Package str6 WheelConfiguraton double Avgweighttonne str23 Transportapplication3768 double(fuelconskml MaxSpeedkmh)
91 201901 "Control 10" "4x2" 20.22572811468958 "General cargo, haulage" 3.2443490545533575  81
78 201901 "Control 10" "4x2" 23.92689427444034 "General cargo, haulage" 3.1107819582214113 124
80 201901 "Control 10" "6x2" 28.67448853003637 "General cargo, haulage"  2.526545317563423 104
81 201901 "Control 10" "6x2" 26.96820698873401 "General cargo, haulage" 2.5393361941474533 101
86 201901 "Control 10" "6x2"  23.4515849739855 "General cargo, haulage"  2.720490383139242 109
82 201901 "Control 10" "6x2" 29.54862232224776 "General cargo, haulage" 2.2781142010261415  79
10 201901 "Control 10" "6x2" 28.65058570735427 "General cargo, haulage"  1.892802644964395 115
84 201901 "Control 10" "6x2" 29.12820613728712 "General cargo, haulage" 2.6546437526117845  95
75 201901 "Control 10" "6x2" 45.16184164466275 "General cargo, haulage" 2.0669901418641734 136
76 201901 "Control 10" "6x2" 44.72535696309836 "General cargo, haulage" 2.3172756710302176 124
26 201901 "Control 10" "6x2" 25.00105673935524 "General cargo, haulage"  2.493304852687939 107
29 201901 "Control 10" "6x2" 35.84662152206085 "General cargo, haulage" 2.7884928586528357  81
53 201901 "Control 10" "6x2" 38.24639558738045 "General cargo, haulage"  2.389581510076834  82
79 201901 "Control 10" "6x2" 35.65045916683301 "General cargo, haulage" 2.4030153022356124  84
25 201901 "Control 10" "6x2" 28.22641298743099 "General cargo, haulage"  2.361547172152763  83
93 201901 "Monitoring" "6x2" 39.65976565941327 "General cargo, haulage" 2.3107772484833675  82
94 201901 "Monitoring" "6x2" 33.29040869233852 "General cargo, haulage" 2.4695204009985963  84
96 201901 "Control 10" "6x2" 26.51844416562108 "General cargo, haulage" 2.8572452857245287 112
64 201901 "Control 10" "6x2" 22.80072670348541 "General cargo, haulage" 2.1075358269074207  93
30 201901 "Control 10" "6x2" 28.24960956243486 "General cargo, haulage"  2.428412388579232 115
24 201901 "Control 10" "6x2"  37.2220119480367 "General cargo, haulage" 2.4588440865320695 131
43 201901 "Control 10" "6x2" 43.84288747346072 "General cargo, haulage" 2.1619823756105943 113
47 201901 "Control 10" "6x2" 38.92704026138369 "General cargo, haulage" 1.6437282169367013 126
61 201901 "Control 10" "6x2" 37.60296379228898 "General cargo, haulage" 2.3828870375880196 126
 4 201901 "Control 10" "6x4" 66.59840313113476 ""                       1.6350449531930669 156
 3 201901 "Control 10" "6x4" 66.65257817465854 ""                        1.692757020842468 140
49 201901 "Control 10" "6x4" 37.86370932438348 "General cargo, haulage" 1.6386678533947951 108
22 201901 "Control 10" "6x4" 42.08444589251184 "General cargo, haulage"  2.200058532612845 112
35 201901 "Control 10" "6x4" 34.80761802198317 "General cargo, haulage"  1.759306675819461  93
41 201901 "Control 10" "6x4" 34.66987999816089 "General cargo, haulage"  1.690758484872914 128
 2 201901 "Control 10" "6x4" 60.55613285006287 ""                       1.6035381032157112 115
 5 201901 "Control 10" "6x4"  67.4329541804867 ""                        1.132051786671292   .
63 201901 "Control 10" "8x2" 16.34201995537406 "Box, distribution"       4.113144816360457  88
90 201902 "Control 10" "4x2" 21.83479217380245 "General cargo, haulage" 3.0067354975479836  80
91 201902 "Control 10" "4x2" 26.08479617206924 "General cargo, haulage" 2.7162057471381535  79
78 201902 "Control 10" "4x2" 27.76119212333397 "General cargo, haulage" 2.9829993427089914 130
37 201902 "Control 10" "6x2" 32.97117073379692 "General cargo, haulage" 2.0249237397175115 111
86 201902 "Control 10" "6x2" 28.85537766720514 "General cargo, haulage"   2.61259294021498 123
77 201902 "Control 10" "6x2" 43.46539614714312 "General cargo, haulage" 2.3314889109991337 107
82 201902 "Control 10" "6x2" 29.26685190570041 "General cargo, haulage"  2.389970940333736  80
10 201902 "Control 10" "6x2" 34.29545972824001 "General cargo, haulage" 1.9253076041677821 119
84 201902 "Control 10" "6x2" 28.53124932983537 "General cargo, haulage" 2.6973569407420626  96
75 201902 "Control 10" "6x2" 46.02362957329562 "General cargo, haulage" 2.1926436539675858 131
76 201902 "Control 10" "6x2" 39.58967451893411 "General cargo, haulage" 2.3930065981927093 125
26 201902 "Control 10" "6x2" 21.49087588141455 "General cargo, haulage" 2.8644369096271016 107
29 201902 "Control 10" "6x2" 35.25993452443144 "General cargo, haulage"  2.931588109471277  81
53 201902 "Control 10" "6x2" 35.33450954317617 "General cargo, haulage"  2.398918120198049  83
79 201902 "Control 10" "6x2" 39.13701365952383 "General cargo, haulage"  2.324736382795981  85
25 201902 "Control 10" "6x2" 24.01301057517857 "General cargo, haulage" 2.5192110608861156  85
93 201902 "Monitoring" "6x2" 34.16632570116146 "General cargo, haulage"  2.627585613738335  82
94 201902 "Monitoring" "6x2" 32.17951703785069 "General cargo, haulage" 2.6180370387223006  84
96 201902 "Control 10" "6x2" 25.68846277278562 "General cargo, haulage" 2.4924012158054714 112
64 201902 "Control 10" "6x2" 25.31075224979183 "General cargo, haulage"  2.033113896827505 100
30 201902 "Control 10" "6x2" 29.05058939510906 "General cargo, haulage" 2.4226578282971745 116
80 201902 "Control 10" "6x2" 28.72334881772399 "General cargo, haulage" 2.5564937715302607 106
81 201902 "Control 10" "6x2" 26.73752593145369 "General cargo, haulage" 2.5783161773824923 138
21 201902 "Control 10" "6x2" 36.88634394742959 "General cargo, haulage" 1.8602405534301136  81
24 201902 "Control 10" "6x2" 37.49505686344752 "General cargo, haulage"   2.37616504212955 132
27 201902 "Control 10" "6x2" 43.00062698362552 "General cargo, haulage" 1.9558071446225214 120
43 201902 "Control 10" "6x2" 39.09350766905375 "General cargo, haulage"  2.315833024081522 110
47 201902 "Control 10" "6x2"  35.3376191283166 "General cargo, haulage" 1.8071693748278712 129
61 201902 "Control 10" "6x2" 37.67235935297572 "General cargo, haulage" 2.2657072221094245 127
 3 201902 "Control 10" "6x4" 67.85001281417954 ""                        1.582464539241574 138
 6 201902 "Control 10" "6x4"  51.8013699225507 ""                       1.7087074375255284   .
46 201902 "Control 10" "6x4" 35.09320257523581 "General cargo, haulage"  2.139412076949829 130
49 201902 "Control 10" "6x4" 48.42056049387186 "General cargo, haulage" 1.5913238753318437  98
22 201902 "Control 10" "6x4" 36.45559860393423 "General cargo, haulage"  2.236692115201413 114
35 201902 "Control 10" "6x4" 38.72214550789678 "General cargo, haulage"  1.891955881032273  94
41 201902 "Control 10" "6x4" 31.20699633189236 "General cargo, haulage"  1.682431314908005 126
 2 201902 "Control 10" "6x4" 56.59164786576915 ""                       1.6188169835282726 129
 5 201902 "Control 10" "6x4" 68.20951663536268 ""                       1.1573160357703156   .
63 201902 "Control 10" "8x2" 14.62430354968176 "Box, distribution"       4.395675448465143  89
90 201903 "Control 10" "4x2" 29.11543861287938 "General cargo, haulage" 2.8048286172245853  80
91 201903 "Control 10" "4x2" 28.82518610238464 "General cargo, haulage" 2.5938236108448876  80
78 201903 "Control 10" "4x2" 29.58358665625453 "General cargo, haulage" 2.9711540005459307 128
31 201903 "Control 10" "4x2" 32.34562641356989 "General cargo, haulage"  2.397362312772746 122
37 201903 "Control 10" "6x2" 39.35329623861632 "General cargo, haulage" 2.1035572200692627 115
86 201903 "Control 10" "6x2" 29.59994093206177 "General cargo, haulage"  2.380182469801158 110
77 201903 "Control 10" "6x2" 28.12349982817847 "General cargo, haulage" 2.5747933481138077 111
82 201903 "Control 10" "6x2" 31.14869057150455 "General cargo, haulage" 2.3140740690925967  80
10 201903 "Control 10" "6x2" 29.49556962605261 "General cargo, haulage" 1.9186263203049185 120
84 201903 "Control 10" "6x2"  29.3008401758301 "General cargo, haulage" 2.6112387438646816  98
75 201903 "Control 10" "6x2" 41.75275645796381 "General cargo, haulage" 2.1390470713644523 126
76 201903 "Control 10" "6x2" 37.22335768870133 "General cargo, haulage"  2.394568091719473 135
26 201903 "Control 10" "6x2" 22.46864824643032 "General cargo, haulage" 2.6502669059884854 117
29 201903 "Control 10" "6x2" 36.85660556511231 "General cargo, haulage" 2.8431764396529053  82
53 201903 "Control 10" "6x2" 38.30557451319209 "General cargo, haulage"  2.459834408463885  82
79 201903 "Control 10" "6x2" 37.74835558989746 "General cargo, haulage"  2.194807939225337  86
25 201903 "Control 10" "6x2" 24.24833748379455 "General cargo, haulage"  2.629620727543853  85
94 201903 "Monitoring" "6x2" 12.34118130577736 "General cargo, haulage"  4.334209856646026  86
36 201903 "Control 10" "6x2" 34.33525625490192 "General cargo, haulage" 2.3299808365235406 133
96 201903 "Control 10" "6x2" 21.83320070203743 "General cargo, haulage"  2.603056142790255 111
64 201903 "Control 10" "6x2" 24.50232841757427 "General cargo, haulage"  2.076085843132208 100
30 201903 "Control 10" "6x2" 26.53641329927602 "General cargo, haulage" 2.3327880501561826 109
80 201903 "Control 10" "6x2" 25.25682862485527 "General cargo, haulage" 2.6428166572200187 111
81 201903 "Control 10" "6x2" 26.09491791353881 "General cargo, haulage" 2.5507609428112232 135
21 201903 "Control 10" "6x2" 35.86458719864421 "General cargo, haulage" 1.8574270748036195  81
24 201903 "Control 10" "6x2" 35.66542570712941 "General cargo, haulage" 2.5900650613723255 141
27 201903 "Control 10" "6x2" 40.14660377925316 "General cargo, haulage"  2.007231452877274 113
43 201903 "Control 10" "6x2" 37.41563862905064 "General cargo, haulage"  2.406022677205003 112
end