Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# RE: st: RE: Nonlinear least squares restrictions

 From tshmak To "statalist@hsphsun2.harvard.edu" Subject RE: st: RE: Nonlinear least squares restrictions Date Thu, 6 Jun 2013 17:16:12 +0800

```Hi Gareth,

Sorry I didn't realize X was multivariate and I also didn't realize Maarten has already replied to your question!

Tim

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of G. Anderson
Sent: 06 June 2013 16:29
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: RE: Nonlinear least squares restrictions

Hi Tim,

Thanks a lot for getting back to me. Unfortunately I'm not sure standard
OLS will work here- I want to constrain the relative responses in the
vector B to be constant over time- and the estimate both the dummy scalar b
(for each year) and the vector B.

Will give the stuff on dummy variables a read - looks like it could prove
useful.

Many thanks,

Gareth

On Jun 6 2013, tshmak wrote:

>Hi Gareth,
>
> I think this is a linear regression rather than a nonlinear regression
> problem.
>
>Naively, we can just create a variable called year, run:
>
>reg y i.year##X, nocons
>
>This would result in a different intercept and slope for each year.
>
> To make the average of b = 1, simply divide the year-specific slopes by
> the average of the slopes, the average being your estimate of B.
>
> The only problem of this approach is that your slopes across years would
> not meet at the boundary. To constraint the slopes to meet, you need to
> use splines. The best place to start is probably Roger Newson's -bspline-
> package. Dr. Newson has also written a few informative articles
> explaining their use in Stata Journal.
>
>HTH,
>Tim
>
> ps. I think the reason -nl- fails on this problem is that the problem is
> not identified unless you can somehow constraint the b to average 1, and
> I'm not sure you can do that in -nl-.
>
>
>
> -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of G. Anderson
> Sent: 05 June 2013 19:24 To: statalist@hsphsun2.harvard.edu Subject: st:
> Nonlinear least squares restrictions
>
>Hi,
>
>Using daily data, I am trying to estimate a relationship of the form y=a
>+bBX +u
>
>Where a is a scalar which can vary across years, b is a scalar which can
>vary across years, X is a vector of data and B is a vector of parameters
>which is fixed across years.
>
> Therefore I am trying to estimate a, b and B. I want to normalise b so
> that on average it is equal to 1 across years.
>
>I have tried experimenting using the nonlinear regression function but so
>far to no avail- is this type of restriction possible in Stata?
>
>Many Thanks,
>
>Gareth
>
>*
>*   For searches and help try:
>*   http://www.stata.com/help.cgi?search
>*   http://www.stata.com/support/faqs/resources/statalist-faq/
>*   http://www.ats.ucla.edu/stat/stata/
>
>*
>*   For searches and help try:
>*   http://www.stata.com/help.cgi?search
>*   http://www.stata.com/support/faqs/resources/statalist-faq/
>*   http://www.ats.ucla.edu/stat/stata/
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```