[R] plot out the predicted values and the upper and lower limits

Rolf Turner r.turner at auckland.ac.nz
Wed Feb 26 22:32:50 CET 2014

On 27/02/14 05:43, varin sacha wrote:

> Many thanks Rolf,
> These codes below are ok :
> LinearModel.1 <- lm(GDP.per.head ~ Competitivness.score +
> Quality.score, data=Dataset)
> summary(LinearModel.1)
> predict(LinearModel.1, se.fit = FALSE, scale = NULL, df = Inf,interval =
> c("prediction"),level = 0.95, type = c("response"))
> One problem remains : If I want to plot out (in a same
> graph) the predicted values as well as the upper and lower limits of the
> prediction intervals for those values. How can I do, many thanks once more.

This is very a very basic R plotting problem.  If you are going to use 
R, you should learn how to use R.  Your emails indicate that you haven't 
really got a clue. Read some of the excellent introductory material 
available from the R web page.  Start with a thorough read of "An 
Introduction to R".  Then have a look at some of the material available 
under "contributed documentation".  It will take a while but will be 
worth the effort if you wish to become anything like competent at using R.

I could tell you how to do the plot you want, in a few lines, but I am 
not going to.  You need to do some learning.



P. S. An indication that you haven't a clue is the fact that you use

	interval = c("prediction")

Just what on earth do you think that "c()" is doing for you here?  Learn 
what the c() function means and what its purpose is.  Don't just slap 
down bits of code in a higgledy-piggledy manner and hope that something 
will work.  Wrapping "prediction" in c() is harmless in this instance, 
but is unnecessary, redundant and confusing.  In general using 
inappropriate code that you don't understand will result in errors.


More information about the R-help mailing list