Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Curve Fit

From   "FEIVESON, ALAN H. (AL) (JSC-SD) (NASA)" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: Curve Fit
Date   Mon, 9 Dec 2002 12:50:44 -0600

Marita - 

I'm not totally sure what you are asking - but it sounds as if you want to
regress your dependent variable on a pre-defined function. To be specific,
suppose your dependent variable is y and your pre-defined function is
log(x), where x is also a Stata variable. Then you could do the following:

.gen fx=log(x)
.reg y fx

This will find a linear transformation of log x (not x) that best fits your
y-variable in a least-squares sense. In other words, y is predicted by b0
+b1*log(x). Note that this model is linear in the coefficients (b0, b1) even
though log(x) is a nonlinear function of x. 

On the other hand if you want to predict y by a model that is nonlinear in
the coefficients, such as b0*exp(-b1*x)+b2, then you have to use nonlinear
least squares (the -nl- command).

Hope this helps - 

Al Feiveson

-----Original Message-----
From: Marita Jacob [mailto:[email protected]]
Sent: Monday, December 09, 2002 7:50 AM
To: [email protected]
Subject: st: Curve Fit 

Hi Stata-Users,

is it possible to use Stata to fit a selected self-defined curve to a line 
I would like to define my own model y=f(x) to be fit to the data (which is 
not necessarily the best fitting function, but I am interested in the 
particular form of the curve).

Marita Jacob

*   For searches and help try:
*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index