代写辅导接单-Homework #6

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top

# Initialize Otter import otter grader = otter.Notebook("hw6.ipynb") ## Homework #6 *Please edit the cell below to add your name, NetID, and any group members that you collaborated with on this assignment.* **Complete this section before proceeding to the assignment questions.** Name: NetID: Group Members: *** # Set random seed and ensure plots are displayed in the notebook import numpy as np import pymc as pm import arviz as az np.random.seed(5) %matplotlib inline %config Inline.figure_format = 'retina' az.rcParams["stats.hdi_prob"] = 0.89 # sets default credible interval used by arviz def standardize(series): """Standardize a pandas series""" return (series - series.mean()) / series.std() <!-- BEGIN QUESTION --> **Question 1**. In 2014, a paper was published that was entitled “Female hurricanes are deadlier than male hurricanes.” As the title suggests, the paper claimed that hurricanes with female names have caused greater loss of life, and the explanation given is that people unconsciously rate female hurricanes as less dangerous and so are less likely to evacuate. Statisticians severely criticized the paper after publication. Here, you’ll explore the complete data used in the paper and consider the hypothesis that hurricanes with female names are deadlier. Load the data as follows: `df = pd.read_csv("Data/hurricanes.csv")` The columns have the following meaning: ``` *Description* Data used in Jung et al 2014 analysis of effect of gender of name on hurricane fatalities. Note that hurricanes Katrina (2005) and Audrey (1957) were removed from the data. name : Given name of hurricane year : Year of hurricane deaths : Number of deaths category : Severity code for storm min_pressure : Minimum pressure, a measure of storm strength; low is stronger damage_norm : Normalized estimate of damage in dollars female : Indicator variable for name categorized as "female" femininity : 1-11 scale from totally masculine (1) to totally feminine (11) for name. Average of 9 scores from 9 raters. *Reference* Jung et al. 2014. Female hurricanes are deadlier than male hurricanes. PNAS. ``` In this problem, you’ll focus on predicting deaths using the femininity score of each hurricane’s name. * Fit the simplest possible model, a Poisson model of deaths using femininity (**after standardization**) as a predictor. * **Compare the predictive ability of the hurricane name femininity model** to an intercept-only Poisson model of deaths. The intercept-only model will only consider single intercept parameter representing the average number of deaths on the log scale. Be sure to use the predictive criteria covered earlier in the semester to answer this question. * **Plot the posterior predictive distribution** (posterior mean, uncertainty of posterior mean, and uncertainty of the observations) for the name femininity model as well as the observed data points and evaluate the effectiveness for this model to predict storm deaths. Then answer the following questions: * Based on the model estimates, how strong is the association between femininity of storm name and deaths? The response to this question should be based on a parameter estimate from your model. **Be sure to reference the estimated association (quantitatively) in your answer.** * Which storms does the model including femininity fit poorly? *Reviewing the prediction tutorial from earlier in the semester will be beneficial for answering this question and the following one. Focus on the storm's femininity score as the characteristic for assessing how well the model fits the data. Considering the number of deaths observed for the storms that the model predicts poorly will help to understand the predictive ability of these models.* * What can we infer about the predictive ability of the femininity model based on the storms that the model fits poorly? **Be sure to justify the priors used in your models for this problem using a prior predictive simulation.** _Hint_: for an intercept-only model, a good way to analyze the priors is to view the distribution of the estimates for the intercept parameter (average number of deaths) using a histogram or kdeplot. _Type your answer here, replacing this text._ # Write code here <!-- END QUESTION --> <!-- BEGIN QUESTION --> **Question 2**. In the trolley data — `Data/Trolley.csv` — we saw how education level (modeled as an ordered category) is associated with responses. But is this association causal? One plausible confound is that education is also associated with age through a causal process: People are older when they finish school than when they begin it. Reconsider the trolley data in this light. * Include a DAG (**save the file as a PNG file named "dag.png"**) that represents hypothetical causal relationships amongst response, education, and age based on the association described above. You can ignore any other variables in this DAG. **Clearly identify what each variable in your DAG represents**. * **State** which statical model (or models) you need to evaluate the causal influence of education on responses and **explain your choice**. Then, approximate the posterior distribution for the parameters of the model(s) using the trolley data. Include the treatment combinations (Action, Intention, Contact) in your model(s) as a competing cause as shown in lecture. * Answer the following questions in your solution: What do you conclude about the causal relationship between education and response? What do you conclude about the causal relationship between age and response? Be sure to support your conclusions **with plots** of your model's parameter estimates. _Type your answer here, replacing this text._ # Write code here grader.check("q2") <!-- END QUESTION --> ## Submission Make sure you have run all cells in your notebook in order before running the cell below, so that all images/graphs appear in the output. The cell below will generate a zip file for you to submit. **Please save before exporting!** # Save your notebook first, then run this cell to export your submission. grader.export(run_tests=True, files=['dag.png'])  

51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468