Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • problems to implant a eventstudy / xtevent

    Hello everyone! I would like to do an event study on Stata. My question is whether crimes committed against civil society actors lead to a change in the crimes committed in the context of an armed conflict. To do this, I have created a database from two sets of data. The new database (panel data) I created brings together :

    -A "date" variable running from 1 January 1989 to 31 December 2018 (it therefore includes all the days between these two dates) so 12,293,754 observations.

    -A variable counting the number of crimes committed against civilians per day.

    -A variable that counts the number of crimes committed in the context of armed conflict per day.

    -A variable that allows me to identify the town where the crime was committed

    I've been trying for some time to implement an event study, at first fairly basic but I can't manage it. I'd like to see if a crime in civil society (t=0) causes an increase in crimes committed in the context of armed conflict in t+1, t+2, t+3, etc.

    First, I created a dummy variable that tells me the days on which a crime against a civilian was committed (==1). However, the rest is complicated because I don't know what method to use. I wanted to create a new variable t, which tells me the days before and after the crime was committed, but even that is complicated.

    I tried to use xtevent but I had an error message after this code :


    gen totalunionviolence_dummy = (sumtotunion_violence > 0)

    replace totalunionviolence_dummy = 0 if missing(totalunionviolence_dummy)

    collapse (first) state muni year month day sumtotunion_violence sumtotconflict_violence totalunionviolence_dummy, by(muni_id date)

    xtevent sumtotconflict_violence, pol(totalunionviolence_dummy) panel(muni_id) time(date) window(5) plot



    I have this error message :

    maxvar too small
    You have attempted to use an interaction with too many levels or attempted to fit a model with too many variables. You need to
    increase maxvar; it is currently 2048. Use set maxvar; see help maxvar.

    If you are using factor variables and included an interaction that has lots of missing cells, try set emptycells drop to reduce
    the required matrix size; see help set emptycells.

    If you are using factor variables, you might have accidentally treated a continuous variable as a categorical, resulting in lots
    of categories. Use the c. operator on such variables.


    I tried to increase the maxvar but it still didn't work...


    Could you help me use the correct command to implement this solution?

    Thanks for your answers!


  • #2
    David:
    take a look at -help memory- and see the maximum number of observations and variables that you Stata version allows you to include in your dataset.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment

    Working...
    X