Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The data for this homework first appear in Gentzkow and Shapiro ( 2 0 1 0 ) and summarize the first year of the 1
The data for this homework first appear in Gentzkow and Shapiro and summarize the first year of the th Congressional Record containing all speech in that year for members of the US house and senate It is stored in the textir package in R in two separate datasets. Use the following lines of code to load the data.
librarytextir
datacongress
The text is already tokenized into bigrams twoword phrases after stopword removal and stemming using a Porter stemmer The matrix congressCounts contains the number of times each phrase in a list of common bigram and trigrams was used in the th Congress by each of the members of the House and Senate.
congressCountscBarack Obama", "John Boehner":
times sparse Matrix of class "dgCMatrix"
stem.cel natural.ga hurricane.katrina trade.agreement
Barack Obama
John Boehner
The data also contain information about each member of Congress.
congressIdeology:
name party state chamber repshare cs cs
Chris Cannon Chris Cannon R UT H
Michael Conaway Michael Conaway R TX H
Spencer Bachus Spencer Bachus R AL H
Mac Thornberry Mac Thornberry R TX H
We will be considering the variable repshare which is the proportion of the two party vote by the members constituents districts for members of the house, state for senators that was captured by the republican candidate GW Bush in the presidential election.
Use the following line of code to create a matrix with an indicator for whether each bigram was used or not.
x congressCounts
Then, set the seed to load the textvec library, and fit a topic LDA model.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started