plot CI

#1
I am trying to do a CI plot as illustrated in book but I get an error..using the values from a previous thread question

str(predict(g,g1, se=TRUE))
List of 4
$ fit : Named num 28.1
..- attr(*, "names")= chr "1"
$ se.fit : num 4.97
$ df : int 42
$ residual.scale: num 22.7
> grid<-seq(0, 100, 1)
P<-predict(g, data.frame(status=43, income=4.64, verbal=6.66, sex=grid, se=T, interval="confidence"))
> matplot(grid, p$fit, lty=c(1,2,2) xlab="average", ylab="male")


Error in p$fit : $ operator is invalid for atomic vectors
 

bryangoodrich

Probably A Mammal
#2
The first thing I notice is that your predict call is wrong. You're including the predict arguments within your data.frame. You need a closing parentheses after sex=grid and before se=T, not at the end as you have it now. If you're using RStudio to write your code, which I recommend, it'll automatically show you where your opening and closing parentheses is when your cursor is on it. Useful for checking syntax.