R中的非线性逻辑回归包

Nonlinear logistic regression package in R

是否有执行非线性逻辑回归的 R 包?

换句话说:我有 glm,我可以用它去 glm (cbind (success, failure) ~ variable 1 + variable2, data = df, family = binomial (link = 'logit')),我可以用 nlsnls (y ~ a * x^2 + b * x + c, data = df)

我想要一些采用公式 cbind (success, failure) ~ int - slo * x + gap / (1 + x / sca) 的函数(其中 xsuccessfailure 是唯一的数据和其他所有数据是参数)与 binomial (link = 'logit') 系列,即将两者结合。我一直在搜索 Google,但没能找到类似的东西。

尝试gnlm::bnlr()。默认 link 是 logit,您可以指定数据和参数的非线性函数。我包含两个答案,具体取决于 gapsca 是数据还是参数。

library(gnlm)

gapsca的情况下是数据:

## if gap and sca are data:
set.seed(1)
dat <- data.frame(  x = rnorm(10),
                  gap = rnorm(10),
                  sca = rnorm(10),
                    y = rbinom(10,1,0.4))
y_cbind = cbind(dat$y, 1-dat$y)
attach(dat)
bnlr(y=y_cbind, mu = ~ int - slo * x + gap / (1 + x / sca), pmu = c(0,0))

输出:

Call:
bnlr(y = y_cbind, mu = ~int - slo * x + gap/(1 + x/sca), pmu = c(0, 
    0))

binomial distribution

Response: y_cbind 

Log likelihood function:
{
    m <- plogis(mu1(p))
    -sum(wt * (y[, 1] * log(m) + y[, 2] * log(1 - m)))
}

Location function:
~int - slo * x + gap/(1 + x/sca)

-Log likelihood    2.45656 
Degrees of freedom 8 
AIC                4.45656 
Iterations         8 

Location parameters:
     estimate      se
int    -1.077  0.8827
slo    -1.424  1.7763

Correlations:
       1      2
1 1.0000 0.1358
2 0.1358 1.0000

如果gapsca是参数:

## if gap and sca are parameters:
detach(dat)
set.seed(2)
dat <- data.frame(  x = rbinom(1000,1,0.3),
                    y = rbinom(1000,1,0.4))
y_cbind = cbind(dat$y, 1-dat$y)
attach(dat)
bnlr(y=y_cbind, mu = ~ int - slo * x + gap / (1 + x / sca), pmu = c(0,0,0,1))

输出:

Call:
bnlr(y = y_cbind, mu = ~int - slo * x + gap/(1 + x/sca), pmu = c(0, 
    0, 0, 1))

binomial distribution

Response: y_cbind 

Log likelihood function:
{
    m <- plogis(mu1(p))
    -sum(wt * (y[, 1] * log(m) + y[, 2] * log(1 - m)))
}

Location function:
~int - slo * x + gap/(1 + x/sca)

-Log likelihood    672.9106 
Degrees of freedom 996 
AIC                676.9106 
Iterations         7 

Location parameters:
     estimate      se
int  -0.22189  2.1007
slo   0.03828  3.6051
gap  -0.20273  2.0992
sca   0.99885  0.3956

Correlations:
          1       2        3       4
1    1.0000   1.859  -0.9993 -281.45
2    1.8587   1.000  -1.8592  -82.06
3   -0.9993  -1.859   1.0000  281.64
4 -281.4530 -82.061 281.6443    1.00