Re: OLS with factors and one common intercept



"John D'Errico" <woodchips@xxxxxxxxxxxxxxxx> wrote in message <gmcioh$c60$1@xxxxxxxxxxxxxxxxxx>...
"Rogelio" <rogelio.a.mancisidor@xxxxxxxxxxxxx> wrote in message <gmchki$o0g$1@xxxxxxxxxxxxxxxxxx>...
Hei,

I wnat to find the coeficient estimates of a linear model with one intercept and two different slopes. I have one factor variable. To be more specific see below:
x=(1:20);
A=[1 2 2 1 2 2 1 1 2 2 2 1 1 1 2 1 2 1 2 1 ]; %%factor variable
y=10+x.*5.*(A==1)+x.*12.*(A==2)+randn(1);
plot(x,y,'o') %% This sketch my model

From the graph we can see that there are one common intercept and two different slopes to estimate. How do I achieve this results??


x=x(:);
A=A(:);
y=y(:);
coef = [ones(length(x),1),(A==1).*x,(A(:)==2)).*x]\y

HTH,
John

Thanks John,

This of course gives an estimate of the coeficients, but I was thinking in terms of a least squares estimation, so I can get standard erros, residuals, hipothesis testing etc. Is there any method in the statistical tool box???
.



Relevant Pages

  • Re: OLS with factors and one common intercept
    ... I wnat to find the coeficient estimates of a linear model with one intercept and two different slopes. ...
    (comp.soft-sys.matlab)
  • Re: OLS with factors and one common intercept
    ... I wnat to find the coeficient estimates of a linear model with one intercept and two different slopes. ...
    (comp.soft-sys.matlab)
  • OLS with factors and one common intercept
    ... I wnat to find the coeficient estimates of a linear model with one intercept and two different slopes. ...
    (comp.soft-sys.matlab)
  • Re: multiple regression (intercept)
    ... One can fit a model without an intercept, ... Neither of course will the linear model without intercept ... I interpreted the OP's question as one where he had noticed something that seemed silly, but there was nothing in his comments to suggest that his data was anywhere near this region of the parameter space. ...
    (sci.stat.math)
  • Re: compare slopes
    ... > So we have got two linear equations fro these two data sets. ... > want to compare the slopes of these two straight lines. ... intercept, and a significant value for d would indicate a change in slope. ...
    (sci.stat.edu)

Loading