# How to get parameters from a quadratic fit in Stata?

Using the Stata graph twoway command, I have created a scatterplot with a quadratic best fit line, using the qfit command. How can I get the equation of the best fit line?

Example:

graph tw (scatter y x) (qfit y x)

-
You should include your specific code to make it easier for people to give an answer. –  David Robinson Jan 8 '12 at 20:00

Your graph, using auto as an example.

sysuse auto, clear
graph tw (scatter  price mpg) (qfit  price mpg), name(graph1)


regress y on x and x^2 and get predicted values (seehelp fvvarlist if you don't know about this notation)

regress price mpg c.mpg#c.mpg


The output from regress gives you the "equation" of the fitted line (y=b1*x + b2*x*x + b3) and the following graph is equivalent:

predict fitted
sort mpg
graph tw (scatter  price mpg) (line fitted mpg) , name(graph2)

-
qfit is a convenience command that simply calls regress, then obtains and plots the predicted values. So if you want the fit parameters, you can call regress yourself.