[R] A smal fitting problem...

Michael Kubovy kubovy at virginia.edu
Fri Dec 8 15:34:37 CET 2006


On Dec 8, 2006, at 7:42 AM, David Barron wrote:

> b = mean(y)
>
> On 08/12/06, Kåre Edvardsen <ked at nilu.no> 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 400400    Charlottesville, VA 22904-4400
Parcels:    Room 102        Gilmer Hall
         McCormick Road    Charlottesville, 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/




More information about the R-help mailing list