0
$\begingroup$

If I have the attached file of 100 people with this dataset with the following demographics/regions:

  • Region: Center: 12%, East: 62%, West: 26%
  • Sex: Female: 82%, Male: 18%
  • Party: D: 89%, R: 4%, O: 7%
  • Race: Black: 41%, Caucasian: 56%, Hispanic: 3%

If I load that into R to create a linear regression model based off the support column, is there a way for me to weight those results to fit these demographics/regions?

  • Region: Center: 14%, East: 50%, West: 36%
  • Sex: Female: 82%, Male: 18%
  • Party: D: 60%, R: 26%, O: 14%
  • Race: Black: 25%, Caucasian: 72%, Hispanic: 3%

In the same attached file, there are breakdowns of all four of these criteria in the unweighted tab (first dataset) and weighted tab (second dataset).

Also this would ideally be in R since this is where I'd create the model -- but open to doing something somewhere else too if it makes a big difference.

--

EDIT: Original post had age as a criteria which was removed to make the example less complicated.

$\endgroup$
7
  • $\begingroup$ This also seemed like a better fit for Cross Validated than somewhere like Stack Overflow, but please let me know if I'm mistaken and will happily move it. Thanks! $\endgroup$
    – Ryan
    Nov 14, 2016 at 20:37
  • $\begingroup$ Did you run logistic or simple linear regression? $\endgroup$
    – Nik Tuzov
    Nov 14, 2016 at 20:39
  • $\begingroup$ @NikTuzov Logistic -- but also super interested to hear about how weighting these numbers would be different pending the type of regression, since I'd need to do that in both forms. $\endgroup$
    – Ryan
    Nov 14, 2016 at 20:43
  • $\begingroup$ @NikTuzov Do you know anything about this? docs.google.com/… Closest I could find but I don't think I'm as well versed in R yet to read this and fully understand how it'd do what I'm asking. $\endgroup$
    – Ryan
    Nov 14, 2016 at 23:08
  • $\begingroup$ What is your goal? Is it to fit the model on the first dataset, and then get the predicted values for the second dataset? $\endgroup$
    – Nik Tuzov
    Nov 15, 2016 at 20:54

1 Answer 1

1
$\begingroup$

If you have only the first data set, then in order to predict the number of "Yes" responses for the second data set, more information is needed. For instance, if we looked just at Gender, then it's possible to estimate $P\{Yes | Male\}$ and $P\{Yes | Female\}$ from the first data set. Since the number of males and females in the 2nd data set is known, it's possible to use that information to predict "support". If you want to consider more factors, it becomes hard/impossible. E.g. if Region is also of interest, then for the 2nd data set you need to know the count of males and females by the region. If you want to consider all five factors, then you need to know the count of people in each of 3*2*4*3*3 cells of the 5-dimensional table that describes the 2nd dataset.

$\endgroup$
9
  • $\begingroup$ Thanks! And yes -- if I do know all the breakdowns from the first and the second dataset, is it possible to lay out how to effectively do something like this in R before running the logistic regression? I can do whatever breakdowns are necessary to make it work -- it's all the same dataset I attached in the question. The first layout of numbers is what I got back and the second set is how I'd like them weighted before creating the model. Happy to provide additional information if it helps -- but would love to know how it's done assuming I do have all the breakdowns. $\endgroup$
    – Ryan
    Nov 16, 2016 at 23:14
  • $\begingroup$ This is the dataset again: drive.google.com/file/d/0B5bpg7DkSUq0VlRZNTU5VHFENVE/view -- and if a five-dimensional table is too much to do, I can extrapolate on my own if we just want to do do weights by gender and region, for example. But would love to get help since I'm stuck on the workflow in R. Can get the data, can run the model, and predict support -- but not based on the needed weights. And it's fine if doing this increases my standard error. Thanks again! $\endgroup$
    – Ryan
    Nov 16, 2016 at 23:17
  • $\begingroup$ Here's actually a new link to the unweighted and weighted samples with four of the criteria above (removed age to make it less complicated): docs.google.com/spreadsheets/d/… $\endgroup$
    – Ryan
    Nov 17, 2016 at 15:02
  • $\begingroup$ (Hope this is my last comment on this!) But I also know my unweighted sample is missing some necessary regions, so if it's possible to still get help on doing this just on sex, party, and race, that'd be great. Thanks again! $\endgroup$
    – Ryan
    Nov 17, 2016 at 15:06
  • $\begingroup$ If you know all of the breakdowns for the 2nd dataset, then you can train the model on the first dataset and use "predict" function to estimate Support for the 2nd dataset. That is, you don't have to weight anything. The general usage is shown here: theanalysisfactor.com/r-tutorial-glm1 $\endgroup$
    – Nik Tuzov
    Nov 17, 2016 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.