Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Assignment 1

Big Data and Machine Learning for Economics and Finance

Provide your answers in a PDF document. For each exercise, provide the R code, the R output and your comments on the output. Comment each line of your R code as well.

Solving the assingment requires the installation of the package Ecdat that con- tains multiple useful econometric datasets.

Exercise 1. (5 points) For this exercise, the only extra packages allowed are Ecdat and MASS.

Consider the dataset Mode (in the package Ecdat) that contains data on individuals' mode of transportation  (either  car,  carpool, bus or rail), in addition to those transportation modes' costs and times.

Using linear and quadratic discriminant analysis, predict the output variable choice given the input variables cost.z and time.z. Construct the confusion matrices and compute the training error rates for the whole sample.

Exercise 2.  (5 points) For this exercise, the only extra package allowed is ISLR2.

Consider the dataset Default in the package ISLR2. We are interested in predicting the output variable default given all other variables in the dataset as inputs using the linear probability model.

Compute the training error rate (over the whole sample) of the linear probability model and compare it with the training error rate of logistic regression using the same output and input variables.  Discuss the performance of the linear probability model in this dataset, in particular when compared with logistic regression.

(Hint) The linear probability model is a linear regression model that is tted using least squares.  Note that default is a factor variable and may need to be transformed into a numeric variable as the function lm expects the output variable to be numeric. The function as.numeric could be used for that purpose.

Exercise 3. (5 points) For this exercise, the only extra packages allowed are boot and Ecdat.  Consider the dataset Strike in the package Ecdat. The dataset contains a variable named duration that measures the length of some factory strikes (in number of days). An economist is interested in studying that duration variable. If n is the sample size, and Xi represent the

duration of strike i, then the economist is interested in computing the quantity

n

 = X log(Xi)

as this gives an estimate of a parameter a that could be used later as a building block for a theoretical economic model.

Compute  for this sample and assess its accuracy using the bootstrap.

Exercise 4.  (5 points) For this exercise, the only extra packages allowed are ISLR2, Ecdat and MASS.

We are interested in the following 4 datasets: Default (from the package ISLR2), and Participation, Train and Mroz (from the package Ecdat). The output variable in each of these datasets is default, lfp, choice and city respectively and the input variables are selected from all the remaining variables in each of the datasets.

Based on error rates computed using cross-validation, decide what is the best model to use for each dataset, among Linear Discriminant Analysis and Quadratic Discriminant Analysis.