0

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

3
  • You have to start your custom function builds with function(x). Here you are nesting within a denominator. Commented Jan 25, 2023 at 6:56
  • @Phil can you clarify? I'm not sure what you mean by custom function builds. Does this make sens? It worked in R (link_func <- function(x) 1/-exp(x)) Commented Jan 25, 2023 at 20:16
  • I mean that 1/-(function(x) exp(x)) will not work. But function(x) 1/-exp(x) will. Commented Jan 25, 2023 at 23:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.