# [R-SIG-Finance] Help on constrained regression

spencerg spencer.graves at prodsyse.com
Fri Jul 3 02:19:19 CEST 2009

```
1.  Have you made normal probability plots of the data
(function "qqnorm")?  This could reveal outliers or a need for a
transformation.

2.  Have you considered using "lme" with "corAR1", allowing
"a" to be negative?  The examples in the help file for "corAR1" show how
to estimate this model with a different "b" for each series but with one
"a" shared between all series.  Then an analysis of residuals should

3.  Have you considered dropping one observation in each
series and using "lme" to estimate a distinct "a" and "b" for each
series, allowing  "a" to be negative?  If the grand mean of the
estimates for "a" are positive, this will reduce the number of negative
"a" values by shrinking them all towards the grand mean.  Then you can
look more carefully at the series that still have negative "a" values.
They will either contain outliers, or you will likely identify some
other series to include in the model so it becomes something more like
the following:

y[t] = a*y[t-1] + b + c*x[t] + e

As your comment indicated, the seriously negative estimates for
"a" suggest some substantive violations of the assumptions you used to
conclude that "a" should be positive.

Hope this helps.
Spencer

R_help Help wrote:
> I did. The problem was the underlying process that's negative AR(1).
> So I just have to find other way to model it. Thank you.
>
> On Thu, Jul 2, 2009 at 7:31 PM, spencerg<spencer.graves at prodsyse.com> wrote:
>
>>     Have you considered writing the model in terms of log(a) = g, say:
>>
>>          y[t] = exp(g)*y[t-1]+b+epsilon?
>>
>>     With this, you could estimate "g" and "b" using "nls".  With multiple
>> series, you could use the "nlme" function in the "nmle" package.  For the
>> "nlme" package, an excellent reference in Pinheiro and Bates (2000)
>> Mixed-Effects Models in S and S-PLUS (Springer).
>>
>>     Hope this helps.
>>     Spencer Graves
>>
>> R_help Help wrote:
>>
>>> Hi,
>>>
>>> I have an AR(1) model
>>>
>>> y[t] = ay[t-1]+b+epsilon
>>>
>>> I'm trying to force a to be positive. So I did the constrained
>>> regression with constraints 0 < a < 1. I used pcls in package mgcv.
>>> However, I found that the solution is not so stable. Most of my lag 1
>>> autocorrelation is negative. Forcing a to positive value makes the
>>> optimizer to stick a to the boundary value. All it does is varying b.
>>> I there anyway to solve this problem? I think the problem might be due
>>> to my initial value is not a smart choice.
>>>
>>> Thank you.
>>>
>>>
>>> _______________________________________________
>>> R-SIG-Finance at stat.math.ethz.ch mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>>> -- Subscriber-posting only.
>>> -- If you want to post, subscribe first.
>>>
>>>
>>>
>>
>
>

```