Re: OLS with factors and one common intercept
- From: "John D'Errico" <woodchips@xxxxxxxxxxxxxxxx>
- Date: Wed, 4 Feb 2009 17:58:01 +0000 (UTC)
"Rogelio" <rogelio.a.mancisidor@xxxxxxxxxxxxx> wrote in message <gmck8q$s35$1@xxxxxxxxxxxxxxxxxx>...
"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???
What are you talking about? This IS a least squares
estimator. In fact, it will give the same estimate as
any other OLS tool on this data. If you wanted more
than just the parameter estimates, why did you not
say that?
Yes, of course you can use the stats toolbox. Look
at regress.
John
.
- References:
- OLS with factors and one common intercept
- From: Rogelio
- Re: OLS with factors and one common intercept
- From: John D'Errico
- Re: OLS with factors and one common intercept
- From: Rogelio
- OLS with factors and one common intercept
- Prev by Date: Re: Using ODE45
- Next by Date: Re: binarizing an image help
- Previous by thread: Re: OLS with factors and one common intercept
- Next by thread: Re: OLS with factors and one common intercept
- Index(es):
Relevant Pages
|
Loading