Least squares fit to absolute value function

Discussion in 'Numerical Analysis' started by sherwood, Jan 16, 2006.

  1. sherwood

    sherwood Guest

    Is there a way to find analytically the best fit, in the least squares
    sense, of data (x_i, y_i), when the function to be fitted is y = a(1 -
    b|x - c|). The function is a pair of intersecting straight lines with
    slopes the negative of each other, intended to represent a peak.
     
    sherwood, Jan 16, 2006
    #1
    1. Advertisements

  2. You can generally least squares fit any function to a data set--but you may
    not have a simple algrorithm to do it and may in your case have to loop
    through values of a, b, and c to find it (keeping track to see which
    combination gives the least sum of squared differences). And if the data
    has substantial outliers, you may be better with a least absolute deviation
    fit (something rarely done it seems but recommended).
     
    David L. Wilson, Jan 17, 2006
    #2
    1. Advertisements

  3. sherwood

    Ray Koopman Guest

    Plot the correlation of y with |x-c| as a function of c, and
    find the peak. Given c, the solution for a & b is standard.
     
    Ray Koopman, Jan 17, 2006
    #3
  4. sherwood

    sherwood Guest

    You are referring to an iterative method, which is not what I'm looking
    for, because they are computationally expensive. I may end up using one
    anyway, though, if I can't find an analytic solution, but right now an
    analytic solution is what I'm seeking.
     
    sherwood, Jan 17, 2006
    #4
  5. Although this gives a fit, it is not clear to me that it will be the least
    squares one.
     
    David L. Wilson, Jan 17, 2006
    #5
  6. sherwood

    Ray Koopman Guest

    The mean square error in the sample linear regression of any y on any
    x is Variance[y]*(1 - Correlation[y,x]^2). Transforming x to maximize
    the correlation will minimize the squared error of prediction.
     
    Ray Koopman, Jan 17, 2006
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.