I'm fitting a GLM to some data, using a quasi-likelihood approach (family=quasi(...)
).
I'd like to use a variable, p
in the variance specification, like so:
family = quasi(link=log, variance=mu^p)
This however doesn't work (it no longer recongises mu
).
Is there any way to get R to just insert the value of p in the expression before it is evaluated, so I can use p
instead of a number?
Here's an example that doesn't work:
set.seed(1)
x <- runif(100)
y <- x^2+2*x+sin(2*pi*x) + rnorm(100)
fitModel <- function(x,y, p) {
model <- glm(y~x, family=quasi(link=log, variance=mu^p))
return(model)
}
fitModel(x,y,2)
Thanks!