Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. In this question we will experiment with Pearson's correlation coefficient. First, load the dataset states_data.csv as well as pandas, numpy, and matplotlib. Throughout

3. In this question we will experiment with Pearson's correlation coefficient. First, load the dataset (d) What do you observe in the scatterplots from the previous questions? Are the variables easier to compare 

3. In this question we will experiment with Pearson's correlation coefficient. First, load the dataset states_data.csv as well as pandas, numpy, and matplotlib. Throughout this ques- tion, we will use the variables prcapinc, the mean income per capita in each state, and vep12_turnout, the percentage voter turnout in the 2012 presidential election in the data. (a) Write a python function called my standardize that takes as input a numpy array and returns an array containing the standardized version of all the values in the input array. To do so recall that: np. mean will return the mean of an array, and np. std will return the standard deviation of an array. (b) Using the standardization function you just wrote, write a python function called my_corr that takes as input two equally sized numpy arrays and output the Pearson correlation between them. You can use the function test_corr included in the code for this assign- ment to test whether the function you wrote works. If running: test-corr() outputs True, then it does, if it outputs False, then it does not. In this case go back to your code and debug it until it works. (c) Using the standardization function you just wrote, standardize the variables prcapinc, and vep12_turnout. Create scatterplots with prcapinc on the x-axis and vep12_turnout on the y-axis for both the standardized and unstandardized versions of these variables. (d) What do you observe in the scatterplots from the previous questions? Are the variables easier to compare once standardized? Briefly explain your answer. (e) Using your function, compute the correlation between the variables. Interpret this cor- relation and describe its implications.

Step by Step Solution

3.48 Rating (161 Votes )

There are 3 Steps involved in it

Step: 1

Answer Below is the Python code that addresses the requirements import pandas as pd import numpy as ... 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

International Economics

Authors: Robert C. Feenstra, Alan M. Taylor

5th Edition

1319218504, 9781319218508

More Books

Students also viewed these Databases questions

Question

24. Describe the purpose of each phase of a compiler.

Answered: 1 week ago

Question

What are your options besides a rote memory approach?

Answered: 1 week ago