-------------------------------------------------------------------------------
help for curvefit                                                   version 2.0
                                                         get the newest version
-------------------------------------------------------------------------------

Curve Estimation

Description

curvefit procedure produces curve estimation regression statistics and related plots between two variables for 35 different curve estimation regression models. curvefit based on the Stata command nl which fits an arbitrary nonlinear regression function by least squares.

Syntax

curvefit depvar indepvar [if] [in] , function(string) [nograph initial(string) count(integer)]

options Description ------------------------------------------------------------------------- * function(string) The following are alternative Models correspond with the values of the sting: . string = 1 Linear: Y = b0 + (b1 * X) . string = 2 Logarithmic: Y = b0 + (b1 * ln(X)) . string = 3 Inverse: Y = b0 + (b1 / X) . string = 4 Quadratic: Y = b0 + (b1 * X) + (b2 * X^2) . string = 5 Cubic: Y = b0 + (b1 * X) + (b2 * X^2) + (b3 * X^3) . string = 6 Power: Y = b0 * (X^b1) OR ln(Y) = ln(b0) + (b1 * ln(X)) . string = 7 Compound: Y = b0 * (b1^X) OR ln(Y) = ln(b0) + (ln(b1) * X) . string = 8 S-curve: Y = e^(b0 + (b1/X)) OR ln(Y) = b0 + (b1/X) . string = 9 Logistic: Y = b0 / (1 + b1 * e^(-b2 * X)) . string = 0 Growth: Y = e^(b0 + (b1 * X)) OR ln(Y) = b0 + (b1 * X) . string = a Exponential: Y = b0 * (e^(b1 * X)) OR ln(Y) = ln(b0) + (b1 * X) . string = b Vapor Pressure: Y = e^(b0 + b1/X + b2 * ln(X)) . string = c Reciprocal Logarithm: Y = 1 / (b0 + (b1 * ln(X))) . string = d Modified Power: Y = b0 * b1^(X) . string = e Shifted Power: Y = b0 * (X - b1)^b3 . string = f Geometric: Y = b0 * X^(b1 * X) . string = g Modified Geometric: Y = b0 * X^(b1/X) . string = h nth order Polynomial: Y = b0 + b1*X + b2*X^2 + b3*X^3 + b4*X^4 + b5*X^5 ... . string = i Hoerl: Y = b0 * (b1^X) * (X^b2) . string = j Modified Hoerl: Y = b0 * b1^(1/X) * (X^b2) . string = k Reciprocal: Y = 1 / (b0 + b1 * X) . string = l Reciprocal Quadratic: Y = 1 / (b0 + b1 * X + b2 * X^2) . string = m Bleasdale: Y = (b0 + b1 * X)^(-1 / b2) . string = n Harris: Y = 1 / (b0 + b1 * X^b2) . string = o Exponential Association: Y = b0 * (1 - e^(-b1 * X)) . string = p Three-Parameter Exponential Association: Y = b0 * (b1 - e^(-b2 * X)) . string = q Saturation-Growth Rate: Y = b0 * X/(b1 + X) . string = r Gompertz Relation: Y = b0 * e^(-e^(b1 - b2 * X)) . string = s Richards: Y = b0 / (1 + e^(b1 - b2 * X))^(1/b3) . string = t MMF: Y = (b0 * b1+b2 * X^b3)/(b1 + X^b3) . string = u Weibull: Y = b0 - b1*e^(-b2 * X^b3) . string = v Sinusoidal: Y = b0+b1 * b2 * cos(b2 * X + b3) . string = w Gaussian: Y = b0 * e^((-(b1 - X)^2)/(2 * b2^2)) . string = x Heat Capacity: Y = b0 + b1 * X + b2/X^2 . string = y Rational: Y = (b0 + b1 * X)/(1 + b2 * X + b3 * X^2) . string = ALL refers to a total of above models (Attention: it's uppercase!) * nograph Curve Estimation without curve fit graph. * initial(string) initial values for parameters. * count(integer) set order of model 'nth order Polynomial' (default=4). -------------------------------------------------------------------------

Note: (1)Some of the equations must initial values for parameters. (2)As for the model 'nth order Polynomial', you should use the option count(integer) to set the order of it.

Examples

(1) sysuse auto

. curvefit between variables weight length for models 6, 8, 0 and a with related plots:

. curvefit weight length if foreign==0, f(680a)

. curvefit for all of different models with no related plots:

. curvefit weight length, f(ALL) n

. then choose models with bigger adjusted R-squared which curvefit the data better:

. curvefit weight length, f(680abfg)

(2) sysuse temptime -- You can get the data file from here

. curvefit for 5th order Polynomial models:

. curvefit temperature time, f(h) c(5)

. curvefit for Logistic models with initial values for parameters:

. curvefit temperature time, f(9) i(b0 2 b1 1.5 b2 0.1)

. curvefit for Reciprocal Quadratic models with initial values for parameters:

. curvefit temperature time, f(l) i(b0 1 b1 0 b2 3)

. curvefit for Sinusoidal models with initial values for parameters:

. curvefit temperature time, f(v) i(b0 3 b1 0.5 b2 0.05 b3 -5)

For problems and suggestions

Author: Liu wei, The School of Sociology and Population Studies, Renmin University of China. Address: Zhongguancun Street No. 59, Haidian District, ZIP Code: 100872. E-mail: rucwz-stata@yahoo.cn

Also see

Other Commands I have written:

deci (if installed) ssc install deci (to install) fdta (if installed) ssc install fdta (to install) ftrans (if installed) ssc install ftrans (to install) freplace (if installed) ssc install freplace (to install) elife (if installed) ssc install elife (to install) ftree (if installed) ssc install ftree (to install) fren (if installed) ssc install fren (to install)