dclab 0.62.11__cp310-cp310-macosx_11_0_arm64.whl → 2.18.0__cp310-cp310-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dclab might be problematic. Click here for more details.

@@ -1,94 +0,0 @@
1
- require(stats);
2
- require(lme4);
3
-
4
- model_name <- "<MODEL_NAME>"
5
- cat("OUTPUT model:", model_name, "#*#\n")
6
-
7
- func_model <- "feature ~ group + (1 + group | repetition)"
8
- func_nullmodel <- "feature ~ (1 + group | repetition)"
9
-
10
- # These are the feature, group, and repetition arrays that are set by dclab
11
- # via templates.
12
- feature <- c(<FEATURES>)
13
- group <- c(<GROUPS>)
14
- repetition <- c(<REPETITIONS>)
15
-
16
- data <- data.frame(feature, group, repetition)
17
-
18
- if (model_name == "glmer+loglink") {
19
- Model <- glmer(func_model, data, family=Gamma(link='log'))
20
- NullModel <- glmer(func_nullmodel, data, family=Gamma(link='log'))
21
- } else if (model_name == "lmer") {
22
- Model <- lmer(func_model, data)
23
- NullModel <- lmer(func_nullmodel, data)
24
- } else {
25
- stop("Invalid model_name:", model_name)
26
- }
27
-
28
- # Anova analysis (increase verbosity by making models global)
29
- # Using anova is a very conservative way of determining
30
- # p values.
31
- res_anova <- anova(Model, NullModel)
32
- cat("OUTPUT r anova: ")
33
- res_anova
34
- cat("#*#\n")
35
-
36
- pvalue <- res_anova$"Pr(>Chisq)"[2]
37
- cat("OUTPUT anova p-value:", pvalue, "#*#\n")
38
-
39
- model_summary <- summary(Model)
40
- cat("OUTPUT r model summary:")
41
- model_summary
42
- cat("#*#\n")
43
-
44
- model_coefficients <- coef(Model)
45
- cat("OUTPUT r model coefficients:")
46
- model_coefficients
47
- cat("#*#\n")
48
-
49
- fe_reps <- model_coefficients$repetition
50
-
51
- effects <- data.frame(coef(model_summary))
52
-
53
- fe_icept <- effects$Estimate[1]
54
-
55
- fe_treat <- effects$Estimate[2]
56
-
57
- if (model_name == "glmer+loglink") {
58
- # transform back from log
59
- fe_treat <- exp(fe_icept + fe_treat) - exp(fe_icept)
60
- fe_icept <- exp(fe_icept)
61
- fe_reps[, 2] = exp(fe_reps[, 1] + fe_reps[, 2]) - exp(fe_reps[, 1])
62
- fe_reps[, 1] = exp(fe_reps[, 1])
63
- }
64
-
65
- cat("OUTPUT fixed effects intercept:", fe_icept, "#*#\n")
66
- cat("OUTPUT fixed effects treatment:", fe_treat, "#*#\n")
67
- cat("OUTPUT fixed effects repetitions:")
68
- fe_reps
69
- cat("#*#\n")
70
-
71
- # convergence
72
-
73
- # convergence warnings in lme4
74
- is_warning_generated <- function(m) {
75
- df <- summary(m)
76
- !is.null(df$optinfo$conv$lme4$messages) &&
77
- grepl('failed to converge', df$optinfo$conv$lme4$messages)
78
- }
79
- lme4_not_converged <- is_warning_generated(Model)
80
-
81
- # convergence code by the optimizer
82
- lme4l <- model_summary$optinfo$conv$lme4
83
- if (length(lme4l) == 0) {
84
- # the optimizer probably does not know
85
- conv_code <- 0
86
- } else if (is.null(lme4l$code)) {
87
- # NULL means 0
88
- conv_code <- 0
89
- } else {
90
- conv_code <- lme4l$code
91
- }
92
-
93
- cat("OUTPUT model converged:", (conv_code == 0) && !lme4_not_converged, "#*#\n")
94
- cat("OUTPUT lme4 messages:", lme4l$optinfo$conv$lme4$messages, "#*#\n")