+ Reply to Thread
Results 1 to 14 of 14

Estimating multiple coefficients of an equation

  1. #1
    Registered User
    Join Date
    10-19-2018
    Location
    Newcastle, Australia
    MS-Off Ver
    16.16.2
    Posts
    8

    Estimating multiple coefficients of an equation

    Hello all,

    I have a time series database from 1985-2016 for variables W, X, Y, and Z of the following equation:

    W = C1 + C2*(1/X) + C3*(Y/X) + C4*(Z/X)

    I need to fit the real data to the equation and estimate the constants C1, C2, C3, and C4, while C2 should be no smaller than zero(C2>0).

    How can I do it in excel in a way that I get r-squared, standard errors and p-values for the estimated coefficient in excel?

    Regards,

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,345

    Re: Estimating multiple coefficients of an equation

    I would probably start by using the LINEST() function: https://support.office.com/en-us/art...a-fa7abf772b6d Some would try to avoid the helper columns, but I would add three columns to compute 1/X, Y/X, and Z/X, then use the range with those helper columns in the LINEST() function. Be sure to read the full help file to see how to get LINEST() to output the standard errors and other statistics. Depending on what other statistics you need, you may need to review the list of statistical functions to see how other statistics are calculated: https://support.office.com/en-us/art...1-63f26a86c0eb

    Note that the LINEST() function will not allow you to constrain C2. When you have a data set and the linear regression algorithm returns C2<0, you will need to decide how best to handle that scenario (set C2=0 and run the linear regression on the other 3 constants??).
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    10-19-2018
    Location
    Newcastle, Australia
    MS-Off Ver
    16.16.2
    Posts
    8

    Re: Estimating multiple coefficients of an equation

    Hello MrShorty
    Thanks very much for the clear explanation. I will look into the Lincet closely to run my estimation.

    Anyway it's a pity that you cannot constrain your coefficient that way. Wish there was such option.

    Cheers.
    Last edited by AliGW; 10-20-2018 at 04:06 AM. Reason: Please do not quote the post before your own - it's just duplication and clutter.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,345

    Re: Estimating multiple coefficients of an equation

    LINEST() is only the starting place I would use. How often do you expect the regular linear regression algorithm to return a negative C2? What does a negative C2 mean? (in a few of the regressions I commonly do, a wrong sign constant is a good indication that there is something wrong with the input data -- not the regression algorithm.) One can use non-linear regression methods (using Solver when done in Excel), but I find those more difficult to program, so I prefer to start with the well known linear regression method before venturing into non-linear regression methods.

    I guess what I am saying is, if you trouble with the linear regression algorithm returning C2<0, there are ways to fix it, but I would wait to see how badly "broken" the linear regression algorithm is before exploring those.

  5. #5
    Registered User
    Join Date
    10-19-2018
    Location
    Newcastle, Australia
    MS-Off Ver
    16.16.2
    Posts
    8

    Re: Estimating multiple coefficients of an equation

    Yea, you're right. I need C2 to be positive because I'm going to put its value in a log expression which measures the the initial intrinsic growth of a technology.

    I'm going to read the Lincet function for now to run the estimation for the database and also other database that I have. In case I was getting negative values, I'd let you know to give me more invaluable tips if you dont mind.

    Cheers,
    Last edited by AliGW; 10-20-2018 at 04:06 AM.

  6. #6
    Registered User
    Join Date
    10-19-2018
    Location
    Newcastle, Australia
    MS-Off Ver
    16.16.2
    Posts
    8

    Re: Estimating multiple coefficients of an equation

    Hello MrShorty,

    I read the function and the instruction, and accordingly I ran some estimations. It was really great though in some cases I am getting negative values for the constant that I need to be positive. Wondering if you could share your tricks or hacks with me.

    Also, I need to calculate the probability of the results. I looked it up and apparently there is a function named FTEST which can do the probability, but the instruction only explains it for an array of definite numbers to make a comparison. While the LINEST has brought me the estimated values for the constants, I dont know how to calculate and construct an array for each constant so I could feed it to the FTEST function and calculate their corresponding probabilities.

    I have been also able to calculate the R squared, ssreg, df, and ssresid.

    Cheers,
    Last edited by Simplifier12; 10-20-2018 at 01:40 AM.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,217

    Re: Estimating multiple coefficients of an equation

    Please don't quote whole posts, especially when you are responding to the one immediately preceding your own - it's just clutter. It's OK to quote if you are responding to a post out of sequence, but limit quoted content to a few relevant lines that makes clear to whom and what you are responding. Thanks!

    For normal conversational replies, try using the QUICK REPLY box below.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  8. #8
    Registered User
    Join Date
    10-19-2018
    Location
    Newcastle, Australia
    MS-Off Ver
    16.16.2
    Posts
    8

    Re: Estimating multiple coefficients of an equation

    Thanks very much for the tips, will do!

  9. #9
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,345

    Re: Estimating multiple coefficients of an equation

    I will point out that this is an Excel forum, not a statistics forum. It seems that a lot of these questions might be more about generic statistics (independent of programming language or analysis application) than about Excel specifically. We are generally very good at the Excel part of these questions, but not always as good at the statistics side of these questions. Where your questions are more about statistics, you might seek out resources that are better at statistics.

    Re: C2<0 -- As I indicated in my first response, it really depends on what C2<0 means. You have indicated that, downstream of the regression, you need to take the log of C2 (which is impossible using real numbers), but you have not explained what C2<0 means for the regression itself.
    As I noted, when I encounter this, it is usually because there is something wrong with the raw data, which usually means looking more carefully at the raw data to find what is wrong with the raw data. Hopefully, it is just a matter of finding the (few?) outliers that are pulling the regression in the wrong direction and discarding them.
    Don't neglect the possibility of floating point error. You have not indicated how far below the returned C2's are. If they are sufficiently close to 0, that might indicate a floating point issue, and you can simply round the result to 0.
    If the unconstrained best fit is returning a C2<0, I would expect that the constrained best fit will be when C2=0 (or as close to 0 as your problem statement will allow). If this applies, then I would simply fix the value of C2 at this minimum value, then use LINEST() to get C1, C3, and C4.
    When all else fails, there is always Solver -- set up the spreadsheet to compute your desired regression objective function, then have Solver optimize the objective function by changing C1, C2, C3, and C4, subject to the constraint that C2>0 (this might be the way to test several scenarios and see if C2 is always 0).
    That what I've got for "constrained regression" scenarios.

    It's not clear to me what "probability of the results" means to you, so I'm not sure I can make any suggestions. Statistics is full of many different probabilities, and almost all statistical hypothesis testing is build on those probabilities. Saying that you need to calculate a probability does not tell us what probability you need to calculate and for what purpose. You mention the FTEST() function, which suggests that maybe you are expecting to perform some kind of F test? I put "F test in linear regression" into my favorite search engine and found:
    Wikipedia, with a brief look at how F tests are used to test the quality of a regression: https://en.wikipedia.org/wiki/F-test...ssion_problems
    A university class note page: http://facweb.cs.depaul.edu/sjost/cs...f-test-reg.htm
    From a Minitab blogger: http://blog.minitab.com/blog/adventu...ssion-analysis
    Another statistics blogger: http://statisticsbyjim.com/regressio...ce-regression/
    A site I like who focuses on statistical analysis using Excel (following up on the university notes that talked about testing whether independent variables are significant): http://www.real-statistics.com/multi...ression-model/
    If none of those applications of the F test are what you are referring to when you talk about "calculating probability", then I recommend that you explain further what probability you need to calculate.

  10. #10
    Registered User
    Join Date
    10-19-2018
    Location
    Newcastle, Australia
    MS-Off Ver
    16.16.2
    Posts
    8

    Re: Estimating multiple coefficients of an equation

    Hello MrShort,

    Thanks for your invaluable tips and advice. The c constant means the intrinsic growth of a technology in the beginning when all required resources are provided and abundant and there is no other technologies to compete with it. That's why I need it to be non-negative. When I get a negative value, it means the growth is negative, but the technology is at the beginning of diffusion and it can almost have zero growth, provided all the resources and no other competitive technologies.

    Yea, the floating point can be considered as you mentioned. Good point. I also gave the Solver a try, and it was really good as I could manipulate the constant constraints.

    By the "probability of the results" I mean p-value for each estimated constant, for example you choose alpha=0.05 as an indicator to accept the value of the estimate constants if their corresponding p-value is smaller than the alpha (saying it is significant).

    However, when I change the constants or put constraints on them in the Solver, it does a good job, however it does not show me the statistics corresponding to the changed constants (like new p-values, new standard errors etc). Is there anyway that when I put constraints on constants in the Solver, I could see their corresponding changed statistics as well?

    Regards,

  11. #11
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,345

    Re: Estimating multiple coefficients of an equation

    By the "probability of the results" I mean p-value for each estimated constant, for example you choose alpha=0.05 as an indicator to accept the value of the estimate constants if their corresponding p-value is smaller than the alpha (saying it is significant).
    I'm still not sure I understand exactly what p-value you are trying to calculate. In other places:
    stattrek article https://stattrek.com/regression/slop...px?tutorial=ap
    Wikipedia article https://en.wikipedia.org/wiki/Simple...ity_assumption
    I see mention of a t-test to test the significance of the coefficient (is the coefficient significantly different from 0). If this is what you are talking about, then you will use the t distribution functions to compute the t score p-value along the way to performing the t test. If you're referring to some other p-value, we need your help to know what p-value you need to calculate. If it helps, here's a previous post where I talked about how to use the standard error from the LINEST() function to get the t score https://www.excelforum.com/excel-gen...ml#post4350280

    The tricky part might be getting the standard error for each coefficient. I know how to get the standard error from the LINEST() function for the unconstrained regression. I can read Wikipedia's article or other statistics tutorial that shows how to calculate the standard error for the unconstrained regression. The tricky part might be determining if the same formulas to calculate the standard error for the unconstrained case apply to the constrained regression that you are performing now. I am not enough of a statistician to know. It should be a "simple" matter of researching statistics resources to determine how one should calculate the standard error, then enter those formulas into the spreadsheet.

    I would note that most of this is statistics, not necessarily Excel. We are pretty good with Excel programming, but I don't think we have a statistics expert among our regular contributors here. If you can help us understand the statistics, we should be able to help you program that into Excel, but we may not be able to help you understand the statistics.

  12. #12
    Registered User
    Join Date
    10-19-2018
    Location
    Newcastle, Australia
    MS-Off Ver
    16.16.2
    Posts
    8

    Re: Estimating multiple coefficients of an equation

    Hello MrShorty,

    Yes now I think we are talking about the same thing but calling it differently. If you look in the tables in the stattrek article that you sent by the link, there is a column titled "P", something I call p-value and you call p-score when you were talking about LINEST in the other post.

    Anyway, wish the Solver could provide the changing t-test and p-scores corresponding to the constrained estimated coefficients.

    Yes, you're right. It might be more statistical issue than the software issue. Sorry for any inconveniences because I'm not good in either of those.

  13. #13
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,345

    Re: Estimating multiple coefficients of an equation

    If you look below the table in the stattrek article, they explain that the p-value they are calculating is taken from their t distribution calculator. Excel has built in T.DIST, T.TEST, and similar functions related to the t distribution for computing these values in Excel. Excel/Solver can provide these quantities -- if you program them into the spreadsheet.

    Help files for functions that start with T: https://support.office.com/en-us/art...90033e188#bm20

    This might be where it is advantageous to revisit one of my recommendations -- fix C2 at the desired minimum value and perform the regression using LINEST() with C2 fixed. For those data sets where LINEST() returns an invalid C2, does the Solver algorithm consistently set C2 to its minimum value? If it does, then you should be able to fix C2 at its minimum and use LINEST() to get the values for the other constants along with their standard errors. It should be straightforward to get t and p from the LINEST() output.

    If you need something more elaborately pre-programmed for these, you might look into applications like R or Minitab, which are more robust statistical packages that may have utilities for this kind of regression all pre-programmed. I've never used them, so I don't know what they can do out of the box, and what you would need to program into them.

  14. #14
    Registered User
    Join Date
    10-19-2018
    Location
    Newcastle, Australia
    MS-Off Ver
    16.16.2
    Posts
    8

    Re: Estimating multiple coefficients of an equation

    Thanks very much for reminding of revisiting the LINEST trick. It really worked well when I fixed the constant at the value that Solver was bringing me with the desired constraint. I'm able to get the changing statistics corresponding to the changed values of the constant.

    I also started look into Eviews and SPSS as I already have them installed on my PC.

    Really helpful your invaluable tips have been to me.
    Thanks.

+ 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. Determining coefficients of an equation using your experimental data?
    By Iman01 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-02-2015, 01:33 PM
  2. [SOLVED] Copy coefficients of an equation produced by a graph into cells
    By mogoldberg in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-06-2013, 06:38 PM
  3. [SOLVED] Finding the Coefficients of a Quadratic Equation using VBA
    By kyleg222 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-26-2012, 10:38 AM
  4. Multiple regression coefficients are not seen
    By Dr.Appalayya in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-15-2009, 04:54 AM
  5. Multiple Worksheet Estimating
    By JamcoJay in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-21-2006, 01:59 PM
  6. [SOLVED] Trend Line Equation Coefficients
    By Jake in forum Excel General
    Replies: 4
    Last Post: 04-17-2006, 03:50 PM
  7. VBA coefficients of an equation
    By Ali Baba in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-21-2005, 12:05 PM

Tags for this Thread

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