[Thread Prev][Thread Next][Index]
Re: How to fit data with a straight line
Hi Yang,
First I see a couple of more fundamental problems.
1. The axis TAX is an year-by-year (non-modulo) axis. You have included a "modulo"
qualifier, but I think it does not belong there.
2. You have also asked for TEMP[gt=tax1@mod], modulo regridding. I believe what you
want is simple TEMP[gt=tax1@AVE] -- to average the (monthly) source points into
the (annual) destination cells.
Here is a complete session illustrating the type of calculation that you are
attempting. I use a SIN function for synthetic data. The resulting GIF file is
attached.
yes? define axis/t=1-jan-1945:31-dec-1993:30/units=days tsrc
yes? let my_var = SIN(T[gt=tsrc]/500)
yes? plot my_var
yes? def axis/t=1-jan-1945:31-dec-1993:365.25/units=days/edges tax1
yes? let my_var_ann = my_var[gt=tax1@ave]
yes? plot/over/symbols my_var_ann
yes? go regresst
... Linear Regression Along the T Axis
... Instructions:
Use the LET command to define new variables
Define the variable P as your independent (X) variable
Define the variable Q as your dependent (Y) variable
Results will be variables "SLOPE", "INTERCEP" and "RSQUARE"
QHAT will be the regression estimate
Note: If "T" is your independent variable then
... "SET GRID Q" after defining Q.
...
yes? let p = t[gt=tax1]
yes? let q = my_var_ann
yes? plot/over qhat
yes? frame/file=qhat.gif
Happy Ferreting - steve
================================================
Yang Haijun wrote:
> Hi,
>
> Thank you very much. Bu now I have another problem,
>
> Suppose I have data temperature with 49 year x 12 months = 588 time steps
>
> currently SET data sets:
> 1> temp.nc (default)
> name title I J K L
> TEMP COADS SST 1:97 1:57 ... 1:588
> PERIOD Averaging period ... ... ... 1:588
>
> 1) First of all I get annual mean temp
>
> yes? def axis/t=1-jan-1945:31-dec-1993:365.25/units=days/edges/modulo tax1
> yes? let TMEAN = TEMP[gt=tax1@mod]
>
> 2) Then I want to do regress for TMEAN
>
> yes? let q = TMEAN
> yes? let p = t
> yes? set grid TMEAN
> yes? go regresst
>
> Then I got error messages:
>
> **ERROR: unknown defining grid: GT=TAX1@MOD --> g=user-or-pseudo-var not allowed
> set grid TMEAN
> Command file, command group, or REPEAT execution aborted
>
> Obviously the problem is due to 't', how to give 't' to p here?
> And let ferret know this 't' is corresponding to TMEAN?
>
> Thanks a lot.
>
>
> Haijun Yang
>
>
>
>
> > From ferret_users-owner@ferret.wrc.noaa.gov Wed Mar 22 15:00:35 2000
> > From: "Mark Verschell" <verschell@neptune.gsfc.nasa.gov>
> > Date: Wed, 22 Mar 2000 15:45:57 -0500
> > In-Reply-To: Yang Haijun <navyang@tuna.meteor.wisc.edu>
> "How to fit data with a straight line" (Mar 22, 1:48pm)
> > References: <200003221948.AA14779@tuna.meteor.wisc.edu>
> > X-Mailer: Z-Mail (5.0.0 30July97)
> > To: Yang Haijun <navyang@tuna.meteor.wisc.edu>,
> ferret_users@ferret.wrc.noaa.gov
> > Subject: Re: How to fit data with a straight line
> > Mime-Version: 1.0
> > Content-Type: text/plain; charset=us-ascii
> > Sender: owner-ferret_users@ferret.wrc.noaa.gov
> > Precedence: bulk
> > Content-Length: 872
> >
> > Look at the .jnl files regress?.jnl that would be in $FER_DIR/go, since you are
> > trying to do this versus time, you would use regresst.jnl. A simple example for
> > your case:
> >
> > yes? let p=temperature
> > yes? let q=t
> > yes? set grid q
> > yes? go regresst
> >
> > Then:
> >
> > yes? list slope, intercep, rsquare ! slope is b and intercep is a
> >
> > You can also plot this with
> >
> > yes? plot qhat
> >
> > Mark
> >
> > On Mar 22, 1:48pm, Yang Haijun wrote:
> > > Subject: How to fit data with a straight line
> > > Dear ferret users,
> > >
> > > I have a time-series data, say Temperature with 40 years, now I want to fit
> > this data with a
> > > straight line, that is, I want to get this line:
> > >
> > > Y = a + b*t
> > >
> > > based on Temperature observations. Here Y is temperature, t is time step.
> > How do I get 'a' and
> > > 'b'? Is there a function to do this in ferret?
> > >
> > > Thank you very much,
> > >
> > > Haijun Yang
> > >-- End of excerpt from Yang Haijun
> >
> >
> >
--
| NOAA/PMEL | ph. (206) 526-6080
Steve Hankin | 7600 Sand Point Way NE | FAX (206) 526-6744
| Seattle, WA 98115-0070 | hankin@pmel.noaa.gov
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement