# NOT RUN {
library(metan)
# Using KW as the response variable and all other ones as predictors
pcoeff <- path_coeff(data_ge2, resp = KW)
# The same as above, but using the correlation matrix
cor_mat <- cor(data_ge2 %>% select_numeric_cols())
pcoeff <- path_coeff_mat(cor_mat, resp = KW)
# Declaring the predictors
# Create a residual plot with 'plot_res = TRUE'
pcoeff2 <- path_coeff(data_ge2,
resp = KW,
pred = c(PH, EH, NKE, TKW),
plot_res = TRUE)
# Selecting variables to be excluded from the analysis
pcoeff3 <- path_coeff(data_ge2,
resp = KW,
pred = c(NKR, PERK, KW, NKE),
exclude = TRUE)
# Selecting a set of predictors with minimal multicollinearity
# Maximum variance Inflation factor of 5
pcoeff4 <- path_coeff(data_ge2,
resp = KW,
brutstep = TRUE,
maxvif = 5)
# When one analysis should be carried out for each environment
# Using the forward-pipe operator %>%
pcoeff5 <- path_coeff(data_ge2, resp = KW, by = ENV)
# }
Run the code above in your browser using DataLab