I wrote unclearly. It is the pairing of
that does not work the way you want. The variable classification was defined so that the first of these commands codes neutral parties as all_ww2 = 0. In the second command, then, because all_ww2 = 0 for a neutral country, the value of cond(inrange...) is always false, and so it is missing value (.), not pit, that gets fed into the evaluation of the -mean()-. In other words, neutral countries are excluded from the calculation of avg_ww2_pit_all.
That said, all countries are classified as either neutral, late entry, or belligerent: there is no other value to variable all_ww2. So you don't need a variable to decide which countries are included: all countries are included. So you can just dispense with variable all_ww2, and change the second command to:
As to the classification of the US in WW2, I see that I made an error in the code for variable classification. The error was that I based the distinction between late entry and belligerent on the number of years of participation being less than 5. That's fine for WW1, which had a 5 year duration. But it's wrong for WW2, which lasted 7 years. Sorry about that. So the fix for this is:
Code:
by country (year), sort: egen all_ww2 = min(cond(inrange(year, 1939, 1945), classification, .)) by year (country), sort: egen avg_ww2_pit_all = mean(cond(inrange(year, 1937, 1960) & all_ww2, pit, .))
That said, all countries are classified as either neutral, late entry, or belligerent: there is no other value to variable all_ww2. So you don't need a variable to decide which countries are included: all countries are included. So you can just dispense with variable all_ww2, and change the second command to:
Code:
by year (country), sort: egen avg_ww2_pit_all = mean(cond(inrange(year, 1937, 1960), pit, .))
Code:
gen byte war = 1 if inrange(year, 1914, 1918) replace war = 2 if inrange(year, 1939, 1945) gen war_duration = 5 if war == 1 replace war_duration = 7 if war == 2 by country war (year), sort: gen years_participation = sum(participant != 0) by country war (years_participation), sort: gen byte classification:classification = 0 if years_participation[_N] == 0 by country war (years_participation): replace classification = cond(years_participation[_N] < war_duration, 1, 2) if missing(classification) label values classification classification label def classification 0 "Neutral", modify label def classification 1 "Late Entry", modify label def classification 2 "Belligerent", modify
Comment