SSID
1.1 Exercise 1: Single Regression
Please don’t forget to comment your code. Failure to do so will result in a loss of points.
Also, remember that all code that is required here (unless otherwise stated) can be found in the lecture Jupyter Notebooks or the coding notebooks from class.
Here are three models for the median starting salary of law school graduates in 1985.
log(salaryi) = b0 + b1 LSATi + ei
(1) log(salaryi) = b0 + b1 LSATi + b2GPAi + ei
(2) log(salaryi) = b0 + b1 LSATi + b2GPAi + b3log(costi) + b4ranki + ei
(3)Each observation i represents a school. The variables in the dataset are:
Variable Description
rank law school ranking
salary median starting salary
cost law school cost
LSAT median LSAT score
GPA median college GPA
libvol volumes in lib., 1000s
faculty of faculty
age age of law sch., years
clsize size of entering class
north =1 if law sch in north
south =1 if law sch in south
east =1 if law sch in east
west =1 if law sch in west
studfac student-faculty ratio
top10 =1 if ranked in top 10
In the code cell below, write the appropriate imports you will need for this question (we will need pandas, numpy and formula.api). You can do an abbreviated import if you wish (but the standard for pandas is pd, statsmodels.formula.api is smf, and numpy is np). Afterwards, load in the data from here:
https://raw.githubusercontent.com/lordflaron/ARE106data/master/lawsch85.csv
This can be done using the read_csv() function. Name this dataset raw_df. After loading in the data, show the first 10 observations in the output.
Use the describe() method on raw_df to show a table of summary statistics for each variable in the dataset. How many observations do salary have? Write this in a print statement. (Hint: This is in the “count” row the summary table).
NameError Traceback (most recent call last)
<ipython-input-56-894b02c4d62f> in <module>
1 ## b. Put your answer in this cell.
----> 2 describe(raw_df)
3 print("raw_df")
NameError: name 'describe' is not defined
Since we’ll need a log-transformed version of salaryi for all our models, use assign() to create a new variable which is the log of salaryi. Name this new variable log_salary.
Hints:
Remember that assign is not an inplace operation!
Remember to use a lambda function in this case. To log a variable, you can use np.log()
Remember the syntax for assign(): my_df.assign(new_variable = expression)
After this we now need to also drop any observations that are missing. This isn’t actually how econometricians deal with missing data, but this is good enough for us for now.
You can do this by chaining the dropna() method after the assign() method.
Warning: Do not do dropna BEFORE assign
The end result should look something like this:
df = raw_df.assign(log_salary= expression).dropna()
[3]:
Before estimating the model, explain how to interpret b1 in Model
Please write your answer for d here. If you need to use more than one line, you may do so.
Before estimating the model, explain how to interpret b1 in Model
Please write your answer for e here. If you need to use more than one line, you may do so.
Before estimating the model, do you expect b1 and b2 to be positive or negative in Model 2? Explain. (Hint: I’m not asking for any rigorous mathematical way to answer this question. Just use your economic intuition and reasoning skills to write an argument).
Please write your answer for f here. If you need to use more than one line, you may do so.
Estimate Model 1. Show the regression
What is the effect of a one unit increase in LSAT score on the log of median salary?
Please write your answer for h here. If you need to use more than one line, you may do so.
What does the R2 measure in the regression? What is the R2 in this case? (Not the adjusted
R2).
Please write your answer for i here. If you need to use more than one line, you may do so.
Exercise 2: Multiple Regression
This is a continuation of what we were doing in Exercise 1.
For this exercise, observe the expression for b1 when there are two regressors in the equation:
bˆ ∑N x1iyi ∑N x2
− ∑N x1ix2i ∑N x2iyivariances and covariances without changing the value of the coefficient (since N2 is 1).
N2
Also notice that the covariance is like an un-normalized correlation coefficient. So if you
calculate the correlation between two variables, you won’t know the covariance between the two, but you’ll know the direction and strength of their relationship. Estimate Model 2.
Calculate the correlations between log(salary)i, LSAT, and GPA.
Use the slicing notation to first make a subset of the data with only log_salary, LSAT and GPA.
Then use the corr() method to get the correlation for those variables, i.e. it will look something like this:
df[['log_salary', 'GPA', 'LSAT']].corr()
60 Answers
67 Answers
DescriptionIn this final assignment, the students will demonstrate their ability to apply two majorconstructs of the C programming language – Functions and Arrays – to solve computationalproblems.Arrays provide a convenient way to store &
The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is anPath finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going through certain obstacles. As the main aim is to thinkabout path finding, we focus on the common task
Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individualDevelop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. TheLineItem class will represent an individual line item of merchandise that acustomer is purchasing.
SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define: SeaPortProgram e
Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define: SeaPortProgram e
The first programming project involves writing a program that parses, using recursive descent, a GUI definition language defined in an input file and generates the GUI that it defines. The grammar for this language is defined below:1Project 1The first programming project involves writing a program that parses, using recursive descent, a GUIdefinition language defined in an input file and generates the GUI that it defines. The grammar for thislanguage is defined below:gui ::= Wi
CMSC 335 Project SeaPort Solved Project 3 Introduction the SeaPort Project series For this set of projects for the course we wish to simulate some of the aspects of a number of Sea PortsCMSC 335 Project SolvedProject 3 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:
CMSC 335 Project 4 Solved SeaPort Introduction the SeaPort Project series For this set of projects for the course we wish to simulate some of the aspects of a number of Sea Ports Here are the classes and their instance variables we wish to defineProject 4 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define: SeaPortProgram ext
CMSC 451 Project 2 Solved The second project involves completing and extending the C++ program that evaluates statements of an expression language contained in the module 3 case studyProject 2 The second project involves completing and extending the C++ program that evaluates statements of an expression language contained in the module 3 case study. The statements of that expression language consist of an arithmetic expression f
CMSC 451 Project 1 Solved The first project involves benchmarking the behavior of Java implementations of one of the following sorting algorithms bubble sort selection sort insertion sort Shell sort, merge sort quick sort or heap sortCMSC 451 Project 1The first project involves benchmarking the behavior of Java implementations of one of thefollowing sorting algorithms, bubble sort, selection sort, insertion sort, Shell sort, merge sort,quick sort or heap sort. You must post your
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.
Get Free Quote!
258 Experts Online