“ALL_” (tutti i dati), “I_” (solo interfila) I_AV_ (solo interfila; solo AV) I_PE_ (solo interfila; sola PE)
# Lista delle variabili per il ciclo
codes <- c("all_", "I_", "AV_I_", "PE_I_")
file_names <- c("FD_H", "FD_SLA", "FD_poll", "FD_seed_weight", "FD_life_span", "FD_N_fixing", "FD_growth_form")
# variabili_risposta <- c("canopy_height", "SLA", "pollinators", "seed_weight", "life_span", "N.fixing", "growth_form")
elenco_modelli_FD<- c()
# Ciclo per fare i modelli in base ai sottogruppi (fila/interfila, AV/PE)
for (code in codes){
# Ciclo per inserire i dataset
for (file_name in file_names){
dataframe_name <- paste0(code, file_name, sep="")
dataframe <- get(dataframe_name)
# Ciclo per costruire i modelli in base alla variabile risposta
variabile_risposta <- colnames(dataframe)[1]
modello <- lmer(as.formula(paste(variabile_risposta, "~ sistema + anno + (1 | blocco)")), data = dataframe)
## ANALISI MODELLO
#risultati modello
anova <- anova(modello)
#shapiro test modello per normalità residui
normality <- shapiro.test(residuals(modello))
#Durbin-Watson test per indipendenza residui
indipendence <- durbinWatsonTest(residuals(modello))
# • SALVO OUTPUT MODELLI E ANALISI
# Nome del modello basato sulla variabile risposta
nome_modello <- paste(code, "FD_model_", file_name, sep = "")
# Assegna il modello a una variabile con nome dinamico
assign(nome_modello, modello)
nome_anova <- paste(code, "FD_anova_model_", file_name, sep = "")
# Assegna il modello a una variabile con nome dinamico
assign(nome_anova, anova)
nome_normality <- paste(code, "FD_normality_model_", file_name, sep = "")
# Assegna il modello a una variabile con nome dinamico
assign(nome_normality, normality$p.value)
nome_indipendence <- paste(code, "FD_indipendence_model_", file_name, sep = "")
# Assegna il modello a una variabile con nome dinamico
assign(nome_indipendence, indipendence)
# • Creo vettore con tutte le variabili create
nome_modello <- paste(code, "FD_model_", file_name, sep = "")
elenco_modelli_FD <- c(elenco_modelli_FD, nome_modello)
elenco_modelli_FD <- unique(elenco_modelli_FD)
}}
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
r_squared <- numeric(length(elenco_modelli_CWM))
print(elenco_modelli_CWM)
## [1] "all_CWM_model_canopy_height" "all_CWM_model_SLA"
## [3] "all_CWM_model_seed_weight" "all_CWM_model_N.fixing"
## [5] "all_CWM_model_annuals" "all_CWM_model_perennials"
## [7] "all_CWM_model_chamaephyte" "all_CWM_model_hemicryptophyte"
## [9] "all_CWM_model_cryptophyte" "all_CWM_model_therophyte"
## [11] "all_CWM_model_epiphyte" "I_CWM_model_canopy_height"
## [13] "I_CWM_model_SLA" "I_CWM_model_seed_weight"
## [15] "I_CWM_model_N.fixing" "I_CWM_model_annuals"
## [17] "I_CWM_model_perennials" "I_CWM_model_chamaephyte"
## [19] "I_CWM_model_hemicryptophyte" "I_CWM_model_cryptophyte"
## [21] "I_CWM_model_therophyte" "I_CWM_model_epiphyte"
## [23] "AV_I_CWM_model_canopy_height" "AV_I_CWM_model_SLA"
## [25] "AV_I_CWM_model_seed_weight" "AV_I_CWM_model_N.fixing"
## [27] "AV_I_CWM_model_annuals" "AV_I_CWM_model_perennials"
## [29] "AV_I_CWM_model_chamaephyte" "AV_I_CWM_model_hemicryptophyte"
## [31] "AV_I_CWM_model_cryptophyte" "AV_I_CWM_model_therophyte"
## [33] "AV_I_CWM_model_epiphyte" "PE_I_CWM_model_canopy_height"
## [35] "PE_I_CWM_model_SLA" "PE_I_CWM_model_seed_weight"
## [37] "PE_I_CWM_model_N.fixing" "PE_I_CWM_model_annuals"
## [39] "PE_I_CWM_model_perennials" "PE_I_CWM_model_chamaephyte"
## [41] "PE_I_CWM_model_hemicryptophyte" "PE_I_CWM_model_cryptophyte"
## [43] "PE_I_CWM_model_therophyte" "PE_I_CWM_model_epiphyte"
for (model_name in elenco_modelli_CWM) {
modello <- get(model_name)
# summary_model <- summary(modello)
R2 <- r.squaredGLMM(modello)
index <- which(elenco_modelli_CWM == model_name)
r_squared[index] <- R2
}
## Warning: 'r.squaredGLMM' now calculates a revised statistic. See the help page.
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
## Warning in r_squared[index] <- R2: number of items to replace is not a multiple
## of replacement length
print(r_squared)
## [1] 0.0272093875 0.0319001247 0.0389749462 0.0109817163 0.0092817757
## [6] 0.0092817757 0.0087425292 0.0616135215 0.1108975811 0.0211682382
## [11] 0.0515524711 0.0144521271 0.0161460010 0.0109288868 0.0118258133
## [16] 0.0724094136 0.0724094136 0.0206553116 0.0652549122 0.0297390626
## [21] 0.0731012990 0.0591131162 0.0189172442 0.0073341578 0.0005487211
## [26] 0.0076482851 0.0372676292 0.0372676292 0.0165344018 0.0269380861
## [31] 0.0395567068 0.0503034892 0.1181905652 0.0243029399 0.0738942794
## [36] 0.0312564790 0.0246485743 0.2970680771 0.2970680771 0.0330892126
## [41] 0.2000893439 0.0689777299 0.2741058790 0.0122147925
for (model_name in elenco_modelli_CWM) {
i <- which(elenco_modelli_CWM == model_name)
cat(model_name,": R quadro =", r_squared[i], "\n")
}
## all_CWM_model_canopy_height : R quadro = 0.02720939
## all_CWM_model_SLA : R quadro = 0.03190012
## all_CWM_model_seed_weight : R quadro = 0.03897495
## all_CWM_model_N.fixing : R quadro = 0.01098172
## all_CWM_model_annuals : R quadro = 0.009281776
## all_CWM_model_perennials : R quadro = 0.009281776
## all_CWM_model_chamaephyte : R quadro = 0.008742529
## all_CWM_model_hemicryptophyte : R quadro = 0.06161352
## all_CWM_model_cryptophyte : R quadro = 0.1108976
## all_CWM_model_therophyte : R quadro = 0.02116824
## all_CWM_model_epiphyte : R quadro = 0.05155247
## I_CWM_model_canopy_height : R quadro = 0.01445213
## I_CWM_model_SLA : R quadro = 0.016146
## I_CWM_model_seed_weight : R quadro = 0.01092889
## I_CWM_model_N.fixing : R quadro = 0.01182581
## I_CWM_model_annuals : R quadro = 0.07240941
## I_CWM_model_perennials : R quadro = 0.07240941
## I_CWM_model_chamaephyte : R quadro = 0.02065531
## I_CWM_model_hemicryptophyte : R quadro = 0.06525491
## I_CWM_model_cryptophyte : R quadro = 0.02973906
## I_CWM_model_therophyte : R quadro = 0.0731013
## I_CWM_model_epiphyte : R quadro = 0.05911312
## AV_I_CWM_model_canopy_height : R quadro = 0.01891724
## AV_I_CWM_model_SLA : R quadro = 0.007334158
## AV_I_CWM_model_seed_weight : R quadro = 0.0005487211
## AV_I_CWM_model_N.fixing : R quadro = 0.007648285
## AV_I_CWM_model_annuals : R quadro = 0.03726763
## AV_I_CWM_model_perennials : R quadro = 0.03726763
## AV_I_CWM_model_chamaephyte : R quadro = 0.0165344
## AV_I_CWM_model_hemicryptophyte : R quadro = 0.02693809
## AV_I_CWM_model_cryptophyte : R quadro = 0.03955671
## AV_I_CWM_model_therophyte : R quadro = 0.05030349
## AV_I_CWM_model_epiphyte : R quadro = 0.1181906
## PE_I_CWM_model_canopy_height : R quadro = 0.02430294
## PE_I_CWM_model_SLA : R quadro = 0.07389428
## PE_I_CWM_model_seed_weight : R quadro = 0.03125648
## PE_I_CWM_model_N.fixing : R quadro = 0.02464857
## PE_I_CWM_model_annuals : R quadro = 0.2970681
## PE_I_CWM_model_perennials : R quadro = 0.2970681
## PE_I_CWM_model_chamaephyte : R quadro = 0.03308921
## PE_I_CWM_model_hemicryptophyte : R quadro = 0.2000893
## PE_I_CWM_model_cryptophyte : R quadro = 0.06897773
## PE_I_CWM_model_therophyte : R quadro = 0.2741059
## PE_I_CWM_model_epiphyte : R quadro = 0.01221479
r.squaredGLMM(PE_I_CWM_model_canopy_height)
## R2m R2c
## [1,] 0.02430294 0.06250206
r.squaredGLMM(AV_I_CWM_model_canopy_height)
## R2m R2c
## [1,] 0.01891724 0.02055278
r.squaredGLMM(I_CWM_model_canopy_height)
## R2m R2c
## [1,] 0.01445213 0.03277968
r.squaredGLMM(all_CWM_model_canopy_height)
## R2m R2c
## [1,] 0.02720939 0.08087853
miglior_modello <- which.max(r_squared)
cat("\nIl miglior modello è il numero", miglior_modello, "con R quadro =", r_squared[miglior_modello], "\n")
##
## Il miglior modello è il numero 39 con R quadro = 0.2970681
#
#
# for (model_name in elenco_modelli_CWM) {
# modello <- get(model_name)
# summary_model <- summary(modello)
# index <- which(elenco_modelli_CWM == model_name)
# r_squared[index] <- summary_model$r.squared
# }
tab_model(modello)
| epiphyte | |||
|---|---|---|---|
| Predictors | Estimates | CI | p |
| (Intercept) | 0.00 | -0.00 – 0.00 | 0.199 |
| sistema [ICC] | -0.00 | -0.00 – 0.00 | 0.223 |
| sistema [INC] | -0.00 | -0.00 – -0.00 | 0.019 |
| anno | 0.00 | -0.00 – 0.00 | 0.254 |
| Random Effects | |||
| σ2 | 0.00 | ||
| τ00 blocco | 0.00 | ||
| ICC | 0.02 | ||
| N blocco | 3 | ||
| Observations | 586 | ||
| Marginal R2 / Conditional R2 | 0.012 / 0.032 | ||