[lme使Rstudio崩溃,并且在增加内存限制后PC无法响应

问题描述 投票:2回答:1

我正在使用205个观测值和2个解释变量的数据集:站点(两个级别)和应变(21个级别)。当应变是固定变量时,我试图将混合模型拟合到数据中。实验不平衡(即每个菌株Xsite细胞中的重复数不相等)。我使用Rstudio 3.0.2; Windows 8。

我首先尝试运行以下内容-

    lme(dist_OFT_min1~strain , random=~strain|site,data=data.frame(d1),method='REML')

但是我遇到了以下错误:

    Error in logLik.lmeStructInt(lmeSt, lmePars) : 
    'Calloc' could not allocate memory (730512784 of 8 bytes)
In addition: Warning messages:
1: In logLik.lmeStructInt(lmeSt, lmePars) :
Reached total allocation of 3873Mb: see help(memory.size)
2: In logLik.lmeStructInt(lmeSt, lmePars) :
Reached total allocation of 3873Mb: see help(memory.size)

我试图将内存限制增加到8000。但是,当我重新运行上一行Rstudio(以及总计的PC)时,它变得非常缓慢且无响应,我让它运行了30分钟以上,没有任何结果。

我尝试将模型拟合到缩减数据集上-仅包含5个菌株:

    lme(dist_OFT_min1~strain , random=~strain|site,data=data.frame(d.test),
    method='REML',control = lmeControl(msMaxIter =90,maxIter=90)) 

和另一种麻烦弹出:

    Error in lme.formula(dist_OFT_min1 ~ strain, random = ~strain | site,  : 
    nlminb problem, convergence error code = 1
    message = iteration limit reached without convergence (10)

任何人都可以帮助我了解我的数据可能会遇到什么麻烦吗?我该如何检查? (我仍然是初学者)。在这里,我分享了自己模拟的类似数据,但是我遇到了与原始数据相同的麻烦(实验室等于站点):

    library(nlme)
    u.strain=letters[1:10]
    u.lab=paste('L',letters[1:5],sep='')
    test.dat=data.frame(strain=sort(rep(u.strain,5)),lab=rep(u.lab,10),test=rep(7,50))
    test.dat[order(test.dat$strain),'test']=test.dat[order(test.dat$strain),'test']+sort(rep(rnorm(n=10,mean=0,sd=3),5)) #strain effect
    test.dat[order(test.dat$lab),'test']=test.dat[order(test.dat$lab),'test']+sort(rep(rnorm(n=5,mean=0,sd=4),10)) #lab effect
    test.dat[,'test']=test.dat[,'test']+ rnorm(n=50,mean=0,sd=5) # interaction
    test.dat=rbind(test.dat,test.dat,test.dat,test.dat,test.dat)
    test.dat[,'test']=test.dat[,'test']+rnorm(n=250,0,sd=2.5)

我认为我实际需要的模型如下:

    lme(teat~strain , random=~strain+strain:lab|lab,
             data=data.frame(test.dat),method='REML')

仍然弹出同样的问题。

ps.s。我主要试图估计相互作用应变:lab的方差。有提示吗?

谢谢大家。

Iman

r memory-management mixed-models nlme
1个回答
2
投票

明确定义交互:

test.dat$strainlab <- with(test.dat,interaction(strain,lab))

适合站点(实验室)作为固定效果(如果您使很多只有两个位点),每个位点之间的相互作用都是随机的:

m1 <- lme(test~strain+lab , random=~1|strainlab,
    data=data.frame(test.dat),method='REML')
VarCorr(m1)
## strainlab = pdLogChol(1) 
##             Variance  StdDev
## (Intercept) 29.286446 5.411695
## Residual     5.398621 2.323493

近似置信区间:

intervals(m1,which="var-cov")
## Approximate 95% confidence intervals
## 
##  Random Effects:
##   Level: strainlab 
##                    lower     est.    upper
## sd((Intercept)) 4.258995 5.411695 6.876374
## 
##  Within-group standard error:
##    lower     est.    upper 
## 2.106594 2.323493 2.562725 
##

或者,以随机方式拟合实验室和实验室间的相互作用:

m2 <- lme(test~strain , random=~1|lab/strain,
data=data.frame(test.dat),method='REML')
VarCorr(m2)
##             Variance     StdDev  
## lab =       pdLogChol(1)         
## (Intercept) 18.608568    4.313765
## strain =    pdLogChol(1)         
## (Intercept) 29.286446    5.411695
## Residual     5.398621    2.323493
## 
intervals(m2,which="var-cov")
## Approximate 95% confidence intervals
## 
##  Random Effects:
##   Level: lab 
##                    lower     est.    upper
## sd((Intercept)) 1.925088 4.313765 9.666346
##   Level: strain 
##                    lower     est.    upper
## sd((Intercept)) 4.259026 5.411695 6.876324
## 
##  Within-group standard error:
##    lower     est.    upper 
## 2.106600 2.323493 2.562717 
© www.soinside.com 2019 - 2024. All rights reserved.