[R] A smal fitting problem...

Eik Uni vettorazzi at econ.uni-hamburg.de
Fri Dec 8 13:37:09 CET 2006


If you really want to fit a horizontal line then the best estimate 
(meaning least squares) for b is mean(y), regardless of the actual x 
values, which becomes clear if you look at your design matrix / 
regressor matrix  .
In general least squares regression could be done with lsfit(). In your 
case the design matrix (X matrix) is a simple vector of ones.


Kåre Edvardsen schrieb:
> Dear R-helpers,
>
> I'm for sure not familiar with R, but it seem like a nice sofware tool,
> so I've decided to try using it.
>
> Here is my problem I just can't figure out:
>
> I'd like to do least square fit of a straight horizontal (a = 0) line y
> = ax + b through some data points
>
> x = (3,4,5,6,7,8)
>
> y = (0.62, 0.99, 0.83, 0.69, 0.76, 0.82)
>
> How would i find b?????
>
> All the best,
> Ked
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list