Raghu Naik
2009-Apr-07 16:53 UTC
[R] Comparing Sample / Population Geographic Distributions
I am trying to confirm that the sample is not different from the population with respect to geographical respresentation for the following data: region population sample n_total s_total 1 north 1244 232 9077 1032 2 south 4333 100 9077 1032 3 east 1500 200 9077 1032 4 west 2000 500 9077 1032 For example the first line of this data shows that our sample consisted of 232 individuals from the north that had a population of 1244. The table also shows that in total, we chose 1032 individuals (s_total) from a population size of 9077 (n_total). I thought that one way of doing that would be to run a logistic regression of sample / population proportion on region (north, south, east, west) and source (sample, population) and show that the source factor is insignificant. I am not exactly satisfied with the results with a huge residual deviance and a sample factor p value of 1.00. Therefore, I was wondering if there was a better approach of making such comparison. I would appreciate any suggestions. Raghu The data / logistic regression code is as below : ____________________________________________________ library(sqldf) mystring <- ("region, population, sample north, 1244, 232 south, 4333, 100 east, 1500, 200 west, 2000, 500") one <- read.table(textConnection(mystring),header=TRUE,sep=",") n_total <- sum(one$population) s_total <- sum(one$sample) one <- cbind(one,n_total,s_total) ; one two <- sqldf(" select population as count, n_total as total , 'population' as source, region from one union select sample as count, s_total as total, 'sample' as source, region from one " ) attach(two) prop <- count/total model1 <- glm(prop ~ source + region, weights=total, quasibinomial) [[alternative HTML version deleted]]
Reasonably Related Threads
- Undefined columns selected
- Graphically show population density for a specific geographic area using R
- ''$'' placeholder naming can confuse your runner
- getting all pairwise combinations of elements in a character string
- [klibc:update-dash] mystring: fix "Illegal number" on FreeBSD & macOS for x=; echo $((x))