I am in a student research position and am new to R. I have asked a question similar (posted here:MLE Issues). I have resolved the initial problem but i have encountered more problems with this function.
I am still using this function for trying to estimate theta[i], where each of the other variables is currently known.
Below is my code:
maxParam <- function(theta) {
logl <- sum(for (i in 1:length(doses)) {
sum(
for (j in 1:LITTERS.M) {
sum(
for (k in 0:(litterResponses[i,j]-1)) {
sum(log10(probabilityResponses[i] + k * theta[i]))
}
+
for (k in 0:(litterSizes[i,j]-litterResponses[i,j]-1)) {
sum(log10(1 - probabilityResponses[i] + k * theta[i]))
}
-
for (k in 0:(litterSizes[i,j] - 1)) {
sum(log10(1 + k * theta[i]))
}
)
}
)
})
return (-logl)
}
mle.fit <- mle(maxParam, start=list(theta=c(1,1,1,1,1,1)))
print(mle.fit)
The error i am being thrown is:
Error: argument "theta" is missing, with no default
I apologize if the error is silly, I have little knowledge of R.
Notes: I am using a vector of (1,1,1,1,1,1) as a test for theta. It is not actual data. Doses is a vector of 6 that corresponds to dose levels of a serum. Litter Responses is a matrix that describes the responses to the serum per dose per litter. LitterSizes is a matrix that describes the size of a litter per dose per litter. LITTERS.M is the initial number of litters that came in contact with serum. ProbabilityResponses is a vector that describes the probability that a given mouse will be affected by the serum.