Hi everyone,
I'm having some trouble with the function lines() in R. Here is an example of the code:
<code>
x=rnorm(100)
y=10+2*x+pmax(x-0.5,0)+pmax(x-0.7,0)
model=lm(y~x+pmax(x-0.5,0)+pmax(x-0.7,0))
plot(x,model$fitted.values)
lines(x,model$fitted.values)
</code>
I want the function lines to draw a line through the datapoints. lines() does not seem to work here.. I can't use abline here, because I think it can only only straight lines
Anyone who knows what has gone wrong?
Thanks in advance,
Taibo
I'm having some trouble with the function lines() in R. Here is an example of the code:
<code>
x=rnorm(100)
y=10+2*x+pmax(x-0.5,0)+pmax(x-0.7,0)
model=lm(y~x+pmax(x-0.5,0)+pmax(x-0.7,0))
plot(x,model$fitted.values)
lines(x,model$fitted.values)
</code>
I want the function lines to draw a line through the datapoints. lines() does not seem to work here.. I can't use abline here, because I think it can only only straight lines
Anyone who knows what has gone wrong?
Thanks in advance,
Taibo
Last edited: