Announcement

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

  • Making an index variable vary according to percentage changes of a different variable

    Hello all,

    I am new here to the Statalist forum so apologies if I have violated convention for discussing issues. I am utilising panel data of years 1970-2005 across several countries.

    I have very limited data for a particular variable (adjusted_overvaluation_index) but wish to extend it to other years. For this variable, I only have its value for 2005. Given I am using panel data all other years for each country are denoted as missing. I intend to make an index variable utilising this variable. 2005 will be set as the base year. To extend it to other years I wish to make it vary according to percentage changes in another variable I have constructed.

    I have constructed another variable that has percentage changes, and wish to make this the amount that the index varies by. However, given the missing values I cannot do this as it simply results in a missing value.

    Below is the code I have used thus far, along with some text from a piece of economic literature which I am following in my attempted construction of this variable. I have also attached a photo of my 'browse' along with some lables to help illustrate my question.




    Code:
    //"The adjusted overvaluation index for 2005 will be the raw index divided by the predicted index. The index is then 100 in 2005 when there is no adjusted overvaluation, while an index of 150 would suggest 50 percent adjusted overvaluation." (Easterly, 2019, pp.42) 
    
    generate adjusted_realovervaluation = (raw_realovervaluation / realovervaluation_predicted)
    label variable adjusted_realovervaluation "=(raw_realovervaluation / realovervaluation_predicted)"
    browse 
    generate adjusted_index = adjusted_realovervaluation*100
    
    //"The benchmark overvaluation index is extended to other years using the percent changes in the real exchange rate index, whcih is defined as (Nominal offical exchange rate)*(US CPI index)/(Domestic CPI index)." (Easterly, 2019, pp.43) 
    
    browse
    generate extension_realoverval = ((officalexchange_rate)*(US_CPI_thatyear)/(CPIdata))
    xtset countrynum year
    generate pcchange = 100*D.extension_realoverval / L.extension_realoverval
    browse countrycode countryname year CPIdata US_CPI_thatyear countrynum adjusted_realovervaluation adjusted_index extension_realoverval pcchange
    
    //I am now unsure of how to extend this to other years given that I have many missing values for adjusted_index as I have only 2005.




    Click image for larger version

Name:	Stata Question picture.png
Views:	1
Size:	280.6 KB
ID:	1618683


    Many thanks
    -Will

  • #2
    Hello! I really appreciate the work you put into this question. However, some effort could be better spent to use -dataex- to show some of the data in the form of Stata code, so that users can use the code to read in your data and provide their codes for you to try. All the details can be found in the FAQ (http://www.statalist.org/forums/help)

    Since the pcchange seems to be basing on extension_realoverval, are you asking for an imputed adjusted_index that is 100% correlated with the extension? If that's the case, try this:

    Code:
    gen ratio1 = extension_realoverval / adjusted_index
    bysort countrycode: egen ratio2 = max(ratio1)
    gen inputed_adjusted_index = extension_realoverval / ratio2

    Comment


    • #3
      Hi Ken Chui,
      Thank you very much for your advice regarding both a better way to detail my question in the future and your solution to my issue. I do apologise for the slow reply. The solution worked and I have installed dataex for future use.

      Thanks again,
      -Will

      Comment

      Working...
      X