我是R的新用户,并希望执行精确的逻辑回归。我之所以选择这种方法是因为我的因变量是二进制的(即0表示失败,1表示成功),并且具有连续的自变量。我的样本量非常小,为n = 10。以下是我编写的代码示例。
library(elrm)
BaselineSteps = c(4202, 7244, 4374.6, 2965.6, 4263.5, 1814.1, 3243.1, 3102.9, 4652.5, 6324.9)
StepsClass = c(1, 0, 1, 1, 1, 1, 1, 1, 1, 1)
Const = rep(1,length(StepsClass))
dat = data.frame(pred = BaselineSteps, trials = Const, success = StepsClass)
m.stepsFromSteps = elrm(formula = success/trials ~ pred, interest = ~pred, iter = 22000, dataset = dat, burnIn = 2000)
我正在尝试使用受试者所采用的基线平均步数/天来确定它们属于哪种类型的恢复模式(0或1)。但是,当我只运行elrm实现的最后一行(不做任何改动)时,每次运行它时都会得到截然不同的p值。见如下:
> m.stepsFromSteps = elrm(formula = success/trials ~pred, interest = ~pred, iter=30000, dataset = dat, burnIn=5000)
> m.stepsFromSteps$p.values
pred
0.16176
> m.stepsFromSteps = elrm(formula = success/trials ~pred, interest = ~pred, iter=30000, dataset = dat, burnIn=5000)
> m.stepsFromSteps$p.values
pred
0.613
> m.stepsFromSteps = elrm(formula = success/trials ~pred, interest = ~pred, iter=30000, dataset = dat, burnIn=5000)
> m.stepsFromSteps$p.values
pred
1
> m.stepsFromSteps = elrm(formula = success/trials ~pred, interest = ~pred, iter=30000, dataset = dat, burnIn=5000)
> m.stepsFromSteps$p.values
pred
0.83056
我尝试过大幅增加迭代次数(iter = 50000)以及burnIn,但无济于事。每次运行时,p值仍然会发生巨大变化。我实际上使用不同的预测变量和/或类以相同的格式执行了50个精确的逻辑回归,并且它们都具有每次产生不同p值的相同问题。
非常感谢任何帮助。