(U)spectral methods. The main methods take d-dimensional inputs and a vector
of binary outputs, and return parameters according to the GLMs mixture model
(General Linear Model). For more details see chapter 3 in the PhD thesis of
- Mor-Absa Loum: <https://theses.fr/s156435>, available here
+ Mor-Absa Loum: <https://theses.fr/2018SACLS299>, available here
<https://theses.hal.science/tel-01877796/document>.
-Version: 1.0-5
+Version: 1.0-6
Authors@R: c(person(given = "Benjamin",
family = "Auder",
role = c("aut", "cre"),
MASS,
jointDiag,
methods,
- pracma
+ pracma,
+ utils
Suggests:
devtools,
flexmix,
roxygen2
License: MIT + file LICENSE
Date: 2026-04-22
-RoxygenNote: 7.3.3
URL: https://github.com/yagu0/morpheus
Collate:
'utils.R'
export(plotBox)
export(plotCoefs)
export(plotHist)
-importFrom(graphics,barplot,boxplot,hist,matplot,par)
+export(pvalue)
+importFrom(graphics,
+ barplot,
+ boxplot,
+ hist,
+ matplot,
+ par
+)
importFrom(jointDiag,ajd)
importFrom(methods,new)
importFrom(pracma,integral)
-importFrom(stats,integrate,pnorm,rbinom,rmultinom,rnorm,runif,sd,pchisq,var)
+importFrom(stats,
+ integrate,
+ pchisq,
+ pnorm,
+ rbinom,
+ rmultinom,
+ rnorm,
+ runif,
+ sd,
+ var
+)
useDynLib(morpheus, .registration = TRUE)
{
"Compute the weights matrix from a parameters list"
- require(MASS)
dd <- d + d^2 + d^3
M <- Moments(θ)
Omega <- matrix( .C("Compute_Omega",
# NOTE: weird "integral divergent" error on inputs:
# link="probit"; order=2; λ=c(531.8099,586.8893,523.5816); b=c(-118.512674,-3.488020,2.109969)
# Switch to pracma package for that (but it seems slow...)
- sapply( seq_along(λ), function(k) {
- res <- NULL
- tryCatch({
+ vapply( seq_along(λ), function(k) {
+ integrand <- function(z)
+ .deriv[[link]][[order]](λ[k]*z+b[k]) * exp(-z^2/2) / sqrt(2*pi)
+ # NOTE: the value must be *returned* by tryCatch (an assignment inside the
+ # error handler would only modify a local variable of the handler).
+ tryCatch(
# Fast code, may fail:
- res <- stats::integrate(
- function(z) .deriv[[link]][[order]](λ[k]*z+b[k]) * exp(-z^2/2) / sqrt(2*pi),
- lower=-Inf, upper=Inf )$value
- }, error = function(e) {
- # Robust slow code, no fails observed:
- sink("/dev/null") #pracma package has some useless printed outputs...
- res <- pracma::integral(
- function(z) .deriv[[link]][[order]](λ[k]*z+b[k]) * exp(-z^2/2) / sqrt(2*pi),
- xmin=-Inf, xmax=Inf, method="Kronrod")
- sink()
- })
- res
- })
+ stats::integrate(integrand, lower=-Inf, upper=Inf)$value,
+ error = function(e) {
+ # Robust slow code, no fails observed.
+ # pracma package has some useless printed outputs: silence them
+ # without touching the user's sink() stack.
+ out <- NULL
+ utils::capture.output({
+ out <- pracma::integral(integrand, xmin=-Inf, xmax=Inf, method="Kronrod")
+ })
+ out
+ }
+ )
+ }, numeric(1) )
}
# Derivatives list: g^(k)(x) for links 'logit' and 'probit'
#' @export
plotCoefs <- function(mr, params, ...)
{
- oldpar <- par(no.readonly = TRUE)
- on.exit(par(oldpar))
-
d <- nrow(mr[[1]])
K <- ncol(mr[[1]])
}
}
- par(cex.axis=1.5, cex.lab=1.5, mar=c(4.7,5,1,1))
+ oldpar <- par(cex.axis=1.5, cex.lab=1.5, mar=c(4.7,5,1,1))
+ # Save/restore only the parameters modified here: restoring the full par()
+ # would also reset the current panel (mfg) and break par(mfrow=...) layouts.
+ on.exit(par(oldpar))
+
params <- as.double(params)
o <- order(params)
avg_param <- as.double(params_hat)