Skip to content

Plotting Confidence Intervals

5 messages · Andre Roldao, Kehl Dániel, Jim Lemon +1 more

#
Hi Guys,

It's the first time i use R-Help and i hope you can help me.

How can i plot conffidence intervals? with the data bellow:

#Package Austria
library(car)
#head(States)
States1=data.frame(States)

ines=lm(SATM ~ log2(pop) + SATV , data=States1)
summary(ines)

NJ=as.data.frame(States["NJ",c(4,2,3)]) #Identifica??o do estado NJ


p_conf<- predict(ines,interval="confidence",NJ,level=0.95)
p_conf #Intervalo de confian?a para o estado NJ e para um nivel de 95%
round(p_conf, digits=3)

p_conf1<- predict(ines,interval="confidence",NJ,level=0.99)
p_conf1 #Intervalo de confian?a para o estado NJ e para um nivel de 99%
round(p_conf, digits=3)

p_pred2<- predict(ines,interval="prediction",NJ,level=0.95)
p_pred2 #Intervalo de perdi??o para o estado NJ e para um nivel de 95%
round(p_pred2,digits=3)

p_pred3<- predict(ines,interval="prediction",NJ,level=0.99)
p_pred3 #Intervalo de perdi??o para o estado NJ e para um nivel de 99%
round(p_pred3,digits=3)

Thanks
#
Hi Andre,

I think you'll have to give some more information about what you want to see on your plot. The 4 intervals with labels? A bar with an interval maybe? Four bars with the intervals? Only two showing differences between conf and pred intervals?

Also you do miss a 1 here I guess:

p_conf1<- predict(ines,interval="confidence",NJ,level=0.99)
p_conf1 #Intervalo de confian?a para o estado NJ e para um nivel de 99%
round(p_conf, digits=3)

last line should read p_conf1 here?

Best,
d
________________________________________
Felad?: R-help [r-help-bounces at r-project.org] ; meghatalmaz&#243;: Andre Roldao [andre.rafael.roldao at gmail.com]
K?ldve: 2015. m?jus 2. 4:49
To: r-help at r-project.org
T?rgy: [R] Plotting Confidence Intervals

Hi Guys,

It's the first time i use R-Help and i hope you can help me.

How can i plot conffidence intervals? with the data bellow:

#Package Austria
library(car)
#head(States)
States1=data.frame(States)

ines=lm(SATM ~ log2(pop) + SATV , data=States1)
summary(ines)

NJ=as.data.frame(States["NJ",c(4,2,3)]) #Identifica??o do estado NJ


p_conf<- predict(ines,interval="confidence",NJ,level=0.95)
p_conf #Intervalo de confian?a para o estado NJ e para um nivel de 95%
round(p_conf, digits=3)

p_conf1<- predict(ines,interval="confidence",NJ,level=0.99)
p_conf1 #Intervalo de confian?a para o estado NJ e para um nivel de 99%
round(p_conf, digits=3)

p_pred2<- predict(ines,interval="prediction",NJ,level=0.95)
p_pred2 #Intervalo de perdi??o para o estado NJ e para um nivel de 95%
round(p_pred2,digits=3)

p_pred3<- predict(ines,interval="prediction",NJ,level=0.99)
p_pred3 #Intervalo de perdi??o para o estado NJ e para um nivel de 99%
round(p_pred3,digits=3)

Thanks


______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
#
Hi Kehl,

First i would like to thank you for the support.

to respond your question i want rather the 4 intervals with the labels, but
another one with the 4 bars with the intervals, it was fantastic!

Thank you again!

2015-05-02 9:24 GMT+01:00 Kehl D?niel <kehld at ktk.pte.hu>:

  
  
#
Hi Andre,
Perhaps you want something like this:

plot(c(p_conf[1],p_conf1[1],p_pred2[1],p_pred3[1]),xaxt="n",
 xlab="Model",ylab="Estimate")
axis(1,at=1:4,labels=c("p_conf","p_conf1","p_pred2","p_pred3"))
library(plotrix)
dispersion(1:4,c(p_conf[1],p_conf1[1],p_pred2[1],p_pred3[1]),
 ulim=c(p_conf[3],p_conf1[3],p_pred2[3],p_pred3[3]),
 llim=c(p_conf[2],p_conf1[2],p_pred2[2],p_pred3[2]),interval=FALSE)

Jim


On Sun, May 3, 2015 at 12:16 AM, Andre Roldao
<andre.rafael.roldao at gmail.com> wrote:
#
Have you tried:

library(effects)
plot(allEffects(ines),ylim=c(460,550))


-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Andre Roldao
Sent: Saturday, 2 May 2015 2:50p
To: r-help at r-project.org
Subject: [R] Plotting Confidence Intervals

Hi Guys,

It's the first time i use R-Help and i hope you can help me.

How can i plot conffidence intervals? with the data bellow:

#Package Austria
library(car)
#head(States)
States1=data.frame(States)

ines=lm(SATM ~ log2(pop) + SATV , data=States1)
summary(ines)

NJ=as.data.frame(States["NJ",c(4,2,3)]) #Identifica??o do estado NJ


p_conf<- predict(ines,interval="confidence",NJ,level=0.95)
p_conf #Intervalo de confian?a para o estado NJ e para um nivel de 95%
round(p_conf, digits=3)

p_conf1<- predict(ines,interval="confidence",NJ,level=0.99)
p_conf1 #Intervalo de confian?a para o estado NJ e para um nivel de 99%
round(p_conf, digits=3)

p_pred2<- predict(ines,interval="prediction",NJ,level=0.95)
p_pred2 #Intervalo de perdi??o para o estado NJ e para um nivel de 95%
round(p_pred2,digits=3)

p_pred3<- predict(ines,interval="prediction",NJ,level=0.99)
p_pred3 #Intervalo de perdi??o para o estado NJ e para um nivel de 99%
round(p_pred3,digits=3)

Thanks


______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.