Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with only intervals for gaussian data #3

Open
Quentin62 opened this issue Sep 14, 2020 · 2 comments · May be fixed by #14
Open

Error with only intervals for gaussian data #3

Quentin62 opened this issue Sep 14, 2020 · 2 comments · May be fixed by #14
Labels
MixtComp Concern the C++ library RMixtCompIO Concern the RMixtCompIO package: R interface of the C++ library

Comments

@Quentin62
Copy link
Collaborator

data.zip

library(RMixtComp)

dat = readRDS("bugdata.rds")
algo <- createAlgo(nInitPerClass = 1000)
model = list(molybdène = "Gaussian")

res <- mixtCompLearn(dat, model, algo, nClass = 1:3, nRun = 2, criterion = "ICL")

an R error is generated:

 Error in res[[indMax]] : 
  attempt to select less than one element in get1index 
3.
rmcMultiRun(algo, dataList, model, list(), nRun, nCore, verbose) at MIXTCOMP_mixtCompLearn.R#396
2.
classicLearn(data, model, algo, nClass, criterion, nRun, nCore, 
    verbose, mode) at MIXTCOMP_mixtCompLearn.R#283
1.
mixtCompLearn(datMC[datMC$Racine == "ELE100", ], model, algo, 
    nClass = 1:10, nRun = 10, criterion = "ICL")

the error comes from in RMixtCompIO:

  logLikelihood <- sapply(res, function(x) {ifelse(is.null(x$warnLog), x$mixture$lnObservedLikelihood, -Inf)})

  indMax <- which.max(logLikelihood)

  return(res[[indMax]])

If all warnlog are null then logLikelihood should be a vector of -Inf and this should not generate an error for which.max

@Quentin62 Quentin62 added MixtComp Concern the C++ library RMixtCompIO Concern the RMixtCompIO package: R interface of the C++ library labels Sep 14, 2020
@Quentin62
Copy link
Collaborator Author

The error occurs when nClass = 1. The parameters are estimated but output criterion are:

$lnObservedLikelihood
[1] NaN
$lnCompletedLikelihood
[1] -Inf
$BIC
[1] NaN
$ICL
[1] -Inf

The problem comes from individuals 43 et 102, the observed loglikelihood is -inf

The parameters are:

k: 1, mean 0.05851658 
k: 1, sd   0.32023988

and the individuals 43 and 102 are "[2.99:3.01]" "[3.99:4.01]"

the computed probability is 0 and so the loglikelihood is -Inf

@Quentin62
Copy link
Collaborator Author

idea: add an epsilon in the probabiblity computation function for some models (the ones that can't have a real 0: gaussian, weibull...)

Quentin62 added a commit that referenced this issue Oct 16, 2020
@Quentin62 Quentin62 linked a pull request Sep 21, 2021 that will close this issue
@Quentin62 Quentin62 linked a pull request Nov 26, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MixtComp Concern the C++ library RMixtCompIO Concern the RMixtCompIO package: R interface of the C++ library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant