forked from PecanProject/pecan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetric_R2.Rd
More file actions
32 lines (30 loc) · 1022 Bytes
/
Copy pathmetric_R2.Rd
File metadata and controls
32 lines (30 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/metric_R2.R
\name{metric_R2}
\alias{metric_R2}
\title{Coefficient of Determination (R2)}
\usage{
metric_R2(metric_dat, ...)
}
\arguments{
\item{metric_dat}{dataframe with columns \code{model} and \code{obvs}}
\item{...}{ignored}
}
\description{
Coefficient of Determination (R2)
}
\details{
Computes R-squared using the correlation-based formula:
\eqn{R^2 = \left(\frac{\sum(obs - \bar{obs})(mod - \bar{mod})}
{\sqrt{\sum(obs - \bar{obs})^2} \cdot \sqrt{\sum(mod - \bar{mod})^2}}\right)^2}
If this formula returns \code{NA} (e.g. when model output is constant
across all observations), the function silently falls back to an
\code{lm()}-based R-squared via \code{summary(lm())$r.squared}.
This fallback may produce unreliable results and triggers a warning
from \code{stats::summary.lm}: "essentially perfect fit: summary may
be unreliable". Consider checking for constant model output before
calling this function.
}
\author{
Betsy Cowdery
}