Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN PYTHON - create a function: working with the data set below: a) Write a function that takes the data frame as an input and

IN PYTHON - create a function: working with the data set below:

image text in transcribed

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. Start with 500 iterations to test your code for the final result, use 5000 iterations.

\begin{tabular}{rrrrrrrrrr} & boxoff & prodcost & dirlncome & dirGender & year & month & genre & numTheatres \\ \hline 0 & 88.648583 & 44.742936 & 1.143234 & male & 2012 & 3 & comedy & 139 \\ 1 & 145.334924 & 38.835516 & 3.393535 & female & 2014 & 11 & drama & 213 \\ 2 & 238.265684 & 29.532283 & 2.418883 & male & 2015 & 6 & other & 100 \\ 3 & 212.714742 & 157.111899 & 2.034115 & male & 2014 & 10 & adventure & 436 \\ \hline 4 & 120.175461 & 30.547155 & 0.963219 & female & 2012 & 1 & comedy & 115 \\ & & & & & & & & \\ 245 & 187.231562 & 72.743712 & 3.105438 & male & 2012 & 12 & adventure & 366 \\ 246 & 215.713195 & 136.851707 & 1.917771 & male & 2013 & 7 & adventure & 285 \\ 247 & 166.827002 & 50.684470 & 2.414571 & male & 2014 & 1 & other & 233 \\ 248 & 223.226998 & 40.103513 & 2.176928 & male & 2015 & 2 & drama & 489 \\ 249 & 123.511036 & 48.287595 & 2.315791 & male 2012 & 7 & comedy & 251 \end{tabular} 250 rows 8 columns

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

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

2. What is the meaning and definition of Banking?

Answered: 1 week ago

Question

3.What are the Importance / Role of Bank in Business?

Answered: 1 week ago