You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用R语言lcmm()拟合增长模型时遇数值问题及系列报错求助

使用{lcmm}包的lcmm()函数拟合增长模型时的数值问题及解决尝试

我有一个无NA值的长格式数据框filtered_gmmdf_long,包含字段ID、time(取值固定为0、3、8、15、25)和近似正态分布的连续变量wblv。计划用{lcmm}包的lcmm()拟合简单增长模型,后续再扩展为增长混合模型,但过程中遇到了一系列问题:

  • 用hlme()拟合模型完全正常,但lcmm()无法运行基础模型,报错:

Numerical problem by computing fn value of function is : NaN

  • 先后尝试使用完整数据集(n=3255)和完全响应数据集(n=873),确认变量类型无误后,按建议尝试了以下操作,仍出现报错:

    • 指定gridsearch参数设置初始值:

    Error in minit$conv : $ operator is invalid for atomic vectors

    • 将hlme()的拟合结果作为初始参数B传入:

    Error in lcmm(...) : The model specified in B should be of class lcmm
    Error in chol.default(varcov) : the leading minor of order 2 is not positive definite

  • 对wblv进行无负值缩放得到wblv_rescale后,单类别增长模型可正常运行,但拟合2类别增长混合模型时再次报错:

Error in .Contlcmm(...) : Please specify initial values with argument 'B'

示例数据代码如下:

library(dplyr)
sample = as.data.frame(matrix(data = c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,
                      0,3,8,15,25,0,3,8,15,25,0,3,8,15,25,0,3,8,15,25,
                      -0.0924870160,0.0274498752,0.2398900582,0.1422529358,
                      0.1440320863,-0.0869990920,0.1423375351,-0.239953000,
                      -0.2378607918,0.1893095329,0.0470979475,0.0681092844,
                      0.0643890367,-0.1299717236,0.0284062668,0.0249408593,
                      0.2341043359,0.0866213575,0.1003340839,0.2721473565),ncol = 3)) %>%
  mutate(ID = V1, time = V2, wblv = V3) %>%
  select(-starts_with("V"))

内容的提问来源于stack exchange,提问作者Cassondra Lyman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 17:13:18