How do i create "nice" prediction hyperbola?

#1
I would like to create a nice prediction hyperbola in my regression analysis, at this moment i am only getting some rather ugly ones and only where i have observations.

Code:
model <- lm(control~treatment)
new.data<-data.frame(control)
 predict(model,newdata=new.data,interval='prediction')
preds<-predict(model,newdata=new.data,interval='prediction')
for (i in 1:dim(new.data)[1]){lines(new.data$control[c(i,i)],preds[i,2:3],col='grey',lty=3,lwd=4)}
How can i get it so i see some nice lines rather than more "dots" ?

Thank you :)
 

Dason

Ambassador to the humans
#2
What does your data look like? Are both variables continuous? Also this isn't related by why are you fitting control by treatment?

You typically want to avoid using loops if at all possible and this especially holds true when using the lines function.

But something like this might be what you want.

Code:
plot(treatment,control)
lines(treatment,preds[,1])
lines(treatment,preds[,2], col = 'grey',lty=3,lwd=4)
lines(treatment,preds[,3], col = 'grey',lty=3,lwd=4)
To get a somewhat better fit you should probably try to do predictions for the entire range of your x variables. So instead of just using the x variable for the predictions stick in a vector that looks something like
xs <- seq(#insert_minimum_x, #insert_maximum_x, by = #insert_spacing_you_want)
and use that in the predictions as your new data instead. Using something like .1 for the by will probably be good enough. If you do this then where I have "treatment" in the lines commands you would replace with "xs".
 
#3
The data are "continous", by which i mean 3 decimals, and all between 3 and 7. I am really just using that particular fit because it was a dataset i had already loaded, i am writting notes for my statistics class in LaTex and would like some nice graphics to go along with it.

The code you posted doesnt quite seem to get lines going as far as i could tell it still plots only "spots" rather than lines and only where i have observations(where in my code is it this is set?)

Thanks :)
 

Dason

Ambassador to the humans
#4
The code you posted doesnt quite seem to get lines going as far as i could tell it still plots only "spots" rather than lines and only where i have observations(where in my code is it this is set?)
Do you do as I suggested and create an xs vector? That should get you the lines for the entire range of the data. If you're talking about the confidence bands only being at certain spots then remove the lty option in the lines. lty=3 tells it to create those dotted lines. If you remove that it will create a solid line.