Dear Stata community,
I hope you can help me out with this. I have a large data set of trade data per product per country, with variables rca (revealed comparative advantage), product code (1200 products), country (150 countries).
I want to calculate the conditional probability that a country exports a certain product X with rca>1, given that it exports product Y with rca>1. This is simply the number of countries that are specialized in both product X and Y (rca>1), divided by the number of countries specialized in product Y.
Then I want to compare this to the simple probability that a country is specialized in a certain product X. (Number of countries specialized in X divided by total number of countries)
My previous experience only covers regression analysis, but this is a completely different type of problem. I think the simple regression should be possible with looping, but despite reading foreach/forvalues manuals and watching Youtube tutorials I have not been able to do this.
The conditional probabilities I want to calculate for 50 products.
I would be really grateful if someone could point me in the right direction.
I hope you can help me out with this. I have a large data set of trade data per product per country, with variables rca (revealed comparative advantage), product code (1200 products), country (150 countries).
I want to calculate the conditional probability that a country exports a certain product X with rca>1, given that it exports product Y with rca>1. This is simply the number of countries that are specialized in both product X and Y (rca>1), divided by the number of countries specialized in product Y.
Then I want to compare this to the simple probability that a country is specialized in a certain product X. (Number of countries specialized in X divided by total number of countries)
My previous experience only covers regression analysis, but this is a completely different type of problem. I think the simple regression should be possible with looping, but despite reading foreach/forvalues manuals and watching Youtube tutorials I have not been able to do this.
The conditional probabilities I want to calculate for 50 products.
I would be really grateful if someone could point me in the right direction.
Comment