kosukeimai / wru

Who Are You? Bayesian Prediction of Racial Category Using Surname and Geolocation
129 stars 30 forks source link

Error in fBISG when using 'place' #129

Closed DianaDaInLee closed 6 months ago

DianaDaInLee commented 10 months ago

My dataset includes place FIPS along with full names, and I'm trying to use fBISG to generate predictions as follows:

df <- data.frame(place = '01000', state = 'NY', first = 'richard', surname = 'smith')
predict_race(voter.file = df,
             names.to.use = 'surname, first',
             census.geo = 'place', 
             census.key = '...', 
             model = 'fBISG',
             surname.only = FALSE,
             impute.missing = TRUE)

But it results in the following error which mentions 'county', which shouldn't be relevant if you're using place fips?

Error in split.default(voter.file$county, voter.file$state) : 
  first argument must be a vector
1beb commented 7 months ago

Hi Diana, I will take a look at this after the next release goes through. Does your voter file not include state and county?

DianaDaInLee commented 7 months ago

Thank you --- it includes state and place fips, but not county. Interestingly, the function works when I generate an empty county field: df$county <- "".

1beb commented 6 months ago

I'm going to close this one. It sounds like you may have created a custom census data object and missed out on some requirements that the software expects. If you feel like this isn't the case, let me know.