library(lavaan)
## This is lavaan 0.6-7
## lavaan is BETA software! Please report any bugs.
library(semPlot)
## Registered S3 methods overwritten by 'huge':
## method from
## plot.sim BDgraph
## print.sim BDgraph
library(OpenMx)
## To take full advantage of multiple cores, use:
## mxOption(key='Number of Threads', value=parallel::detectCores()) #now
## Sys.setenv(OMP_NUM_THREADS=parallel::detectCores()) #before library(OpenMx)
##
## Attaching package: 'OpenMx'
## The following object is masked from 'package:lavaan':
##
## vech
library(tidyverse)
## ── Attaching packages ───────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2 ✓ purrr 0.3.4
## ✓ tibble 3.0.3 ✓ dplyr 1.0.2
## ✓ tidyr 1.1.2 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.5.0
## ── Conflicts ──────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(knitr)
library(kableExtra)
##
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
##
## group_rows
library(GGally)
## Registered S3 method overwritten by 'GGally':
## method from
## +.gg ggplot2
DADOS = read.csv("DADOS_CANA.csv", header = TRUE, sep = ";", dec = ",")
str(DADOS)
## 'data.frame': 108 obs. of 7 variables:
## $ Clones: chr "RB975375" "RB975375" "RB975375" "RB006655 " ...
## $ Rep : int 1 2 3 1 2 3 1 2 3 1 ...
## $ FIBRA : num 12.7 12.6 12.8 13.3 13 ...
## $ PZA : num 85.4 84.8 85.9 83.9 81.1 ...
## $ PCC : num 15.7 15.7 15.7 14.9 13.5 ...
## $ ATR : num 155 154 154 148 137 ...
## $ TIPO : chr "PLANTA" "PLANTA" "PLANTA" "PLANTA" ...
DADOS$Clones = as.factor(DADOS$Clones)
DADOS$Rep = as.factor(DADOS$Rep)
DADOS$TIPO = as.factor(DADOS$TIPO)
dados_planta = DADOS[which(DADOS$TIPO=="PLANTA"),]
dados_soca = DADOS[which(DADOS$TIPO=="SOCA"),]
lm_planta = lm(ATR~Clones+Rep+FIBRA+PZA+PCC, data = dados_planta)
anova(lm_planta)
## Analysis of Variance Table
##
## Response: ATR
## Df Sum Sq Mean Sq F value Pr(>F)
## Clones 17 4101.6 241.268 29.7623 1.481e-14 ***
## Rep 2 6.2 3.115 0.3843 0.68412
## FIBRA 1 51.8 51.834 6.3941 0.01676 *
## PZA 1 176.5 176.510 21.7739 5.578e-05 ***
## PCC 1 42.7 42.662 5.2627 0.02872 *
## Residuals 31 251.3 8.107
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lm_soca = lm(ATR~Clones+Rep+FIBRA+PZA+PCC, data = dados_soca)
anova(lm_soca)
## Analysis of Variance Table
##
## Response: ATR
## Df Sum Sq Mean Sq F value Pr(>F)
## Clones 17 6618.8 389.34 30.8398 8.933e-15 ***
## Rep 2 2.5 1.27 0.1008 0.9044
## FIBRA 1 1.4 1.43 0.1129 0.7391
## PZA 1 34.1 34.09 2.7000 0.1105
## PCC 1 500.5 500.54 39.6480 5.290e-07 ***
## Residuals 31 391.4 12.62
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lm_geral = lm(ATR~Clones+Rep%in%TIPO+FIBRA+PZA+PCC+TIPO+Clones:TIPO, data = DADOS)
anova(lm_geral)
## Analysis of Variance Table
##
## Response: ATR
## Df Sum Sq Mean Sq F value Pr(>F)
## Clones 17 9605.0 565.00 47.5694 < 2.2e-16 ***
## FIBRA 1 81.8 81.84 6.8903 0.01079 *
## PZA 1 938.3 938.34 79.0017 7.794e-13 ***
## PCC 1 889.6 889.63 74.9006 2.016e-12 ***
## TIPO 1 11.8 11.78 0.9919 0.32297
## Rep:TIPO 4 14.7 3.67 0.3090 0.87098
## Clones:TIPO 17 368.7 21.69 1.8259 0.04330 *
## Residuals 65 772.0 11.88
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
modelo = 'ATR~FIBRA+PZA+PCC'
fit = cfa(modelo, data = DADOS)
summary(fit,fit.measures = TRUE, standardized=T,rsquare=T)
## lavaan 0.6-7 ended normally after 25 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of free parameters 4
##
## Number of observations 108
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 196.737
## Degrees of freedom 3
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -312.231
## Loglikelihood unrestricted model (H1) -312.231
##
## Akaike (AIC) 632.461
## Bayesian (BIC) 643.190
## Sample-size adjusted Bayesian (BIC) 630.551
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value RMSEA <= 0.05 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ATR ~
## FIBRA -0.258 0.539 -0.480 0.632 -0.258 -0.021
## PZA -0.044 0.149 -0.294 0.769 -0.044 -0.015
## PCC 8.405 0.501 16.765 0.000 8.405 0.915
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .ATR 18.995 2.585 7.348 0.000 18.995 0.162
##
## R-Square:
## Estimate
## ATR 0.838
semPaths(fit,"std",layout = 'tree', edge.label.cex=.9, curvePivot = TRUE)
ggcorr(DADOS[-c(1, 2,7)], nbreaks = 6, label = T, low = "red3", high = "green3",
label_round = 2, name = "Correlation Scale", label_alpha = T, hjust = 0.75) +
ggtitle(label = "Correlation Plot") +
theme(plot.title = element_text(hjust = 0.6))
modelo_planta = 'ATR~FIBRA+PZA+PCC'
fit_planta = cfa(modelo_planta, data = dados_planta)
summary(fit_planta,fit.measures = TRUE, standardized=T,rsquare=T)
## lavaan 0.6-7 ended normally after 22 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of free parameters 4
##
## Number of observations 54
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 92.667
## Degrees of freedom 3
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -150.476
## Loglikelihood unrestricted model (H1) -150.476
##
## Akaike (AIC) 308.952
## Bayesian (BIC) 316.908
## Sample-size adjusted Bayesian (BIC) 304.341
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value RMSEA <= 0.05 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ATR ~
## FIBRA -0.995 0.575 -1.731 0.084 -0.995 -0.113
## PZA -0.111 0.167 -0.664 0.506 -0.111 -0.048
## PCC 7.148 0.623 11.473 0.000 7.148 0.884
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .ATR 15.414 2.967 5.196 0.000 15.414 0.180
##
## R-Square:
## Estimate
## ATR 0.820
semPaths(fit_planta, 'std', layout = 'circle')
semPaths(fit_planta,"std",layout = 'tree', edge.label.cex=.9, curvePivot = TRUE)
modelo_soca = 'ATR~FIBRA+PZA+PCC'
fit_soca = cfa(modelo_soca, data = dados_soca)
summary(fit_soca,fit.measures = TRUE, standardized=T,rsquare=T)
## lavaan 0.6-7 ended normally after 29 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of free parameters 4
##
## Number of observations 54
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 121.689
## Degrees of freedom 3
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -149.162
## Loglikelihood unrestricted model (H1) -149.162
##
## Akaike (AIC) 306.325
## Bayesian (BIC) 314.281
## Sample-size adjusted Bayesian (BIC) 301.714
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value RMSEA <= 0.05 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ATR ~
## FIBRA 0.923 1.023 0.902 0.367 0.923 0.044
## PZA 0.083 0.232 0.357 0.721 0.083 0.022
## PCC 10.130 0.687 14.753 0.000 10.130 0.949
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .ATR 14.683 2.826 5.196 0.000 14.683 0.105
##
## R-Square:
## Estimate
## ATR 0.895
semPaths(fit_soca, 'std', layout = 'circle')
semPaths(fit_soca,"std",layout = 'tree', edge.label.cex=.9, curvePivot = TRUE)