0

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

Rspacer
  • 2,369
  • 1
  • 14
  • 40

1 Answers1

1

The toy dataset is:

> df
  x1.test x2.test y.test
1    1000      NA     30
2    1000      NA     30
3    5000      NA     20
4    5000      NA     20
5      NA    1000     10
6      NA    1000     10
7      NA    4000      5
8      NA    4000      5

Since there are no complete rows, it is not possible to fit a model with both x1.test and x2.test as predictors

Robert Long
  • 5,722
  • 5
  • 29
  • 50