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.
let me clarify, i understand what differing x, y lengths mean. i understand the concept of average effects, etc. i just don't understand how one would fix it. thanks. -- View this message in context: http://r.789695.n4.nabble.com/plotting-average-effects-tp3923982p3924003.html Sent from the R help mailing list archive at Nabble.com.
Hi Denins, and thanks for your reply. I understand x,y are not lining up. I just don't know how to fix it in the code. There is only a small group of us at my university using R (4 people of which I am one). 2 are not even touching the average effects plot option, however myself and my study partner feel it is best. So, we really don't have anyone to ask. Everyone else in our class was taught on STATA. The reasons why are sort of complicated and I don't wish to bore you with details. Basically, we were the first group to be trained using R. This is our 3rd semester using it. Is there an online guide anywhere that will describe exactly what is going on in the plot function for average effects? I have been googling and have not come across anything useful, except this site. ----- Ph.D. Candidate -- View this message in context: http://r.789695.n4.nabble.com/plotting-average-effects-tp3923982p3925293.html Sent from the R help mailing list archive at Nabble.com.
How about posting a reproducible sample, so that we can see what is going on? Read the posting guide!!! -- View this message in context: http://r.789695.n4.nabble.com/plotting-average-effects-tp3923982p3925324.html Sent from the R help mailing list archive at Nabble.com.
Bart, I apologize. I posted the code I was using in my first comment, to include the error and the plot that is coming up. I was unaware that was not enough. I am not looking for anyone to give me the actual answer to my specific issue, only looking to be pointed in a direction for an online guide that i can read to understand how average effects are plotted in R. Our text book doesn't cover any topics for using R, only theory. ----- Ph.D. Candidate -- View this message in context: http://r.789695.n4.nabble.com/plotting-average-effects-tp3923982p3925350.html Sent from the R help mailing list archive at Nabble.com.