Announcement

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

  • Analyst Forecast Dispersion

    Hi All

    I am a beginner with Stata and am working with analyst data downloaded from IBES. I am using Stata to compute the dispersion of forecasts made by analysts over a certain period. The formula that I need to calculate is as follows:
    Std Dev of earnings forecasts issued by individual analysts in year t/ Stock price of year t-1

    I have used the following Stata code to do the above computation:

    gen fyear=year(fpedats)

    gen fmonth=month(fpedats)

    gen year_actual=year(anndats_act)

    gen month_actual=month(anndats_act)

    sort ticker fyear analys (analyst code) fpedats

    gen date=anndats_act-anndats (announce date - actual announce date)

    sort ticker fyear analys fpedats date

    by ticker fyear analys fpedats: gen n=_n

    keep if n==1 (deleting multiple forecasts from one analyst in a year)

    sort ticker fyear (fpedats)

    by ticker fyear: gen analyst_num=_N

    sort ticker fyear (fpedats)

    by ticker fyear: egen std_forecast_full=sd(value)

    With the above code, I hope to compute the 1st part of my formula, that is std dev of forecasts issued by individual analysts. However, the mean of this final column (std_forecast_full) is very high like 1234.56 etc. I think this is not right.
    Can someone please point what is wrong with above code? Can someone also tell what would be the code to divide this column with stock price from last year?

    Thank you so much for the help! Please let me know shall further information be required.

    Last edited by Shruti Verma; 03 Jan 2020, 22:23.

  • #2
    There are several problems with this code.

    Code:
    gen date=anndats_act-anndats (announce date - actual announce date) keep if n==1 (deleting multiple forecasts from one analyst in a year)


    These are both syntax errors. If the content in parentheses is intended to be comment, it needs to be separated from the actual code by //.

    In addition, keep if _n == 1 will throw out everything but the very first observation in the entire data set--which, even though I don't quite know what you are trying to do here, doesn't sound like what you want. The standard deviation of a single observation is not useful. Probably what you wanted to do is keep the first observation for each firm, or eacdh analyst, or something like that. This owuld require an appropriate -by- prefix for the command.

    As for finding the stock price from the preceding year, aren't there many stock prices dfrom the preceding year? Which one do you pick? Or maybe that -keep if _n == 1- was meant to reduce it to one stock price per year. If that's true, -xtset ticker fyear- and -gen last_year_stock_price = L1.price- will do it (replace price by the actual name of the variable that gives the stock price.

    If you need more specific advice, post back showing a sample of your data using the -dataex- command. Also explain what each variable is and how it relates to what you are trying to calculate. Avoid jargon--this is a multidisciplinary forum: put it in terms that anybody with a college education and a knowledge of statistics would understand.
    If you are running version 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    Comment

    Working...
    X