
- #IGOR PRO IF WITH LESS THAN AND GREATERTHAN HOW TO#
- #IGOR PRO IF WITH LESS THAN AND GREATERTHAN CODE#
This function optimizes the starting values through some sort of searching, and the resulting equation is y = 39.2 + 0.75x up to 75 ppm K, which is similar to the first. # Number of iterations to convergence: 8įlawless (so long as we use nlsLM). For the function SSlinp, the author uses xs as the critical x-value or break-point whereas I’ve chosen jp to represent the “join-point”. The nlraa package provides just that, a self-starting function for a linear-plateau model. Let’s try that.īetter than providing starting values to nls or nlsLM is to use a function that can “self-start”. Using a self-starting function that uses an optimization algorithm to get starting values might be a more precise and reliable way to go. Quite a bit different perhaps just by using different starting values. It worked again, but notice that the response equation now is y = 19.3 + 1.33x up to 56 ppm K. # Number of iterations to convergence: 15 # Residual standard error: 10.71 on 21 degrees of freedom In fact, we could wrap all of these steps into a function. From this the intercept and slope can be estimated, and the join point can then be estimated by taking the mean or median of the soil test values. If you’re a sane person, you might decide to get starting values for a LP model by fitting a regular ol’ line. # Achieved convergence tolerance: 1.49e-08Īnd it worked! The response equation is y = 39.8 + 0.74x up to 75 ppm K. # Number of iterations to convergence: 19 # Residual standard error: 11.06 on 21 degrees of freedom Going to the left, that imaginary line looks like it might intercept the y-axis around 20-30, maybe? The slope of that line would be positive, and looks like maybe it’s around 2-ish (2% RY gain for every 1 ppm increase). The join point is easiest to imagine, and I’d guess it’s somewhere between 60 and 80 ppm K. Scroll to the bottom of this page if you struggle to visualize this.Įyeballing that scatter plot, I’m trying to visualize in my mind’s eye a straight line coming up and breaking over at a join point. Looking at the plot, notice how the relative yield of the cotton does not appear to increase anymore from about 70-200 ppm K (the plateau!). The LP model is a type of segmented model, and is simpler than quadratic plateaus because there is no curve! Maybe the curve is important to biological systems, but for now note that in a LP model the response line meets a zero-slope plateau at a well-defined join point.

Perhaps a polynomial function could be fit, or the data could be transformed, but we’ll fit a nonlinear model known as the linear plateau (LP), or lin-plat 3.

The relationship between soil test potassium (STK) and relative cotton yield may be nonlinear 2. "Relative yield and soil potassium for", nrow(cotton), "cotton trials"), Let’s plot it to see what we’re working with. Fitting a model to determine something about this relationship is central to the soil-test correlation process. Basically, more potassium measured in the soil should correlate to more cotton yield, but the relationship will most likely not be linear. The data is suppose to be some cotton trials based on Cate and Nelson (1971), and can be accessed through the agridat package. Library(devtools) # for sourcing the lin_plateau() function in Method 3 Library(modelr) # for the r-squared and rmse Library(minpack.lm)# for nls with Levenberg-Marquardt algorithm Library(nlraa) # for self-starting models

Library(tidyverse) # for data manipulation and plotting and so on My R programming language has a heavy tidyverse accent.
#IGOR PRO IF WITH LESS THAN AND GREATERTHAN CODE#
To make your life easier, here is a link to the R code so that you do not have to copy and paste code chunks from this page. I’ve written this post in the context of soil test correlation, so the code isn’t an out-of-the-box solution for any kind of analysis. Like my suspiciously similar post on quadratic plateau models in R This post demonstrates three ways to fit a linear-plateau model, and presents an unnecessary unique function that sort of helps one do linear plateau fits and make a ggplot style figure all at once.
#IGOR PRO IF WITH LESS THAN AND GREATERTHAN HOW TO#
This post is intended for the person 1 who has been googling how to fit linear plateau models in R. Crop yields go up a line, then level off.
