Question 1 In maximum likelihood estimation, the estimator is obtained by maximizing the log likelihood function. However, most of the log likelihood has to be optimized by Newton-Raphson algorithm....

1 answer below »
this 3 questions


Question 1 In maximum likelihood estimation, the estimator is obtained by maximizing the log likelihood function. However, most of the log likelihood has to be optimized by Newton-Raphson algorithm. In this question, we will learn to program Newton-Raphson algorithm for a univariate function. Consider the function f(θ) = 2θ2-1/ 1+θ3 , θ > 0 Use the Newton-Raphson method to find the maximizer of the function. Implement the algorithms in R and run your code to obtain the maximizer. (Attach your screenshots of the output in R). You can use the online symbolic differentiation calculator to obtain f 0 (θ) and f 00(θ) (https://www.symbolab.com/solver/second-derivative-calculator). Question 2 In the following marketing set, we have 9 years with the sales in 10 million euro and the advertising expenditure in million euro. a) Based on the 9 observation and perform a ridge regression. Program it with R. Output the ridge regression results at a few different values of λ. b) In your ridge regression, when λ increaes, what do you observe from the values of the estimated coefficients. Does any of the estimated coefficients shrink to zero like the L1 LASSO regression? Describe the difference between the output of a ridge regression and the output of a lasso regression. year sales Advertisment 1 65 23 2 76 26 3 85 30 4 106 34 5 119 43 6 129 48 7 142 52 8 144 57 9 151 58 Question 5: Analyze the German data set from the site: https://archive.ics.uci.edu/ml/datasets/statlog+(german+credit+data). a) Perform the logistic regression on the dataset. You can some of the predictors in the model. Please use 900 observations as the training set and use your model to predict the default status of the remaining 100 loans. What is the cutoff value of the probability do you use for your analysis? How many default ones are predicted to be non-default ones (number of false negative)? How many non-default ones are predicted to be default ones (number of false positive). Then you need to improve your model by adding more predictors or adding some higher order terms or interaction terms. Please demonstrate that your new model has lesser errors than your first model in the 100 testing cases. b) Please investigate how the sensitivity and specificity change with respect to the different cutoff value of probability.
Answered Same DayFeb 14, 2021

Answer To: Question 1 In maximum likelihood estimation, the estimator is obtained by maximizing the log...

Sanchi answered on Feb 15 2021
148 Votes
#Question 1
func <- function(x) {(2*(x^2)-1)/(1+(x^3))}
derivfunc <- function(x) {2*(2(x^6)-6(x^4)-14(x^3)+3*x+2)/(1+(x^3))^3}
install.p
ackages("animation")
library(animation)
x0=seq(0,2,,100)
plot(x0,func(x0),type="n")
lines(x0,func(x0))
abline(h=0,lty=2)
ani.options(interval = 0.5)
newton.method(function(x) (2*(x^2)-1)/(1+(x^3)),1,c(0,2))
#Question2
install.packages("ISLR")
library(ISLR)
library(glmnet)
library(dplyr)
library(tidyr)
data <- read.csv("C:\\Users\\sanchi.kalra\\Desktop\\Greynodes\\AS11\\data_16.csv")
grid = 10^seq(10, -2, length = 100)
#RIDGE
set.seed(1)
train = data %>%
sample_frac(0.5)
test = data %>%
setdiff(train)
x_train = model.matrix(sales~., train)[,-1]
x_test = model.matrix(sales~., test)[,-1]
y_train = train %>%
select(sales) %>%
unlist() %>%
as.numeric()
y_test = test %>%
select(sales) %>%
unlist() %>%
as.numeric()
ridge_mod = glmnet(x_train, y_train, alpha=0, lambda = grid, thresh = 1e-12)
ridge_pred = predict(ridge_mod, s = 4, newx = x_test)
mean((ridge_pred - y_test)^2)
mean((mean(y_train) - y_test)^2)
ridge_pred = predict(ridge_mod, s = 1e10, newx = x_test)
mean((ridge_pred - y_test)^2)
ridge_pred = predict(ridge_mod, s = 0, newx = x_test, exact = T)
mean((ridge_pred - y_test)^2)
lm(sales~., data = train)
predict(ridge_mod, s = 0, type="coefficients")[1:3,]
set.seed(1)
cv.out =...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here