Linear Trend Analysis using Grads
Dhaval Prajapati
dhaval.prajapati at ICCSIR.ORG
Mon May 18 00:42:56 EDT 2009
Dear all,
I have used following script to see the the linear trend in data. I am attaching one fig. for the reference.
Yellow line is representing mean
Green line represents trend
1. This script is working fine but in the result kinks are coming in the line representing trend, How to remove
it and make the trend line smooth ?
2. How to check the statsistical significance level in the trend (5% amd 1% significance level) ?
Script :
*assuming this is the time limit
'reinit'
'enable print print.meta'
'open test1.ctl'
'set vpage 0 8 7.5 11'
'set grid off'
'set grads off'
'set t 1 57'
'set lat 18.96'
'set lon 72.83'
'set z 1'
'define yvar = ave(rf,t=1,t=57)'
'set vrange 0 1000'
'set ylabs 0| 100| 200| 300| 400| 500| 600| 700| 800| 900| 1000|'
'd rf'
* make a variable 1, 2, ..., 24 to calculate m and c of y = mx + c
'xvar = rf*0 + 1'
'xvar = const(xvar,1,-rf)'
'xvar = 58 - sum(xvar,t+0,t=57)'
'set t 1'
'define p = sum(xvar,t=1,t=57)'
'define q = sum(rf,t=1,t=57)'
'define r = sum(xvar*rf,t=1,t=57)'
'define s = sum(xvar*xvar,t=1,t=57)'
'define rn = ave(xvar*rf,t=1,t=57)'
'define n = r/rn'
'define amp = (n*r - p*q)/(n*s - p*p)'
'define dd = (q - amp*p)/n'
'set t 1 57'
'define yvar = ave(rf,t=1,t=57)'
'define aa= (amp*xvar + dd)'
'set cmark 0'
'd aa'
'set cmark 0'
'd yvar'
'draw ylab mm'
'draw xlab Year'
'draw title 1SD_Ahm blk_Act_TS ylw_mean grn_trend'
'close 1'
**__________________________________________________________________________________
'open test2.ctl'
'set vpage 0 8 4 7.5'
'set grid off'
'set grads off'
'set t 1 57'
'set lat 18.96'
'set lon 72.83'
'set z 1'
'define yvar = ave(rf,t=1,t=57)'
*'set vrange 0 1000'
'set ylabs 0| 100| 200| 300| 400| 500| 600| 700| 800| 900| 1000|'
'd rf'
* make a variable 1, 2, ..., 24 to calculate m and c of y = mx + c
'xvar = rf*0 + 1'
'xvar = const(xvar,1,-rf)'
'xvar = 58 - sum(xvar,t+0,t=57)'
'set t 1'
'define p = sum(xvar,t=1,t=57)'
'define q = sum(rf,t=1,t=57)'
'define r = sum(xvar*rf,t=1,t=57)'
'define s = sum(xvar*xvar,t=1,t=57)'
'define rn = ave(xvar*rf,t=1,t=57)'
'define n = r/rn'
'define amp = (n*r - p*q)/(n*s - p*p)'
'define dd = (q - amp*p)/n'
'set t 1 57'
'define yvar = ave(rf,t=1,t=57)'
'define aa= (amp*xvar + dd)'
'set cmark 0'
'd aa'
'set cmark 0'
'd yvar'
'draw ylab mm'
'draw xlab Year'
'draw title 2SD_Ahm blk_Act_TS ylw_mean grn_trend'
'close 1'
**_________________________________________________________________________________
'open test3.ctl'
'set vpage 0 8 0.5 4'
'set grid off'
'set grads off'
'set t 1 57'
'set lat 18.96'
'set lon 72.83'
'set z 1'
'define yvar = ave(rf,t=1,t=57)'
'set vrange 0 1000'
'set ylabs 0| 100| 200| 300| 400| 500| 600| 700| 800| 900| 1000|'
'd rf'
* make a variable 1, 2, ..., 24 to calculate m and c of y = mx + c
'xvar = rf*0 + 1'
'xvar = const(xvar,1,-rf)'
'xvar = 58 - sum(xvar,t+0,t=57)'
'set t 1'
'define p = sum(xvar,t=1,t=57)'
'define q = sum(rf,t=1,t=57)'
'define r = sum(xvar*rf,t=1,t=57)'
'define s = sum(xvar*xvar,t=1,t=57)'
'define rn = ave(xvar*rf,t=1,t=57)'
'define n = r/rn'
'define amp = (n*r - p*q)/(n*s - p*p)'
'define dd = (q - amp*p)/n'
'set t 1 57'
'define yvar = ave(rf,t=1,t=57)'
'define aa= (amp*xvar + dd)'
'set cmark 0'
'd aa'
'set cmark 0'
'd yvar'
'draw ylab mm'
'draw xlab Year'
'draw title 3SD_Ahm blk_Act_TS ylw_mean grn_trend'
'close 1'
'print'
'disable print'
'!gxps -c -i print.meta -o TS_Ahm_June_123SD_magnitude_mm.ps'
'!rm print.meta'
Thanks,
Dhaval
Indian Centre for Climate and Societal Impacts Research (ICCSIR)
Ahmedabad Education Society compound,
Opp. H.L. Commerce College,
Navrangpura,
Ahmedabad 380 009,
Gujarat,
India
Contact No. : +91(079)40045462
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20090518/92efe96b/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TS_Ahm_June_123SD_magnitude_mm.ps
Type: application/octet-stream
Size: 255406 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20090518/92efe96b/attachment.obj
More information about the gradsusr
mailing list