I\'m working on a state and year fixed effects regression, which has 3 observations per state/year combo based on the race for that row (white, black, other) - See link belo
The plm
function needs just one pair of id/time. For each id you supplied you have more than one year.
If each st_name
and race
pairs form an "individual" (or whatever the name you give to this dimension of the panel), then you could do:
library(dplyr)
my.data$id <- group_indices(my.data, st_name, race)
#which would be the same as my.data <- my.data %>% mutate(id = group_indices(st_name, race)), if this function supported mutate.
plm.reg <- plm(drugcrime_ar ~ decrim_dummy + median_income + factor(race),
data = my.data, index=c("id","year"), model = "within",
effect = "twoways")
See, however, that in this situation you are not using a kind of nested panel structure as @Helix123 suggested. You are only redefining the first dimension of the panel.