[R-sig-ME] Error in logLik.reStruct(object, conLin) : NA/NaN/Inf in foreign function call (arg 3) when Exponential Correlation added to model

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Tue Apr 19 16:51:23 CEST 2022


   These are hard problems to debug.

    The error message means *some* numerical issue  has occurred, but 
without a reproducible example it's really hard to diagnose. None of 
these examples ends up being diagnosed, but some have advice about 
debugging/troubleshooting:

https://stackoverflow.com/questions/16488736/r-error-in-lme-function-na-nan-inf-in-foreign-function-call-arg-3

https://stackoverflow.com/questions/34900270/lme-na-nan-inf-in-foreign-function-call-arg-3


Slightly different: 
https://stat.ethz.ch/pipermail/r-help/2005-November/082151.html

https://stats.stackexchange.com/questions/129781/why-will-higher-order-of-polynomials-using-poly-function-solve-in-lme-model-an

   You could try glmmTMB:


glmmTMB(lung_function~age +covariate1+covariate2+covariate3+
        timesincepregnancy + (1+age|id) + ar1(0+age|id),
        data=df5, na.action=na.exclude)

  [glmmTMB will include an iid residual error term and hence a nugget 
term by default, unless you add `+0` to the overall model formula]

On 4/19/22 9:54 AM, Esan, Oluwaseun wrote:
> Dear List Members,
> 
> I am relatively new to R and Mixed Effects Models using LME.
> 
> I am unable to post sample data:
> 
> 
> I am trying to get the effect of pregnancy on lung function  and age on women with a certain genetic condition. We know lung function declines with age in people with the condition but we do not know the effect pregnancy has on this relationship.
> 
> I have repeat measurements of lung function measured up to 4 times in a year for up to 14 years for each woman (A total of 331,722 observations for 11668 women).
> 
> I am having problems when trying to add an exponential serial correlation to a validated model.
> 
> library(nlme)
> 
> covariate 1= age
> M1<-lme(lung function~age +covariate1+covariate2+covariate3+ timesincepregnancy ,data=df5,random=~1+age|id, na.action=na.exclude, method ="ML", control=lmeControl(opt='optim'), corr=corExp(form=~age|id, nugget=T))
> 
> The following error occurs:
> 
> Error in logLik.reStruct(object, conLin) :
>    NA/NaN/Inf in foreign function call (arg 3)
> 
> When I run it on random sample of 40 women it runs without an error. Is there any further processing I need to do on the data? I have already removed duplicates.
> 
> Previous studies have shown exponential correlation structure is the best fit for the data but I cannot seem to get this to work on the dataset I have.
> 
> All the best,
> Seun
> 
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

-- 
Dr. Benjamin Bolker
Professor, Mathematics & Statistics and Biology, McMaster University
Director, School of Computational Science and Engineering
(Acting) Graduate chair, Mathematics & Statistics



More information about the R-sig-mixed-models mailing list