

Good evening
I have a doubt on polynomials. If I have an AR model like Yt=b0+b1*Yt1+b2*Yt2+et and I want to write the corresponding polynomial, would it be [1 b1 b2]?
Thank you very much.
Kind regards,
Estefanía


On 04.07.2020 21:37, [hidden email] wrote:
> Good evening
>
> I have a doubt on polynomials. If I have an AR model like
> Yt=b0+b1*Yt1+b2*Yt2+et and I want to write the corresponding
> polynomial, would it be [1 b1 b2]?
>
> Thank you very much.
>
> Kind regards,
>
> Estefanía
>
>
polynomials have positive exponents.
You seems to use negative ones b0+b1*Yt^1+b2*Yt^2
so they are not polynomial
https://octave.org/doc/v5.2.0/PolynomialManipulations.htmlMarco


please reply to the mailing list
On 04.07.2020 22:25, [hidden email] wrote:
> Thank you for your answer.
> The fact is that yt=b0+b1*y^1+b2*y^2 is also written as (1b1b2)*L
> being L the lag operator. This is why I wrote [1 b1 b2].
>
> I want to find the roots of the corresponding polynomial for that AR
> model. Should then I put: [1 b1 b2]? I find examples for polynomials
> like x^2+x+1, for instance, but I need the way to express an AR model.
> Could you help me? Thank you very much.
>
> Kind regards,
>
> Estefanía
>
I am not an expert in AR model,
but taking the definition at
https://en.wikipedia.org/wiki/Autoregressive_modelit seems not a simple polynomial operation.
The TSA package as some functions
https://octave.sourceforge.io/tsa/overview.htmlthat is referring to AR.
You may want it, of clarify better what you want to meet.
> El sáb., 4 jul. 2020 22:12, Marco Atzeri < [hidden email]
> <mailto: [hidden email]>> escribió:
>
> On 04.07.2020 21:37, [hidden email]
> <mailto: [hidden email]> wrote:
> > Good evening
> >
> > I have a doubt on polynomials. If I have an AR model like
> > Yt=b0+b1*Yt1+b2*Yt2+et and I want to write the corresponding
> > polynomial, would it be [1 b1 b2]?
> >
> > Thank you very much.
> >
> > Kind regards,
> >
> > Estefanía
> >
> >
>
> polynomials have positive exponents.
> You seems to use negative ones b0+b1*Yt^1+b2*Yt^2
>
> so they are not polynomial
>
> https://octave.org/doc/v5.2.0/PolynomialManipulations.html>
> Marco
>
>
>


> > I have a doubt on polynomials. If I have an AR model like
> > Yt=b0+b1*Yt1+b2*Yt2+et and I want to write the corresponding
> > polynomial, would it be [1 b1 b2]?
> You seems to use negative ones b0+b1*Yt^1+b2*Yt^2
> so they are not polynomial
The polynomial representation is not the delayed representation, in estefania's
x^{2} means x(t2*dt), that is the value of the signals two timesteps
in the past. This is a operator representation. the corresponding
polynomial would be
x = a x^{2} > x(t) = a x(t2*dt), so the coefficients are the same.
@estefania:
Yt=b0+b1*Yt1+b2*Yt2+et
is then
y(t) = b0 + b1 * y(t1) + b2 * y(t2) + noise(t)
and the polynomial is
py = [b2 b1 b0]
if you want to solve the coefficients that minimize the squared error
(i.e. is the same as assuming noise is i.i.d. and sampled from a
Gaussian distribution) you can do
(for one data set)
# assumes x is a column vector containing the signal, with length N
X = [x(1:end2) x(2:end1) ones(N2,1)]; # this is the Vandermonde
matrix in operator space
py = X \ x(3:N)
Example:
# create synthetic data
N = 10;
x_noiseless = x = zeros (N, 1);
x_noiseless(1) = 0.0;
x_noiseless(2) = 0.0;
px_true = [0.2 0.5 0.1].';
pdeg = length(px_true)  1; # polynomial's degree
for i = 3:N
x_noiseless(i) = px_true(3) + x_noiseless(i1) * px_true(2) +
x_noiseless(i2) * px_true(1);
# alternative, and more generic
# x_noiseless(i) = [x((ipdeg):(i1)).' 1] * px_true;
endfor
x = x_noiseless + 0.01 * randn(N, 1); # add Gaussian noise
# Solve with leastsquares (check other functions in optim package,
and other optimizations functions)
X = [x(1:N2) x(2:N1) ones(N2,1)];
px = X \ x(3:N);
printf ('px_true and px_ols\n');
disp([px_true px])
# Compare
x_ = zeros(N, 1);
for i =3:N
x_(i) = [x((ipdeg):(i1)).' 1] * px;
endfor
plot(x,'o;data;', x_, 'x;estimation: mean value;')
# end example
You can vectorize the for loop using the function movslice, or if you
implement your Ar model as a function you can use movfun.
Check their help
Regards,


Thank you for your answer. The fact is that yt=b0+b1*y^1+b2*y^2 is also written as (1b1b2)*L being L the lag operator. This is why I wrote [1 b1 b2].
I want to find the roots of the corresponding polynomial for that AR model. Should then I put: [1 b1 b2]? I find examples for polynomials like x^2+x+1, for instance, but I need the way to express an AR model. Could you help me? Thank you very much.
Kind regards,
Estefanía
On 04.07.2020 21:37, [hidden email] wrote:
> Good evening
>
> I have a doubt on polynomials. If I have an AR model like
> Yt=b0+b1*Yt1+b2*Yt2+et and I want to write the corresponding
> polynomial, would it be [1 b1 b2]?
>
> Thank you very much.
>
> Kind regards,
>
> Estefanía
>
>
polynomials have positive exponents.
You seems to use negative ones b0+b1*Yt^1+b2*Yt^2
so they are not polynomial
https://octave.org/doc/v5.2.0/PolynomialManipulations.html
Marco


In reply to this post by Juan Pablo Carbajal2
Thank you! I just want to calculate the roots of the associated polynomial to an autoregressive model. If I put [b2 b1 b0], wouldn't it be b2*x^2+b*x+b0?, as Octave represents polynomials from highest to lowest degree.
Can you help me?
Best,
Estefanía El dom., 5 jul. 2020 13:46, Juan Pablo Carbajal < [hidden email]> escribió: > > I have a doubt on polynomials. If I have an AR model like
> > Yt=b0+b1*Yt1+b2*Yt2+et and I want to write the corresponding
> > polynomial, would it be [1 b1 b2]?
> You seems to use negative ones b0+b1*Yt^1+b2*Yt^2
> so they are not polynomial
The polynomial representation is not the delayed representation, in estefania's
x^{2} means x(t2*dt), that is the value of the signals two timesteps
in the past. This is a operator representation. the corresponding
polynomial would be
x = a x^{2} > x(t) = a x(t2*dt), so the coefficients are the same.
@estefania:
Yt=b0+b1*Yt1+b2*Yt2+et
is then
y(t) = b0 + b1 * y(t1) + b2 * y(t2) + noise(t)
and the polynomial is
py = [b2 b1 b0]
if you want to solve the coefficients that minimize the squared error
(i.e. is the same as assuming noise is i.i.d. and sampled from a
Gaussian distribution) you can do
(for one data set)
# assumes x is a column vector containing the signal, with length N
X = [x(1:end2) x(2:end1) ones(N2,1)]; # this is the Vandermonde
matrix in operator space
py = X \ x(3:N)
Example:
# create synthetic data
N = 10;
x_noiseless = x = zeros (N, 1);
x_noiseless(1) = 0.0;
x_noiseless(2) = 0.0;
px_true = [0.2 0.5 0.1].';
pdeg = length(px_true)  1; # polynomial's degree
for i = 3:N
x_noiseless(i) = px_true(3) + x_noiseless(i1) * px_true(2) +
x_noiseless(i2) * px_true(1);
# alternative, and more generic
# x_noiseless(i) = [x((ipdeg):(i1)).' 1] * px_true;
endfor
x = x_noiseless + 0.01 * randn(N, 1); # add Gaussian noise
# Solve with leastsquares (check other functions in optim package,
and other optimizations functions)
X = [x(1:N2) x(2:N1) ones(N2,1)];
px = X \ x(3:N);
printf ('px_true and px_ols\n');
disp([px_true px])
# Compare
x_ = zeros(N, 1);
for i =3:N
x_(i) = [x((ipdeg):(i1)).' 1] * px;
endfor
plot(x,'o;data;', x_, 'x;estimation: mean value;')
# end example
You can vectorize the for loop using the function movslice, or if you
implement your Ar model as a function you can use movfun.
Check their help
Regards,


On Sunday, 5 July 2020 20.39.23 WEST [hidden email] wrote:
> Thank you! I just want to calculate the roots of the associated polynomial
> to an autoregressive model. If I put [b2 b1 b0], wouldn't it be
> b2*x^2+b*x+b0?, as Octave represents polynomials from highest to lowest
> degree.
>
> Can you help me?
>
> Best,
>
> Estefanía
Yes
roots([b2 b1 b0])
is what you are looking for.
For those who could be confused with this consider a stationary time series, then Y_t=Y_(t1) and so on, that is why it is stationary. :)

José Matos


Thank you José! Nevertheless, it is difficult for me to understand it, as [b2 b1 b0] would be the same for a polynomial with degree 2 and for an AR(p=2) model. As the AR model is often represented by (1b1*Lb2*L^2)*Yt, why something like [1  b1 b2] wold be wrong? Thank you beforehand.
El lun., 6 jul. 2020 a las 14:59, José Abílio Matos (< [hidden email]>) escribió:
On Sunday, 5 July 2020 20.39.23 WEST [hidden email] wrote:
> Thank you! I just want to calculate the roots of the associated polynomial
> to an autoregressive model. If I put [b2 b1 b0], wouldn't it be
> b2*x^2+b*x+b0?, as Octave represents polynomials from highest to lowest
> degree.
>
> Can you help me?
>
> Best,
>
> Estefanía
Yes
roots([b2 b1 b0])
is what you are looking for.
For those who could be confused with this consider a stationary time series, then Y_t=Y_(t1) and so on, that is why it is stationary. :)

José Matos

