Plotting trend

Arindam Chakraborty arch at IO.MET.FSU.EDU
Sat Jun 25 22:21:37 EDT 2005


hi Shailendra,
        to plot a linear trend, you need to compute the slop and
y-intercept of the time series. A least square fit can be done
to obtain those two parameters. Here is an example to calculate
those and plot the linear trend.

 'open file'
 'set lon 88'
 'set lat 0'
 'set t 1 24' * assuming this is the time limit
 'define yvar = aave(...)'

 'd yvar'

* make a variable 1, 2, ..., 24 to calculate m and c of y = mx + c
 'xvar = yvar*0 + 1'
 'xvar = const(xvar,1,-u)'
 'xvar = 25 - sum(xvar,t+0,t=24)'

 'set t 1'

 'define p = sum(xvar,t=1,t=24)'
 'define q = sum(yvar,t=1,t=24)'
 'define r = sum(xvar*yvar,t=1,t=24)'
 'define s = sum(xvar*xvar,t=1,t=24)'

 'define rn = ave(xvar*yvar,t=1,t=24)'
 'define n = r/rn'

 'define amp =  (n*r - p*q)/(n*s - p*p)' * this is m
 'define ave = (q - amp*p)/n' * this is c

 'set t 1 24'
 'd amp*xvar + ave'



Hope this helps,
----------------------------
 ARINDAM CHAKRABORTY
 Department of Meteorology
 Florida State University
 Tallahassee, FL-32306, USA
 Tel: +001-850-6443524 (Off)
      +001-850-5758550 (Res)
 Fax: +001-850-6449642
____________________________


On Sat, 25 Jun 2005, Shailendra Rai wrote:

> Hello,
I have plotted a time series of area averaged variable variable with time. Is their any way in gradsc to plot the trend as a straight line ???

With regards
Shailendra Rai
K. Banerjee Centre of Atmospheric and Ocean Studies
University of Allahabad
Allahabad
INDIA



More information about the gradsusr mailing list