[Thread Prev][Thread Next][Index]

Re: Re: make scatter plot and regression



Hi, all
 
I tried to use regresst script to make a linear regression. But i failed to plot qhat (the regression line) over the scsttered figure.
My script shown as below.
Anyone helps?
Thanks.
 
---------------------my script------------------------------
cancel mode verify;cancel region;cancel data/all
!
 
  define axis/t=1946:1992/npoints=47 t2  !annual mean time series
  define grid/t=t2 g2
  file/var="a,b,c,d"/grid=g2/col=4 d:\Fig5.asc  ! i attached the data file last time 
 
  set window/size=1/aspect=1.294
  def view/xlim=0.2,0.6/ylim=0.6,0.85 v11
  def sym margin1=0.0,0.0,0.0,0.0
 
  LET p = a;  LET q = d !SET GRID q  !GO regresst
 let pq = p*q
 let pqmask = pq-pq  ! 0 or "missing" so all variables share the same missing
 let pmasked = p + pqmask
 let qmasked = q + pqmask
 let pp = pmasked*pmasked
 let qq = qmasked*qmasked
 
 let pave = pmasked[t=@ave]
 let qave = qmasked[t=@ave]
 let pqave = pq[t=@ave]
 let ppave = pp[t=@ave]
 let qqave = qq[t=@ave]
 let pvar  = ppave - pave*pave
 let qvar  = qqave - qave*qave
 let pqvar = pqave - pave*qave
 
 let slope = pqvar / pvar
 let intercep = qave - slope*pave
 let qhat = slope*p + intercep
 let rsquare = (pqvar*pqvar) / (pvar*qvar)
        !list slope,intercep
        !list qhat        

  set view v11
  go margins ($margin1)
  ppl tics 0,.15,0,.15,1,-1;ppl axlsze,0.14,0.14;ppl labset 0.2,0.2,0.2,0.2
  plot/nolabel/vs/set/sym=27/color=2 p,q
    ppl yfor "(i2)";ppl xfor "(i2)"; ppl yaxis -4,4,.5;ppl xaxis -3,3,.5
    ppl axlabp -1,-1,;ppl axset 1,1,1,1;ppl plot
  plot/over/nolabel/line=4/set qhat;  ppl plot/over

   frame/file=Fig5.gif
-----------------------------------------------------------------------------
 

Hello Gao,
Yes you can do this.  Read the data into four
variables, say they are  a, b, c, and d.  Then the
scatter plot of two of them is made with
 
yes? plot/vs a, c
 
You can use /HLIMITS and /VLIMITS on the plot call to
make the axes any length you want.
 
If you have defined the axis for the data as a time
axis, then the script regresst.jnl will define the
variables you need for the regression line. There is a
Ferret FAQ about how to use the regress scripts:
 
http://www.ferret.noaa.gov/Ferret/FAQ/analysis/regressions.html
 
 
--- Gao Rongzhen < gaorz@scsio.ac.cn>  wrote:
 
>  Hi, Dear All,
>  
>  The attatched data file contains 4 colomns,
>  representing four annual mean time series ranging
>  from 1946 to 1992 .
>  
>  Now i want to make a scatter plot and its linear
>  regression line. For example, a is independent
>  variable (x), and c is dependent variable (y).
>  
>  Can ferret make it and how?
>  
>  Thanks for any help.
>  
>  Gao Rongzhen
>  
 
 
__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
 
.


[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement