So I've included code for 1 question for reference below.
Question 3 asks me to assume that the linear predictor, takes the values between −5 and 5 equally spaced by 0.01. If the link function is logit, log (μi/(1-μi)) = x_i^t β, then compute and plot the mean response against the linear predictor, x_i^t β.
#Q3
LinearPredictor <- seq(-5,5,0.01)
head(LinearPredictor)
# compute inverse of link function
link_func <- function(x) exp(x)
# Compute mean response
MeanResponse<- as.vector(link_func(LinearPredictor))
# Plot the values
plot(LinearPredictor, MeanResponse)
For the next question, I'm asked the same thing but to assume that the link function is inverse negative and I'm not sure how to approach this piece. I attempted having the link_func as
link_func <- 1/-(function(x) exp(x))
But I kept getting a binary operator error.
Any advice? I'm new to this subject.
Thank You
function(x). Here you are nesting within a denominator.1/-(function(x) exp(x))will not work. Butfunction(x) 1/-exp(x)will.