View the step-by-step solution to:

Matching on a Single Covariate To account for these differences in age across the two voter populations, let's try to 'control for' age via matching....

Screen Shot 2018-04-02 at 21.36.46.png

I need help creating a function that takes an age value and returns the ID of a randomly chosen non-contacted adult with the same age.

Screen Shot 2018-04-02 at 21.36.46.png

Matching on a Single Covariate To account for these differences in age across the two voter populations, let's try to ‘control for‘ age via matching. That is, for each contacted voter, we'll find a
non-contacted voter with the same age, and use the set of matched non-contacted voters as our comparison group. First let's assign lD's to people in the control group. It will soon become clear why we‘re doing this. In [82]: #add ID column
noncontacted = noncontacted.with_column( 'id' , np.arange(noncontacted.num_rows))
noncontacted Out[82]: contact vote02 vote98 newreg age female county id 0 1 0 0 68 1 44 0
0 1 0 0 31 0 44 1
0 1 1 0 71 1 44 2
0 0 0 0 45 0 44 3
0 1 0 0 50 0 44 4
0 1 0 0 39 1 44 5
0 1 0 0 64 1 44 6
0 0 1 0 49 0 44 7
0 0 0 0 30 0 44 8
0 0 0 0 49 1 44 9 (14502 rows omitted)

Top Answer

Below is the logic for the program. Let me know if you have any doubts. First subset the dataframe with the matched age then... View the full answer

2.PNG

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online