0

I would like to estimate a nonlinear regression model of the following kind:

y=ß0 + ß1*( b[1,theta]*x1 +  b[2,theta]*x2 )+ e

Description of the elements:

 y: the regressand
x1: regressor 1
x2: regressor 2
ß0: parameter to be estimated
ß1: parameter to be estimated
 e: iid random noise ~ N(mu, sigma)

And finally, b[i,theta] for i=1,2 represents the following Exponential Almon Polynomial Weighting Function:

b[i,theta]= exp(theta1*i+theta2*k^2)/(exp(theta1*1+theta2*1^2) + exp(theta1*2+theta2*2^2))

It just represents two decaying weights for x1 and x2, nothing more. But these weights depend on two parameter values, which are also to be estimated: theta1 and theta2.

Now, I would like to estimate the optimal (with respect to RSS criterion) values for the parameters ß0, ß1, theta1 and theta2 using the nonlinear least squares function nls().

I tried the following which resulted in an error message:

nls(y~beta0+beta1*(exp(theta1*1+theta2*1^2)/1318837781*x1+exp(theta1*2+theta2*2^2)/1318837781*x2),data=d,start=list(beta0=1,beta1=1,theta1=.01,theta2=-.0099))

Error in nls(y ~ beta0 + beta1 * (exp(theta1 * 1 + theta2 * 1^2)/1318837781 *  : 
Parameters without initial values in 'data': x1, x2

Note: for notational simplicity I calculated the denominator value of the weighting function beforehand, which amounts to 1318837781.

It seems that nls() sees x2 and x2 as parameters, but they are regressors. What am I doing wrong here and how should I modify the code to get reasonable results. Or is it impossible to estimate such kind of function with nls()?

Thanks!

Metrics
  • 15,172
  • 7
  • 54
  • 83
DatamineR
  • 10,428
  • 3
  • 25
  • 45
  • 1
    Can you add some sample data to your post (via `dput` or simulation)? Thanks. – Nate Pope Sep 29 '13 at 19:36
  • I used a simple simulated data set: `d=data.frame(y=rnorm(10),x1=rnorm(10),x2=rnorm(10))` Before applying to my real data I wanted to understand the function – DatamineR Sep 29 '13 at 19:40
  • Sometimes it's helpful to evaluate your expression on the RHS using graphic methods to see where it is defined or where it blows up. – IRTFM Sep 29 '13 at 23:10
  • Meanwile I am confused if my model is nonlinear at all. As one can see, the regressors x1 and x2 are just multiplied with the weights. In all other cases of nonlinearity I can recall the regressors appear in different positions, for example as the power, as the denominator or something like that, but not just multiplied with something. Is this a nonlinear model at all in my case? – DatamineR Sep 29 '13 at 23:40
  • I bet your "depth" in defining `b[i,theta]` that way is blowing something up. Try simplifying your model formula as much as possible. – Carl Witthoft Sep 30 '13 at 00:01
  • It is actually a simple example. In my actual model there are much more regressors. Actually they are lagged values of the same variable which I want to include with decaying weights, represented by the Exponential Almon Polynomial function, which has two parameters - theta1 and theta2. This approach is called MIDAS(Mixed-data sampling), developed by Ghysels. There is still no package or function in R implementing this approach, so I am trying to write my own code. – DatamineR Sep 30 '13 at 00:48
  • I can't recreate your error. This kind of error usually indicates that your data.frame doesn't have variables with the same names as in your model. You might try to start over with a clean R session to get rid of that error, although I think you'll have get singularity errors once you have that worked out. – aosmith Oct 01 '13 at 20:52
  • Looks like *d* has no *x1* and *x2* and *nls* expects starting values. – mlt Jun 19 '14 at 19:34

0 Answers0