Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

IA_tab

Indexes of Agreement Table


Description

Indexes of agreement

plotting function for a IA_tab, it requires ‘ggplot2’

Usage

IA_tab(obs, sim, object, null.object)

## S3 method for class 'IA_tab'
plot(x, y, ..., type = c("OvsS", "RvsS"))

Arguments

obs

vector with observed data

sim

vector with simulated data (should be the same length as observed)

object

alternative to the previous two arguments. An object of class ‘lm’, ‘nls’ or ‘lme’

null.object

optional object which represents the ‘null’ model. It is an intercept-only model by default.

x

object of class ‘IA_tab’.

y

not used at the moment

...

additional plotting arguments (none use at the moment).

type

either “OvsS” (observed vs. simulated) or “RvsS” (residuals vs. simulated).

Details

This function returns several indexes that might be useful for interpretation

For obbjects of class ‘lm’ or ‘nls’
bias: mean(obs - sim)
intercept: intercept of the model obs ~ beta_0 + beta_1 * sim + error
slope: slope of the model obs ~ beta_0 + beta_1 * sim + error
RSS (deviance): residual sum of squares of the previous model
MSE (RSS / n): mean squared error; where n is the number of observations
RMSE: squared root of the previous index
R2.1: R-squared extracted from an ‘lm’ object
R2.2: R-squared computed as the correlation between observed and simulated to the power of 2.
ME: model efficiency
NME: Normalized model efficiency
Corr: correlation between observed and simulated
ConCorr: concordance correlation

For objects of class ‘gls’, ‘gnls’, ‘lme’ or ‘nlme’ there are additional metrics such as:

See Also

Examples

require(nlme)
require(ggplot2)
## Fit a simple model and then compute IAs
data(swpg)
#' ## Linear model
fit0 <- lm(lfgr ~ ftsw + I(ftsw^2), data = swpg)
ias0 <- IA_tab(object = fit0)
ias0$IA_tab
## Nonlinear model
fit1 <- nls(lfgr ~ SSblin(ftsw, a, b, xs, c), data = swpg)
ias1 <- IA_tab(object = fit1)
ias1$IA_tab
plot(ias1)
## Linear Mixed Models
data(barley, package = "nlraa")
fit2 <- lme(yield ~ NF + I(NF^2), random = ~ 1 | year, data = barley)
ias2 <- IA_tab(object = fit2)
ias2$IA_tab
## Nonlinear Mixed Model
barleyG <- groupedData(yield ~ NF | year, data = barley)
fit3L <- nlsLMList(yield ~ SSquadp3(NF, a, b, c), data = barleyG)
fit3 <- nlme(fit3L, random = pdDiag(a + b ~ 1))
ias3 <- IA_tab(object = fit3)
ias3$IA_tab
plot(ias3)
## Plotting model
prds <- predict_nlme(fit3, interval = "conf", plevel = 0)
barleyGA <- cbind(barleyG, prds)
ggplot(data = barleyGA, aes(x = NF, y = yield)) + 
   geom_point() + 
   geom_line(aes(y = Estimate)) + 
   geom_ribbon(aes(ymin = Q2.5, ymax = Q97.5), 
               fill = "purple", alpha = 0.2)
## R2M for model 2
R2M(fit2)
## R2M for model 3
R2M(fit3)

nlraa

Nonlinear Regression for Agricultural Applications

v0.89
GPL-3
Authors
Fernando Miguez [aut, cre] (<https://orcid.org/0000-0002-4627-8329>), José Pinheiro [ctb, cph] (author of nlme::nlsList, nlme::predict.gnls, nlme::predict.nlme), Douglas Bates [ctb, cph] (author of nlme::nlsList, nlme::predict.gnls, nlme::predict.nlme), R-core [ctb, cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.