Re: OLS with factors and one common intercept
- From: "Rogelio" <rogelio.a.mancisidor@xxxxxxxxxxxxx>
- Date: Wed, 4 Feb 2009 17:46:02 +0000 (UTC)
"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???
.
- Follow-Ups:
- Re: OLS with factors and one common intercept
- From: Peter Perkins
- Re: OLS with factors and one common intercept
- From: John D'Errico
- Re: OLS with factors and one common intercept
- References:
- OLS with factors and one common intercept
- From: Rogelio
- Re: OLS with factors and one common intercept
- From: John D'Errico
- OLS with factors and one common intercept
- Prev by Date: Re: Motion sensor
- Next by Date: Re: No fixed arrays in Fortran / Mex possible?
- 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