+ Reply to Thread
Results 1 to 7 of 7

automative Regression, Macro, update regression with new values

  1. #1
    Registered User
    Join Date
    11-06-2018
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    13

    automative Regression, Macro, update regression with new values

    Hey everyone,

    I couldn´t find an answer to my Question so far, so I hope you can help me.

    I created an excel sheet which gives me automatically my portfolio excess rate back. Now I am always doing regressions with my excess rates as y-variable and the fama french factors as x variable. Anyways, I sometimes change the input for the excess rate and I was wondering if there is any possibility, maybe a macro function or maybe easier an "update the regression" function, which automatically gives me the new regression results for the changed excess rates. Because so far I always need to do i manually for every single regression, and thats a lot of work :/

    Maybe any of you do have an idea for how to make this step easier. Thank you so much for even thinking about it and your help. I really appreciate it!

    Best regards
    Leo

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: automative Regression, Macro, update regression with new values

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? However, please give us an indication of the approximate number of rows of data you want the solution to work with (100, 1000, 100,000 or whatever). Please don't attach a picture of an Excel sheet (no-one will want to re-type all your stuff before starting).

    1. It does NOT have to be your real sheet - mock up a SAMPLE if you need to. But not 1000's of rows!!! It makes manual checking so tedious. Whatever you do... make sure that all confidential information is removed first!!

    2. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    3. Make sure that your desired solution is also shown (mock up the results manually).

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    11-06-2018
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    13

    Re: automative Regression, Macro, update regression with new values

    Hello,

    thank you so much for your quick Reply glenn kennedy.

    (Hopefully) attached you can find an example, and just one Regression. In the end I do have About 203 data Points and do About 3 regressions for each Portfolio.

    Best
    Alisa
    Attached Files Attached Files

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: automative Regression, Macro, update regression with new values

    I was in exactly the same situation a few years ago. I set up a formula-based ANOVA table... from memory. That could be adapted to select specified ranges.. I will try to find it on my HDD.

    It's not onvious from your sheet what data ranges you want to use... if it was columns N:Q, they are on your HDD, not in the sheet. I see non-working links. If it was those columns, how do they relate to columns A:K?

    More information is needed...

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: automative Regression, Macro, update regression with new values

    Your sample file suggests to me that you are using the Data analysis -> Regression tool to perform these regressions, is that correct? When you recognize that the Data Analysis -> Regression tool uses the same exact algorithms as the LINEST() worksheet function to perform regressions, my first suggestion is to use the LINEST() worksheet function instead of the Data Analysis -> Regression tool. LINEST() help file: https://support.office.com/en-us/art...a-fa7abf772b6d

    The Data Analysis -> Regression tool outputs more statistics than the LINEST() function. If all of those statistics are needed, recognize that all of those statistics can be calculated using other worksheet functions. You may need to research how those other statistics are calculated, but once you know how to calculate them, you should be able to come up with worksheet formulas that will calculate all of those statistics.

    If I were going to make this more automatic, that's the direction I would go.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    Registered User
    Join Date
    11-06-2018
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    13

    Re: automative Regression, Macro, update regression with new values

    Thank you so much for your answers!

    First to you Glenn Kennedy,thank you so much for your next Reply!
    I am sorry, I attached a new file, now it should be working withouth references. And I used for the y-values: colum B (blue one) and for x-values: N-P (orange values). Hope this gives you all the Information needed. If you really do have a Formula to automate that step that would be amazing!!!! I would really appreciate that, because it would save me a lot of time.

    Also thank you MrShorty, thats probably the way I will go if I do not get a Formula from Glenn Kennedy which works, but I do really Need all the values. So all the statistical Outputs and unfortunately not only one result, so this would probably be a lot of work to put all that together.
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: automative Regression, Macro, update regression with new values

    I don't expect Glenn or anyone to come up with a single formula that supplies all of those statistics. As I said, I would use the LINEST() function and what I know of the other statistics to get the same output.

    1) As explained in its help file, the LINEST() will give you:
    coefficients
    standard errors of coefficients
    r-squared and standard error in y
    F-score and degrees of freedom
    the sum squared and residual
    2) When you need the t value and accompanying P score, these are easily calculated from the LINEST() output (see this statistics tutorial: https://stattrek.com/regression/slope-test.aspx )
    t=coefficient/standard error of coefficient
    P score is from the t-distribution (in Excel, you can use one of the TDIST() functions (https://support.office.com/en-us/art...8-4a1f9dcdd192 )
    3) Margin of error of each coefficient uses the desired confidence interval and the TINV() function to get the lower and upper confidence limits (see stat tutorial here: https://stattrek.com/estimation/margin-of-error.aspx ).
    4) To get the Fcritical value, use the FDIST() function with the Fscore output by LINEST()
    5) and so on until you have all the stats you need.

    The main "trick" I would expect is that, because the LINEST() output is a 2D block of cells rather than a single row/column, it will be tricky to arrange the LINEST() output into a single column for easy copying across columns B:K. Strategic use of an INDEX() function should allow you to arrange the LINEST() output (along with the other statistic calculations) so it all fits into a single column beneath the corresponding x.PF values. Then it will be a simple copy and paste to perform the regression analysis for each column of x.PF values.

    Once you are familiar with Excel's stat functions and the statistics behind the analysis, this should not be overly difficult to program into the spreadsheet. Let us know where you get stuck.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 10-14-2018, 08:38 PM
  2. Regression with blank values in x range
    By excelhelpguy123 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-14-2017, 12:16 PM
  3. Power regression - standard error values
    By David2017 in forum Excel General
    Replies: 8
    Last Post: 02-26-2017, 01:52 PM
  4. Regression Macro
    By Scher215 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 08-18-2013, 06:35 AM
  5. Need help with a Macro to run Regression.
    By sbnjac80 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-05-2012, 10:16 PM
  6. Non-numeric values in a Regression
    By Nickley in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2011, 03:32 PM
  7. Using Linear Regression to Fill in Missing Values
    By Matty's Dilemma in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-30-2009, 06:56 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1