Announcement

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

  • Reference year inflation rate applied to different years.

    Hi all,

    I am analysing some trial data of respondents who have filled in questionnaires over three separate years. I wish to inflate the data from 2013, 2014, 2015 to the equivalent 2016 dollar amount.

    For example someone who filled in a questionnaire on 12/5/2013 i wish to inflate there cost by 2.7%.Eg 100*102.7.
    Someone with another date 1/2/2014 i wish to inflate by 2%.

    Is there a way i can make stata assign values for dates and then multiply by the relevant inflation amount?

    Thanks



    Last edited by Max Catch; 16 Nov 2016, 15:21.

  • #2
    Max,

    I think so. But how you'll do it depends on what your data look like. You're likely to get some specific suggestion from the list if you post some example data (see the FAQs).

    Lance

    Comment


    • #3
      Hi Lance,

      Thanks for getting back to me and apologies about my lack of info in my original post!


      ----------------------- copy starting from the next line -----------------------
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input int participantid float(date cost)
      212 19505 239.61
      616 19585      6
      185 19298  574.8
      344 19646  23.58
      707 19667   36.1
      812 19416  77.39
      144 19243 188.54
      259 19260 111.84
      267 19292  29.71
      end
      format %d date
      ------------------ copy up to and including the previous line ------------------

      Listed 9 out of 9 observations

      I wish to multiple cost by the percentage listed within the table below.
      2013 2014 2015 2016
      94.1 95.7 98 100

      Does it just mean some big coding specifying to multiple if within range or is there an easier way?

      Any help would be great.

      Thanks again

      Max

      Comment


      • #4
        There are, I'm sure, any number of ways to do it. Here's one possibility...

        Code:
        generate year = year(date)
        
        recode year (2012=.93)(2013=.941)(2014=.957)(2015=.98)(2016=1), gen(mult)
        gen adjusted = cost*mult

        I assumed the date variable was a Stata date (i.e., days since 01jan1960). Under that scenario, there were observations from 2012 and 2013 so I made up a cost adjustment for 2012.

        Lance

        Comment


        • #5
          Thank you so much for your assistance lance! Will work on my questioning technique in future posts!

          Comment


          • #6
            Another possibility is to use a Stata matrix as a look-up table: Using a year variable as shown by Lance,

            Code:
            matrix factor = (.93, .941, .957, .98, 1)'  matrix list factor  gen adjusted = cost * factor[year - 2011, 1]
            See also http://www.stata-journal.com/sjpdf.h...iclenum=pr0054

            Comment


            • #7
              Sorry for poor formatting:

              Code:
              matrix factor = (.93, .941, .957, .98, 1)'  
              matrix list factor  
              gen adjusted = cost * factor[year - 2011, 1]

              Comment

              Working...
              X