Homework Problem Set 5, Due Wednesday September 20, 2017. -------------------------------------------------------- Assigned 9/13/2017, due 9/20: 14 points (a) Write a function with arguments (a,b,c, N), where N has default value 1000, to find the numerical value for the integral of the function g(x,y) = (3x^2 + c*x*y + 5y^3)/(1+x^2 + y^2)^2 over the rectangle (-a,a) x (-b,b). Do this in two ways: (i) by Monte Carlo simulation, with N being the number of simulation iterations used, and (ii) using "integrate". Part (iii) of (a): Can you use the comparison between the answers (i)-(ii) (or with (i) for different values of N or with different values for the argument "rel.tol" in "integrate"), to assess the error in your answers ? (b) Write a function to find the maximum likelihood estimator for the parameters (a,b) in the logistic regression for a dataset with columns x (real, numeric) and y (binary, integer) under the conditional probability model P(y[i]=1 | x ) = exp( a + b*x[i] )/ (1 + exp(a + b*x[i])) , where a and b are unknown real parameters. The input is to be a two-column matrix XY with columns x, y. The number of rows of XY is referred to as the "sample size". Use your function to find and display the histogram of 1000 estimators b based on simulating 1000 independent datasets of size n=100 in which x[i] ~ Uniform[0,1] iid P(y[i]=1 | x ) = exp( a + b*x[i] )/(1 + exp(a + b*x[i])) , y[i] in {0,1} where the true values of (a,b) for all 1000 simulation replications are (-1,2). NOTE: it is intended in this problem that you write a function for the log-likelihood in this problem as a function of the data and parameters and use one of the library R functions (like nlm, optim, etc.) to maximize it. As mentioned in class, the function "glm" can be used to do the same likelihood maximization, but simply applying that function is not an adequate solution to this assigned HW problem. However, I do suggest that you make sure that the maximum likelihood estimators you find coincide to high accuracy (because they are supposed to be unique in this kind of likelihood !) with the ones found by "glm".