Answered step by step
Verified Expert Solution
Question
1 Approved Answer
ANSWER QUESTION 4a,b,c ONLY, QUESTION 3 IS PROVIDED FOR CONTEXT Question 3 (15 marks) In this question, we consider the marketing dataset from datarium package
ANSWER QUESTION 4a,b,c ONLY, QUESTION 3 IS PROVIDED FOR CONTEXT
Question 3 (15 marks) In this question, we consider the marketing dataset from datarium package in R. install.packages("datarium") library(datarium) data(marketing) The data contains 200 observations and 4 variables. The response variable is sales, denoted as Y. The explanatory variablesmeasured in thousands of dollarsare advertising budget spent on youtube, newspapers and facebook, respectively, which are denoted as X1, X5 and X3, respectively. To model the impact of the three media on sales, a researcher uses the following multiple linear regression: Y =fo+ 51 X1+ B2 X2+ B3X3 + , (1) =XB+e (2) where Y, X1, X5 and X3 is a vector of n X 1 (n is the number of observations in the dataset), X = (1n, X1, X2, X3) and B = [Bo, B1, B2, B3] The parameter 8 in Equation (2) and its standard error (s.e()) can be estimated by using the function 1m() in R. Alternatively, 8 can be estimated by minimising the following loss function - Imean squared errors: 1 (Y - XiB) (3) n L= (Y =XB)(Y - XB) = ) =1 It is well-known that the optimal solution of 8 in Equation (3), denoted as B, has the following form: B=(X'X)"'XY (4) and its standard error is . 1 n . s.e(B) = /s2(X'X)~! where s = Z(Y; -XB8)2%i=1,2,... ,n. (5) n4 Your tasks are to: (a) use equations (4) and (5) to estimate 8 and its standard error in R. (b) compare the results obtained in Question 3(a) with those obtained from the function 1m() in R. 2 Optimisation Question 4 (30 marks) Another approach to estimate 8 in Equation (3) is to use Classical Gradient Descent. (a) Write down a step-by-step procedure of Classical Gradient Descent to estimate 8 in Equa- tion (3) (b) Write an R code to implement the Classical Gradient Descent procedure provided in Ques- tion 4(a). (c) Discuss the results obtained from Question 4(b) and compare it with that obtained from Question 3(a)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started