Saraswathi Analytics provides Visual Analytics Week 12 solution (Visual Analytics - 202051 - CRN140).

Plotting Marginal Effects

  1. load the margins library
  2. create a new column called called polviews_m to use Moderate as a reference category using relevel on the polviews column of the gss_sm data.
  3. use glm() to create a model called out_bo using logistic regression of polviews_m with sex and race showing an interaction glm(obama~ polviews_m + sex*race, family = “binomial”, data = gss_sm).
  4. use summary() on out_bo to see what the results look like
  5. calculate the marginal effects of each variable and store that in a variable called bo_m.
  6. plot(bo_m) to see a graph of the results
  7. create a tibble called bo_gg of the summary() of bo_m, create a vector of the prefixes ‘polviews_m’ and ‘sex’. And, remove the prefixes from the factor column and replace ‘race’ with ‘Race:’ in the factor column. Finally, limit the contents of the bo_gg attributes to ‘factor’, ‘AME’, ‘lower’, and ‘upper’.
  8. Plot the average marginal effects with a point and the upper and lower bounds with whiskers

Submit by Sunday at midnight a Word document with screen shots of your work with a slice of your desktop and text. Explain what each image is.

Note:

  • Only for knowledge gain and helping to the students(who are facing difficulties when solving to the Assessments/ Home works) with their course support.

Contact Us: