plotting average effects.
hi... i am a phd student using r. i am having difficulty plotting average effects. admittedly, i am not really understanding what each of the commands mean so when i get the error i am not sure where the issue is. here is my code... i will include the points at which there are errors....
dat2 <- dat3 <- dat dat2$popc100 <- dat2$popc100 + 1000 dat2$popc100[which(dat2$popc100 > max(dat$popc100))] <- max(dat$popc100) dat3$popc100 <- dat$popc100 - 1000 dat3$popc100[which(dat3$popc100 < min(dat$popc100))] <- min(dat$popc100) pred1 <- predict(mod, type="response") pred2 <- predict(mod, newdata=dat2, type="response") pred3 <- predict(mod, newdata=dat3, type="response") pop.group <- cut(dat$popc100kpc, breaks=quantile(dat$popc100kpc, seq(0,1,by=.3)), include.lowest=T) means <- by(cbind(pred1, pred2, pred3), list(pop.group), apply, 2, mean) means <- do.call(rbind, means)
par(mar=c(7,4,4,2)) plot(c(1,10), range(c(means)), type="n", xlab="",
+ ylab="Predicted Probability", axes=F)
plot(c(1,10), range(c(means)), type="n", xlab="pop pc by 100k",
+ ylab="Predicted Probability", axes=F)
arrows(1:10, means[,1], 1:10, means[,2], code=2, length=.1) arrows(1:10, means[,1], 1:10, means[,3], code=2, length=.1, col="red") points(1:10, means[,1], pch=16)
Error in xy.coords(x, y) : 'x' and 'y' lengths differ as i understand it, i need to change the means[,1].... i have tried a few combos and i am not getting anywhere... further, my arrows are huge and points are not appearing in my plot. is there anywhere i can find a break down of each of these commands and what each part means? i understand the lengths, colors, xlab, ylab, etc etc. thanks in advance for any insight you can give me. http://r.789695.n4.nabble.com/file/n3923982/effplot_copy.jpg -- View this message in context: http://r.789695.n4.nabble.com/plotting-average-effects-tp3923982p3923982.html Sent from the R help mailing list archive at Nabble.com.