Hi Markovtsev,

 

Others will have to help you with gretl syntax, but what you’ve specified here is a linear model, not a non-linear model.  What makes it linear is that it’s linear in the parameters.  There are 3 independent variables for each y, namely 1, x, and x2.  Then your model becomes y = [1   x  x2] . [c  b  a], where the period should be read as “dot.”  The data matrix X  has, for example, second row [1  2  4].  You can obtain the estimated parameter vector [c  b  a] by OLS.

 

Frank Benford

 

From: gretl-users-bounces@lists.wfu.edu [mailto:gretl-users-bounces@lists.wfu.edu] On Behalf Of ????? ?????????
Sent: Wednesday, July 13, 2011 9:15 PM
To: gretl-users@lists.wfu.edu
Subject: [Gretl-users] Code sample for nonlinear least squares

 

Hello guys,

 

I am a developer from Russia trying very hard to learn how libgretl works. I successfully understood the provided code example (extra/simple_client.c). Unfortunately, LSQ is not enough and I want to use NLS. Could you please post a code example for, I say,

 

y=a x^2 + b x + c

 

model,

 

x = 1, 2, 3, 4, 5, 6

y = 3, 7, 13, 21, 31, 43

 

data series. Particularly, how to get the values of a, b and c?

 

I've read http://gretl.sourceforge.net/API/gretl-Nonlinear-models.html but it does not clarify how to write the actual code. I mean, it seems that I should use nlspec_new(), nlspec_set_regression_function() and model_from_nlspec() and I am not sure how to connect them.

 

Thanks,

  Markovtsev Vadim.