非线性混合模型:我做错了什么?

发布于 2025-01-09 02:58:11 字数 3383 浏览 1 评论 0原文

我正在处理一个由三列组成的数据集: 患者 ID (ID)、时间和宫颈扩张 (CD)。对于无法共享我的数据,我提前表示歉意,因为它是机密的,但我在下面提供了一个示例表。每个患者的 CD 在分娩过程中都被及时记录下来。时间以小时为单位,CD 可以为 1-10 厘米。时间点/CD 评分的数量因患者而异。在此模型中,t 被设置为相反,其中 10 cm(完全扩张)被设置为所有患者的 t=0。这样做是为了使所有患者都能在完全扩张时对齐。我的数据集没有 NA,并且所有患者都有 2 个或更多时间点。

IDTIMECD
1010
138
165
2010
219
247
294

我知道对于这个问题我需要使用非线性混合效应模型。我从文献中得知,定义此生物过程的函数最好建模为 CD= Cexp(-At)+(10-C)exp(- 形式的双指数函数Lt),其中 A 是主动临产率 [厘米/小时],L 是潜伏临产率 [厘米/小时],C 是患者过渡时的子宫颈直径 [厘米]从潜伏劳动到主动劳动,以及t 是以小时为单位的时间。

我尝试使用 nlmer() 和 nlme() 来拟合这些数据,并且使用了自启动双指数函数 SSbiexp() 以及创建了我自己的函数及其 deriv()。每个参数 C、A 和 L 应该具有基于 ID 的随机效果。先前的工作表明C~4.98cm,A~0.41cm/hr,L~0.07cm/hr。使用 SSbiexp() 时,有一个术语表示第二个指数分量,此处标记为 C2,但应该与我自制双指数函数的 (10-C) 分量相同。

当将 nlme() 与 SSbiexp() 一起使用时,我收到错误: 在 0 级、块 1 处反求解中的奇异性

nlme_ssbiexp<- nlme(CD~SSbiexp(TIME, C, A, C2, L),
                  data= df,
                  fixed = C+A+C2+L ~1, 
                  random= C+A+C2+L ~1|ID, 
                  start= c(C=4.98, A=0.41, C2= 5.02, L=0.07))

当将 nlme() 与我自制的 biexp 函数一起使用时,我收到错误: 在没有收敛的情况下达到最大迭代次数 (maxIter = 50)

start<- c(C=4.98, A=0.41, L=0.07)
biexp<- ~ C*exp(-A*t) + (10-C)*exp(-L*t)
nfun <- deriv(biexp, namevec=c("C", "A", "L"),
              function.arg=c("t","C", "A", "L"))
nlme_my_biexp<- nlme(CD~nfun(TIME, C, A, L),
                  data= df,
                  fixed = C+A+L ~1, 
                  random= C+A+L ~1|ID, 
                  start= c(C=4.98, A=0.41, L= 0.07))

将 nlmer() 与 SSbiexp() 结合使用时,我收到错误: devfun(rho$pp$theta) 中的错误:Downdated VtV 不是正定

nlmer_ssbiexp<-nlmer(CD~SSbiexp(TIME, C, A, C2, L)~(C|PTID)+(A|PTID)+(C2|PTID)+(L|PTID),
                   data=df,
                   start= c(T1= 4.98, R1=0.41, T2=5.02, R2=0.07))

当将 nlmer() 与我自制的 biexp 函数一起使用时,我收到错误: devfun(rho$pp$theta) 中的错误:prss{Update} 未能在“maxit”迭代中收敛

  start<- c(C=4.98, A=0.41, L=0.07)
  biexp<- ~ C*exp(-A*t) + (10-C)*exp(-L*t)
  nfun <- deriv(biexp, namevec=c("C", "A", "L"),
                function.arg=c("t","C", "A", "L"))
  nlmer.fit.fun <- nlmer(CD ~ nfun(TIME, C, A, L) ~ (C|ID)+(A|ID)+(L|ID),
                          data = df,
                          start = start)

我使用 nlmer() 和我自制的 biexp 函数的最后组合取得了一些成功,但只有当我将随机效应减少到仅包括 (C|ID) 时。

start<- c(C=4.98, A=0.41, L=0.07)
  biexp<- ~ C*exp(-A*t) + (10-C)*exp(-L*t)
  nfun <- deriv(biexp, namevec=c("C", "A", "L"),
                function.arg=c("t","C", "A", "L"))
  nlmer.fit.fun <- nlmer(CD ~ nfun(TIME, C, A, L) ~ (C|ID),
                          data = df,
                          start = start)

我尝试增加 maxit 和 MaxIter,但两者仍然无法收敛。我无法在 Stack Overflow 上找到任何有助于解决这些问题的解决方案,尽管我已经在多个线程中看到了这些问题的讨论。我还尝试翻转时间尺度,使 t=0 并不总是与 CD=10 相关,但这并没有改变我的问题。我是 R 新手,所以我希望 nlmer() 或 nlme() 方面的专家可能知道这些错误消息的修复方法。

Ben Bolker-如果您正在阅读本文-我真的很想与您交谈!

I am working with a data set that is comprised of three columns:
patient ID (ID), TIME, and cervical dilation (CD). I apologize in advance for being unable to share my data, as it is confidential, but I have included a sample table below. Each patient CD was recorded in time as they progressed through labor. Time is measured in hours and CD can be 1-10cm. The number of time points/CD scores vary from patient to patient. In this model t is set in reverse, where 10 cm (fully dilated) is set as t=0 for all patients. This is done so that all patients can be aligned at time of full dilation. My dataset has no NA's and all patients have 2 or more time points.

IDTIMECD
1010
138
165
2010
219
247
294

I know for this problem I need to use nonlinear mixed effects model. I know from literature that the function that defines this biological process is modeled best as a biexponential function of the form CD= Cexp(-At)+(10-C)exp(-Lt), where A is the active labor rate [cm/hour], L is the latent labor rate [cm/hour], C is the diameter of the cervix [cm] at the point where the patient transitions from latent to active labor, and t is time in hours.

I have tried using both nlmer() and nlme() to fit this data, and I have used both the self-start biexponential function SSbiexp() as well as created my own function and its deriv(). Each parameter C, A, and L should have a random effect based on ID. Previous work has shown that C~4.98cm, A~0.41cm/hr, and L~0.07cm/hr. When using the SSbiexp(), there is a term for the second exponential component that is labeled here as C2, but should be the same as the (10-C) component of my self-made biexponential function.

When using nlme() with SSbiexp() I receive the error:
Singularity in backsolve at level 0, block 1

nlme_ssbiexp<- nlme(CD~SSbiexp(TIME, C, A, C2, L),
                  data= df,
                  fixed = C+A+C2+L ~1, 
                  random= C+A+C2+L ~1|ID, 
                  start= c(C=4.98, A=0.41, C2= 5.02, L=0.07))

When using nlme() with my self-made biexp function I receive the error:
Maximum number of iterations (maxIter = 50) reached without convergence

start<- c(C=4.98, A=0.41, L=0.07)
biexp<- ~ C*exp(-A*t) + (10-C)*exp(-L*t)
nfun <- deriv(biexp, namevec=c("C", "A", "L"),
              function.arg=c("t","C", "A", "L"))
nlme_my_biexp<- nlme(CD~nfun(TIME, C, A, L),
                  data= df,
                  fixed = C+A+L ~1, 
                  random= C+A+L ~1|ID, 
                  start= c(C=4.98, A=0.41, L= 0.07))

When using nlmer() with SSbiexp() I receive an error:
Error in devfun(rho$pp$theta) : Downdated VtV is not positive definite

nlmer_ssbiexp<-nlmer(CD~SSbiexp(TIME, C, A, C2, L)~(C|PTID)+(A|PTID)+(C2|PTID)+(L|PTID),
                   data=df,
                   start= c(T1= 4.98, R1=0.41, T2=5.02, R2=0.07))

When using nlmer() with my self-made biexp function I receive the error:
Error in devfun(rho$pp$theta) : prss{Update} failed to converge in 'maxit' iterations

  start<- c(C=4.98, A=0.41, L=0.07)
  biexp<- ~ C*exp(-A*t) + (10-C)*exp(-L*t)
  nfun <- deriv(biexp, namevec=c("C", "A", "L"),
                function.arg=c("t","C", "A", "L"))
  nlmer.fit.fun <- nlmer(CD ~ nfun(TIME, C, A, L) ~ (C|ID)+(A|ID)+(L|ID),
                          data = df,
                          start = start)

I had some success using the last combination of nlmer() and my self-made biexp fucntion, but only when I reduced my random effects to only including (C|ID).

start<- c(C=4.98, A=0.41, L=0.07)
  biexp<- ~ C*exp(-A*t) + (10-C)*exp(-L*t)
  nfun <- deriv(biexp, namevec=c("C", "A", "L"),
                function.arg=c("t","C", "A", "L"))
  nlmer.fit.fun <- nlmer(CD ~ nfun(TIME, C, A, L) ~ (C|ID),
                          data = df,
                          start = start)

I have tried increasing maxit and MaxIter, but both continued to fail to converge. I have been unable to find any solutions on Stack Overflow that help fixed these issues, though I have seen them discussed in several threads. I have also tried flipping the time scale so that t=0 is not always associated with CD=10, but it did not change my issues. I am new to R, so I am hoping someone that is an expert in nlmer() or nlme() might know fixes for these error messages.

Ben Bolker- if you are reading this- I would really love to talk with you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

演出会有结束 2025-01-16 02:58:11

这是我已经取得的进展:

  • 指数速率应该被指定为速率的对数(以确保速率本身保持正值,即我们有指数衰减 em> 曲线而不是增长曲线)
  • 我显着简化了模型,消除了 T1T2 中的随机效应。
nlmer.ssbiexp<- nlmer(CD~SSbiexp(TIME, T1, R1, T2, R2)~
                        (R1|ID) + (R2|ID),
                      data=df,
                      start= c(T1= 4.98, R1=log(0.41), T2=5.25, R2=log(0.07)))

此时我会尝试:

  • T2 指定为 10-T1 来简化模型(不确定这是否真的有效),
  • 看看是否可以构建回更复杂的版本实际工作的模型

Here's how far I've gotten:

  • the exponential rates are supposed to be specified as logs of the rates (to make sure that the rates themselves stay positive, i.e. that we have exponential decay curves rather than growth curves)
  • I simplified the model significantly, taking out the random effects in T1 and T2.
nlmer.ssbiexp<- nlmer(CD~SSbiexp(TIME, T1, R1, T2, R2)~
                        (R1|ID) + (R2|ID),
                      data=df,
                      start= c(T1= 4.98, R1=log(0.41), T2=5.25, R2=log(0.07)))

At this point I would try:

  • specifying T2 as 10-T1 to simplify the model (not sure if this will actually work)
  • seeing if you can build back to more complex versions of the model that actually work
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文