Dear R users,

experimenting with the lm function in R, I've encountered some  
behaviour I don't understand with my limited knowledge of regression.

I made a data-'set' of three measurements (see syntax below). Using  
lm (linear model) to fit the regression-line, I expected to find an  
intercept of 2.0 and a slope of 0, but in fact the slope is slightly  
below zero. Amazed by this behaviour, I decided to shift the  
measurements towards each other, create a model using lm and analyse  
the resulting slopes. Plotting these, I found that they are  
increasingly deviant from zero when the difference between the three  
values is smaller. More fascinating, some of the slopes seem to be  
relatively large in comparison with other resulting slopes (sort of  
outliers).

How is this possible? Is this a rounding-problem or is it the way R  
creates the linear model? Using SPSS results in b-values of zero. I'm  
using R 2.3 on MacOS 10.4.6, on a G4 processor. The syntax I used is  
printed below.

Any explanations of this behaviour are really appreciated.

Rense Nieuwenhuis

#--------------------------

x <- c(0,1,1)
y <- c(2,1,3)
plot(x,y)
b <- 1
length <- 100

for(i in 1:length) {
	x[1] <- i/length
	model <- lm(y~x)
	b[i] <- model$coefficients[2]
	}

plot(b)

#----------------
	[[alternative HTML version deleted]]


