Trend modeling

	# Basic LS line y = a + bx
	model = trend1d("@MaunaLoa_CO2.txt", output=:xm, n_model=:p1)
	plot("@MaunaLoa_CO2.txt", region=(1958,2016,310,410), frame=(axes=:WSen, bg=:azure1),
         xaxis=(annot=:auto, ticks=:auto), yaxis=(annot=:auto, ticks=:auto, suffix=" ppm",
         marker=:circle, ms=0.05, fill=:red, figsize=(15,5), x_off=4)
	plot!(model, pen=(0.5,:blue))
	text!(text_record("m@-2@-(t) = a + b@~\\327@~t"), font=12, region_justify=:TL,
          offset=(away=true, shift=0.25), fill=:lightyellow )
	# Basic LS line y = a + bx + cx^2
	model = trend1d("@MaunaLoa_CO2.txt", output=:xm, n_model=:p2)
	plot!("@MaunaLoa_CO2.txt", frame=:same, ms=0.05, fill=:red, y_off=6)
	plot!(model, pen=(0.5,:blue))
	text!(text_record("m@-3@-(t) = a + b@~\\327@~t + c@~\\327@~t@+2@+"),
          font=12, region_justify=:TL, offset=(away=true, shift=0.25), fill=:lightyellow)
	# Basic LS line y = a + bx + cx^2 + seasonal change
	model = trend1d("@MaunaLoa_CO2.txt", output=:xmr, n_model="p2,f1+o1958+l1")
	plot!("@MaunaLoa_CO2.txt", frame=:same, ms=0.05, fill=:red, y_off=6)
	plot!(model, pen=(0.25,:blue))
	text!(text_record("m@-5@-(t) = a + b@~\\327@~t + c@~\\327@~t@+2@+ +
                       d@~\\327@~cos(2@~p@~t) + e@~\\327@~sin(2@~p@~t)"),
          font=12, region_justify=:TL, offset=(away=true, shift=0.25),
          fill=:lightyellow)
	# Plot residuals of last model
	plot!(model, region=(1958,2016,-4,4), frame=(axes=:WSen, bg=:azure1,
          title="The Keeling Curve [CO@-2@- at Mauna Loa]"),
          xaxis=(annot=:auto, ticks=:auto), yaxis=(annot=:auto, ticks=:auto, suffix=" ppm"),
          ms=0.05, fill=:red, incol="0,2", y_off=6)
	text!(text_record("@~e@~(t) = y(t) - m@-5@-(t)"), font=12, region_justify=:TL,
          offset=(away=true, shift=0.25), fill=:lightyellow, show=1)

See also GMT ex45