This function helps to fit a linear-plateau model in order to estimate critical soil test values (CSTV) above which yield response becomes flat.
Usage
SS_LP(x, a, b, xs)
linear_plateau(
data = NULL,
stv,
ry,
target = NULL,
tidy = TRUE,
plot = FALSE,
resid = FALSE
)
boot_linear_plateau(data, stv, ry, n = 1000, target = NULL, ...)
Arguments
- x
selfstart arg. for explanatory variable in SSlinp Default: NULL
- a
selfstart arg. for intercept Default: NULL
- b
selfstart arg. for slope Default: NULL
- xs
selfstart arg. for break/join point in SSlinp Default: NULL
- data
Optional argument to call and object of type data.frame or data.table containing the soil test value (STV) and relative yield (RY) data, Default: NULL
- stv
name of the vector containing soil test values (-) of type
numeric
.- ry
name of the vector containing relative yield values (%) of type
numeric
.- target
numeric
value of relative yield target (e.g. 90 for 90%) to estimate the CSTV. The target needs to be < plateau, otherwise, target = plateau.- tidy
logical operator (TRUE/FALSE) to decide the type of return. TRUE returns a tidy data frame or tibble (default), FALSE returns a list.
- plot
logical operator (TRUE/FALSE) to plot the linear-plateau model, Default: FALSE
- resid
logical operator (TRUE/FALSE) to plot residuals analysis, Default: FALSE
- n
sample size for the bootstrapping Default: 500
- ...
when running bootstrapped samples, the
...
(open arguments) allows to add grouping variable/s (factor or character) Default: NULL
Value
returns an object of type ggplot
if plot = TRUE.
returns a residuals plot if resid = TRUE.
returns an object of class data.frame
if tidy = TRUE,
returns an object of class list
if tidy = FALSE.
SS_LP: selfStart function to pass into the linear_plateau fit
linear_plateau: function
boot_linear_plateau: bootstrapping function
Details
See online-documentation for additional details.
Note
For extended reference, we recommend to visit: https://gradcylinder.org/post/linear-plateau/ by Austin Pearce. Self-start function code adapted from nlraa package by F. Miguez https://github.com/femiguez/nlraa
References
Anderson, R. L., and Nelson, L. A. (1975). A Family of Models Involving Intersecting Straight Lines and Concomitant Experimental Designs Useful in Evaluating Response to Fertilizer Nutrients. Biometrics, 31(2), 303–318. doi:10.2307/2529422
Examples
# \donttest{
# Example dataset
dat <- data.frame("ry" = c(65,80,85,88,90,94,93,96,97,95,98,100,99,99,100),
"stv" = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15))
# Run
fit_example_lp <- linear_plateau(data = dat,
ry = ry, stv = stv, resid = TRUE, plot = FALSE)
fit_example_lp
#> # A tibble: 1 × 16
#> intercept slope equation plateau CSTV lowerCL upperCL CI_type target STVt
#> <dbl> <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <chr> <dbl> <dbl>
#> 1 65.9 5.09 65.9 + 5.0… 97.4 6.21 5.1 7.4 Wald, … 97.4 6.2
#> # ℹ 6 more variables: AIC <dbl>, AICc <dbl>, BIC <dbl>, R2 <dbl>, RMSE <dbl>,
#> # pvalue <dbl>
# }