Saraswathi Analytics provides Visual Analytics Week 12 solution (Visual Analytics - 202051 - CRN140).
Plotting Marginal Effects
- load the margins library
- 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.
- 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).
- use summary() on out_bo to see what the results look like
- calculate the marginal effects of each variable and store that in a variable called bo_m.
- plot(bo_m) to see a graph of the results
- 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’.
- 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.