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

Some Fix in plnnetwork (Issue #129 and #130) #131

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading