RSS

Lines, Sines, and Curve Fittings 4 – walk and chew gum

10 Jan

In the three fitting exercises to date, I have first fit one line to the 20th Century data, and then a second to the residuals. In this exercise, I am going to fit two equations simultaneously.

First, the line and sine wave together. I loop around the parameter space of m (slope) and a (intercept) to fit y1 = mx + a while also looping around A (amplitude), b (phase shift) and T (period) to fit y2 = A * sin ((x-b)/T * (2*pi)). I add y1+y2 together and subtract from the data points and looking for the minimum of the residuals squared for the best fit.

GISTEMP 2000 100 line sine

In a second case, I look for the best of two sines simultaneously. Similar to the first, I loop around two sets of A, b, and T looking for the least residual squares.

GISTEMP 2000 100 sine and sine

How good is the fit?
The line and sine fit is 0.89
The sine and sine fit is 0.89

In the first set of equations:
m = 0.0046 C/yr
a = 9.0 C

A = 0.09 C
b = 33 yrs
T = 61 yrs

In the second set of equations:
A1 = 0.15 C
b1 = 2 yrs
T1 = 71 yrs

A2 = 0.23 C
b2 = 123 yrs
T2 = 141 yrs

Multiple sines series … oh! oh! … I sense some Fourier analysis in my future. Haven’t tried my hand at that for 20+ years!

The script is here.

Advertisement
 
3 Comments

Posted by on 2011 January 10 in LSCF, Statistics

 

Tags:

3 Responses to Lines, Sines, and Curve Fittings 4 – walk and chew gum

  1. Chad

    2011 January 10 at 7:58 am

    I’ve done some Fourier analysis on that same temperature time series. Seems like a nicer way of smoothing (no missing data at the ends).

     
  2. Ned

    2011 January 11 at 9:29 am

    Hi, Ron. Very nice post.

    I have to admit I “peeked ahead” — ran your two models (linear + sine, sine + sine) out through 2020.

    If you want to try a different flavor of gum, consider simultaneously fitting exponential + sine models:

    y1(t) = y1(0) * exp(kt)
    y2(t) = A * sin(((t-b)/T) * 2 * pi)
    y(t) = y1(t) + y2(t)

    You’ve probably already thought of this, of course.

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.