% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/compare_apsim.R
\name{compare_apsim}
\alias{compare_apsim}
\alias{print.out_mrg}
\alias{plot.out_mrg}
\title{Compare two or more apsim output objects}
\usage{
compare_apsim(
  ...,
  variable,
  index = "Date",
  by,
  labels,
  cRSS = FALSE,
  weights,
  verbose = FALSE
)

\method{print}{out_mrg}(x, ..., digits = 2)

\method{plot}{out_mrg}(
  x,
  ...,
  plot.type = c("vs", "diff", "resid", "ts", "density"),
  pairs = c(1, 2),
  cumulative = FALSE,
  variable,
  id,
  id.label,
  by,
  facet = FALSE,
  span = 0.75,
  dodge.width = NULL
)
}
\arguments{
\item{...}{data frames with APSIM output or observed data.}

\item{variable}{variable to plot}

\item{index}{index for merging objects. Default is \sQuote{Date}}

\item{by}{variable in \sQuote{index} used for plotting}

\item{labels}{labels for plotting and identification of objects.}

\item{cRSS}{compute (weighted) combined residual sum of squares using some or all variables}

\item{weights}{optional weights for computing the (weighted) combined sum of squares}

\item{verbose}{whether to print indexes to console (default is FALSE).}

\item{x}{object of class \sQuote{out_mrg}}

\item{digits}{digits to print (default is 2)}

\item{plot.type}{either \sQuote{vs}, \sQuote{diff}, \sQuote{ts} - for time series or \sQuote{density}}

\item{pairs}{pair of objects to compare, defaults to 1 and 2 but others are possible}

\item{cumulative}{whether to plot cumulative values (default FALSE)}

\item{id}{identification. Useful for finding extreme values. If this values is equal to 
1 and no id.label is provided all observations are labeled by the row number. If it is 
less than one points are labeled if their probability is equal or less than the id value.
For example, a value of 0.05 will label values that have a probability of 0.05 (or less)
under a normal distribution.}

\item{id.label}{optional label for the id}

\item{facet}{whether to facet or use color for the by variable (default is FALSE, meaning \sQuote{color})}

\item{span}{argument passed to \sQuote{geom_smooth}}

\item{dodge.width}{optional argument to control the \sQuote{dodge} for the \sQuote{id.label}}
}
\value{
object of class \sQuote{out_mrg}, which can be used for further plotting

it prints the index.table data.frame

it produces a plot
}
\description{
Function which allows for a simple comparison between APSIM output objects

print method for \sQuote{out_mrg}

plotting function for compare_apsim, it requires ggplot2
}
\details{
There are different metrics with different interpretations produced by this function.
Many of them take one object (assuming that is the observed data) and another object
(assuming that is the simulated or predicted) object. Some of these metrics
are a result from the regression.

- metrics that do not rely on regression (obs vs. pred): bias, mean bias, rss, rmse,
corr, concorr, mod.eff

- metrics that do depend on a regression model (Reg): intercept, slope, rsigma, R2. In this case,
a simple linear regression is first adjusted to the two variables and the parameters and
statistics are derived from that model. 

\sQuote{rsigma} is the regression residual standard deviation obtained by using the function
\code{\link[stats]{sigma}} to the regression object.

Plotting function for observed and simulated data
}
\note{
\sQuote{Con Corr} is the concordance correlation coefficient (https://en.wikipedia.org/wiki/Concordance_correlation_coefficient);
\sQuote{ME} is the model efficiency (https://en.wikipedia.org/wiki/Nash-Sutcliffe_model_efficiency_coefficient)
}
\examples{
\donttest{
## Directory with files
extd.dir <- system.file("extdata", package = "apsimx")
## Comparing observed and simulated for Wheat
data(obsWheat)
sim.opt <- read.csv(file.path(extd.dir, "wheat-sim-opt.csv"))
sim.opt$Date <- as.Date(sim.opt$Date)

cap <- compare_apsim(obsWheat, sim.opt, labels = c("obs", "sim"))

plot(cap)
plot(cap, plot.type = "diff")
plot(cap, plot.type = "resid")
plot(cap, plot.type = "ts")

plot(cap, variable = "AboveGround")
plot(cap, variable = "AboveGround", plot.type = "diff")
plot(cap, variable = "AboveGround", plot.type = "ts")

## Selecting a variable
cap <- compare_apsim(obsWheat, sim.opt, variable = "AboveGround", 
                     labels = c("obs", "sim"))
                     
## Using id
plot(cap, variable = "AboveGround", id = 0.05)
                     
}

}
