Skip to content

Commit

Permalink
Merge pull request #131 from PLN-team/fix-plnnetwork
Browse files Browse the repository at this point in the history
Some Fix in plnnetwork (Issue #129 and #130)
  • Loading branch information
jchiquet authored Sep 10, 2024
2 parents a10efa5 + 5ffdf38 commit 185c538
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions R/PLNnetworkfit-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ PLNnetworkfit <- R6Class(
args <- list(data = data,
params = list(B = private$B, M = private$M, S = private$S),
config = config)
private$Sigma <- crossprod(private$M)/self$n + diag(colMeans(private$S**2), self$p, self$p)
while (!cond) {
iter <- iter + 1
if (config$trace > 1) cat("", iter)
Expand Down
5 changes: 4 additions & 1 deletion inst/case_studies/oaks_tree.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ factoextra::fviz_pca_biplot(
labs(col = "distance (cm)") + scale_color_viridis_c()

## Network inference with sparce covariance estimation
system.time(myPLNnets <- PLNnetwork(Abundance ~ 0 + tree + offset(log(Offset)), data = oaks, control = PLNnetwork_param(min_ratio = 0.05)))

system.time(myZIPLNnets <- ZIPLNnetwork(Abundance ~ 0 + tree + offset(log(Offset)), zi = "single", data = oaks, control = ZIPLNnetwork_param(min_ratio = 0.1)))

system.time(myPLNnets <- PLNnetwork(Abundance ~ 0 + tree + offset(log(Offset)), data = oaks, control = PLNnetwork_param(min_ratio = 0.1)))
plot(myPLNnets)
plot(getBestModel(myPLNnets, "EBIC"))
# stability_selection(myPLNnets)
Expand Down
13 changes: 13 additions & 0 deletions inst/check/objective_zipln.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
library(PLNmodels)
data(oaks)

myPLN <- PLN(Abundance ~ 0 + tree + offset(log(Offset)), data = oaks)
myZIPLN <- ZIPLN(Abundance ~ 0 + tree + offset(log(Offset)) | 0 + tree, data = oaks)

## bricolage car quelques points explosent, sans conséquences sur la convergence finale
obj_PLN <- -myPLN$optim_par$objective
plot(obj_PLN, ## optimisation nlopt de la vraisemblance profilée
ylim = c(obj_PLN[1], # fonction objective sans les constantes
tail(obj_PLN,1)), log = "xy")

plot(myZIPLN$optim_par$objective, type = "l", log = "xy") ## Les itérations du VEM: la vraisemblance estimée

0 comments on commit 185c538

Please sign in to comment.