Given you had a large dataset of people with a name and country. How would you calculate an estimate of the origin country from one of the names? If i looked up a name, Kim and just averaged the rows from each country, it seems to me that my numbers would be skewed since the dataset might contain a lot more names from a given country in the first place. How can i make up for this uncertainty?
Welcome to the site.
I am not sure what you mean when you write "averaged the rows from each country". You can't average countries.
If your data set is a random selection of the world's population (lots of luck a true random sample of that!) then you can say, for each name, what proportion are from each country. You can also say, for each country, what proportion of people have each name.
But I don't see any sort of average you could take here.
You have a lot of rows with names and states. The number of rows don't seem to match the size of the population of the state. You need to standardize the results.
In order to move forward we need to assume that the sample you have is random. If its not then this method may be flawed.
Here is how I would do it: Count the rows of the name and sum it up by state. Divide the sum of the name rows with the total number of rows of the state. The resulting number have to be standardized. I recommend using the population of the state as a weight. The standardization is done by multiplying the resulting number of the former division with the population of the state. Now you get a state by state comparable number. The next step is to do this calculation for the same name in every country. Calculate the sum of the comparabe numbers for each name in each state and divide each comparable number by the sum and multiply by 100. Now you get the percentage point that the name is from the specific country in question. The total percentage points for each name should equal 100 %.
Now, if you have a name and asks yourself which state this name comes from, you should have the probabilities from the above calculations.
It sounds you want this: If you were to imagine all countries on the planet did not exist except for the UK (as an example) because, let's say...aliens invaded and took everyone else out (but the UK didn't know about it and never will because they live in a giant impenetrable bubble they don't know about - just making sure that our aliens are not messing with your results - at least as you survey their first names - so that the element of "randomness" is upheld....then again maybe you wanted the data only for that time period. Or after. Because the first name ratios may change if they got inside the bubble ....unless they took everyone out at complete random too, then you'd be fine.)
And then you go to the UK and met someone there at random. You want to know what the probability is that their name would be, for example, "Sam".
Essentially, the probability for each country for a given name.
Is this correct?
If so, then you can either
A) Find this data online already if you looked hard enough (opendata.stackexchange.com may help)
B) Or if you want to generate the values yourself (and depending upon your needed accuracy)...then the database you're using has to be very accurate (or actually just also completely random as well as big enough to also be big enough for you - I don't know how to calculate that metric.) and your first name data has to be completely random or at least completely randomly drawn from whichever specific countries your first names come from - there can be absolutely nothing in common with between who your first names represent or where they came from besides the fact that they were all random and thus will likely have random similarities (lol). Then again these rules lax depending upon how accurate you need/want to be.
You'd just do exactly what you said to get the best possible guess from the amount of names you have.
For each name you put in that is from the UK, record that that name appeared once and someone from the UK's population appeared once.
At the end, assuming you went through enough names for each countries sample size requirements (and your p value requirements are achieved, which is the probability that your conclusions/results occurred strictly by chance and you cannot trust your data, it's usually put at around .05 or 5%...there's also a confidence interval around that, but I don't think you need to worry about it much...you probably have enough names...maybe).
Then, as you said before, divide the number of unique names you recorded for each name for each country by the number of times you recorded that anyone's name appeared from that country.
(number of times the name "Sam" appeared and lived in the UK) ----------------------------------------------------------- (number of times any name appeared that lived in the UK)
The probability that name ("Sam") would be randomly selected from the population of that country (the UK here).
This has a p value in a -/+ confidence interval. The p value is probably 5% if that's what you chose (5% is "generally considered" to be acceptable that you're data is not wrong) when figuring out how many names you'll need. It is probably in a +/- confidence interval of 2.5% (also common figure) if that is also what you chose when figuring out how many names you'll need.