Reputation: 1
I tried to run this code but returns an error
library(bbmle)
# Define the log-likelihood function using a single parameter vector 'theta'
loglik <- function(theta, data) {
mu <- theta[1] # Extract mu from the parameter vector
sigma <- theta[2] # Extract sigma from the parameter vector
# Negative log-likelihood for a normal distribution
-sum(dnorm(data, mean = mu, sd = sigma, log = TRUE))
}
set.seed(123)
data <- rnorm(100, mean = 5, sd = 2)
# Fit the model
fit <- mle2(loglik, start = list(theta = c(0, 1)), data = list(data = data))
# View the fit results
summary(fit)
`
Errore in validObject(.Object) : oggetto classe “mle2” non valido: invalid object for slot "fullcoef" in class "mle2": got class "NULL", should be or extend class "numeric"
I don't understand how mle2 handles parameter vectors, e.g., vector of regression coefficients
Upvotes: 0
Views: 4