In an experiment, we had two types of treatments -- same species (x1.test at two densities 1000, 5000) or different species (x2.test at two densities 1000, 4000) for which we collected the total number of offspring (y.test) arranged as follows
set.seed(101)
x1.test <- c(1000,1000,5000,5000, NA,NA,NA,NA)
x2.test <- c(NA,NA,NA,NA,1000,1000,4000,4000)
y.test <- c(30,30,20,20,10,10,5,5)
df <- data.frame(x1.test, x2.test, y.test)
I want to fit my data to the following exponential function that can linearized as follows
y.test = lambda * exp^ - aii x1.test - aij x2.test
log(y.test) = log(lambda) + log (exp^ - aii x1.test - aij x2.test)
log(y.test) = log(lambda) - aii x1.test - aij x2.test
Therefore, the glm
function is of the form
g1 <- glm(y.test ~ x1.test + x2.test, family = gaussian(link = "log"))
coef(g1)
It produces as error in glm.fit(x = numeric(0), y = numeric(0), weights = NULL, start = NULL, : object 'fit' not found
presumable because there are NA's
Ultimately, I want to compute the estimates of lambda, aii, and aij as follows:
s0 <- with(as.list(coef(g1)), list(lambda = log(`(Intercept)`), aii = (x1.test * `(Intercept)`)),aij = (x2.test * `(Intercept)`))
Code modelled on this answer