ANOVA Results and Interaction Plot


#1

I have data that has two explanatory variables: race and hometown, and the response variable is a number from 0-40. When I input this code:

Anova(intanova, type = 3, singular.ok = TRUE)

I get this:

Anova Table (Type III tests)

Response: Total Sum Sq Df F values Pr(>F)
Race 8.00 1 0.1958 0.65963
Hometown 0.00 0
Race:Hometown 352.65 2 4.3155 0.01745 *

Residuals 2614.96 64
Signif. codes: 0 ‘’ 0.001 ‘’ 0.01 ‘’ 0.05 ‘.’ 0.1 ‘ ’ 1

I'm not sure why "Hometown" has 0 degrees of freedom. The options for Race were black, white, and other. The options for Hometown were out of state, out of country, and Texas.

I also need to create an interaction plot for this set of data, but because my categories of “Out of State” and “Out of Country” don’t have any “black” data points for the race, so the keeps overlapping on my axis for the plot and I’m not sure how to fix it.

This was the code I used:

Hometown.Texas <- nrk552[nrk552Hometown=="Texas",]Hometown.OutofState<−nrk552[nrk552Hometown == "Out of state", ] Hometown.OutofCountry <- nrk552[nrk552$Hometown == "Out of country", ]

install.packages("gplots") library(gplots)

plotmeans(Total ~ Race, data = Hometown.Texas, n.label = F, col = "black", barcol = "black", pch = 20, main = "Total Stress Score by Hometown and Race", ylab = "Hometown", ylim = c(-100 , 100), xlab = "Race") plotmeans(Total ~ Race, data = Hometown.OutofState, n.label = F, add = T, col = "red", barcol = "red", pch = 20) plotmeans(Total ~ Race, data = Hometown.OutofCountry, n.label = F, add = T, col = "blue", barcol = "blue", pch = 20) legend("bottomright", inset = 0.01, title = "Hometown", c("Texas", "Out of state", "Out of country"), fill = c("black", "red", "blue"), cex = 0.8)

Any help would be greatly appreciated, thanks so much!


#2

A few tips to hopefully help you get useful help faster! The overall message is: helpers want to help, but they are busy — so make things easy for them :grin:

  • This question seems to be about R in general, not the RStudio IDE (what's the difference?), so you might consider changing the category to attract helpers with relevant interests
  • It looks like you also posted this question to Cross Validatedthis site's cross-posting policy discourages posting at more than one site at once. If you do it, it's very important that you say so up front.
  • It's hard to read and absorb code that isn't formatted as code. A little formatting :sparkles: keeps would-be helpers from recoiling at a confusing wall o' text.
  • It's also really helpful to add formatting :sparkles: to console output. After you've pasted in the output, select it and click the </> button in the little bar at the top of the text area.

Finally, and most importantly:

  • Give people enough info to reproduce your problem without guesswork. It's difficult to know for sure what's going on here without seeing the data — or at least a sample or numerical summary of the data — and the code that created the intanova model object used in your call to Anova().

All that being said... depending on how you fit your model, this:

might be causing more problems than just plotting headaches.