I'm trying to understand the with
function in context of a glm
function output from here
First, a simple data set
set.seed(101)
x.test <- runif(50,2,8)
y.test <- 0.5^(x.test)
df <- data.frame(x.test, y.test)
I want to fit the function of form y.test ~ lambda/(1+ aii*x.test)
using the inverse link function in glm
g1 <- glm(y.test ~ x.test, family = gaussian(link = "inverse"))
coef(g1)
(Intercept) x.test
-10.884889 6.946893
s0 <- with(as.list(coef(g1)),
list(lambda = 1/`(Intercept)`, aii = x.test/`(Intercept)`))
This produces a single value for $aii
: [1] -0.6382144
Why does the with
function do that? Should aii
not produce 50 values given that x.test
is a vector containing 50 values?