Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN PYTHON PLEASE - using the packages matplotlib, munpy, pandas, and pyplot a) Write a function that takes the data frame as an input and

IN PYTHON PLEASE - using the packages matplotlib, munpy, pandas, and pyplot

a) Write a function that takes the data frame as an input and returns the difference on conditional probabilities. Test the function by calling it with your data and report the difference in probability This difference is your test statistics for the coming permutation test in part b

b) Perform a permutation test. Under the Null-hypothesis the director gender is exchangeable. Write a function that takes the data frame as an input and then randomly permutes the specific columns of that data frame (see lab for hints). Then write a function permutation_test that takes a data frame as an input and the loops numIter times. Every iteration of the the loop it should shuffle the dirGender column of the data and then calls the function written in a get the test statistic. Each iteration, the test statistic should be stored in a list.

After building up the numpy array of test statistics, the function should plot a histogram of the test statistics and mark the value of the empirical test statistics by a vertical line. Finally, it should report the p-value.

Start with 500 iterations to test your code for the final result, use 5000 iterations.

Here is the data: please refer to the dataset as df

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Let {X(t), Answered: 1 week ago

Answered: 1 week ago