[R] A smal fitting problem...

2006-12-08 Thread Kåre Edvardsen
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@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.


Re: [R] A smal fitting problem...

2006-12-08 Thread Eik Uni
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@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.


__
R-help@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.


Re: [R] A smal fitting problem...

2006-12-08 Thread David Barron
b = mean(y)

On 08/12/06, Kåre Edvardsen [EMAIL PROTECTED] wrote:
 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@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.



-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

__
R-help@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.


Re: [R] A smal fitting problem...

2006-12-08 Thread Michael Kubovy
On Dec 8, 2006, at 7:42 AM, David Barron wrote:

 b = mean(y)

 On 08/12/06, Kåre Edvardsen [EMAIL PROTECTED] wrote:
 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?

And in the context of linear models:
x - 3:8
y - c(0.62, 0.99, 0.83, 0.69, 0.76, 0.82)
lm(y ~ 1)
_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

__
R-help@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.