# question on plotting error values for treatment effects from multiple regression output

Say I have some data, where a dependent variable, dv, is a function of some independent variable, iv, and a categorical predictor, cat. Here are some example data below generated in R:

a<-c(1:100)
err<-rnorm(100,sd=30)
b<-a + err
c<-a + err + 20
cat1<-rep(0,100)
cat2<-rep(1,100)
iv<-c(a,a)
dv<-c(b,c)
cat<-c(cat1,cat2)
data<- data.frame(dv,iv,cat)


I then model dv as a function of iv and cat with this code:

summary(lm(dv~iv + cat, data=data))


and get the following output

                Estimate Std. Error t value Pr(>|t|)
(Intercept) -5.49606    5.09626  -1.078    0.282
iv           1.18250    0.07848  15.067  < 2e-16 ***
cat         20.00000    4.53086   4.414 1.67e-05 ***


Now, I want to plot the effect of cat using a standard bar graph- means and errors. So, based on the model, I calculate what the value of dv should be when cat is 0 and when cat is 1, using a common value of iv of 50. For my particular data set, I would get dv values of 53.62894 and 73.62894, for cat levels 0 and 1, respectively.

My question is: which term from the model should I use for the error bars? Should I just use the std error estimate of the cat predictor? Or something more complex that integrates the error values of the intercept and iv parameter as well?

Try the lsmeans package from R, which will calculate the expected value and the confidence limits:
lsmeans(mod,~iv + cat, at=list(cat=c(0,1), iv=50), data=data )
 iv cat   lsmean       SE  df lower.CL upper.CL