Created
July 9, 2015 14:46
-
-
Save MartinMacharia/a1e468e3f8fc4abdc231 to your computer and use it in GitHub Desktop.
R Markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Here is a document. | |
A single # represents a tittle, 2 represents a subtittle) | |
`Back quotes (``)are use to represent the inside text in a type writter format` | |
*The star signs between a text italicize the text* | |
**Double stars make the text bold** | |
* **Bulleting items, star space then item. This will not only bullet but also make the bulleted text bold** | |
*Four spaces than a star creates sub-bullets | |
>Pushes the text inside | |
$For subscript notation$ | |
##Let us create a data set | |
```{r include=TRUE} | |
library(stats) | |
x <- c(0,10,20,30,40,50) | |
y <- c(2748,3162,3307,3571,3576,3544) | |
dat <- as.data.frame(cbind(x,y)) | |
``` | |
lets plot the data | |
```{r echo=TRUE,fig.width=3 ,fig.height=3.5} | |
plot(dat) | |
``` | |
Some notes on the function we are about to fit | |
SSasymp is the same function that Charlie is using, just slightly re-parameterized | |
you need at least 4 xy pairs to fit this relationship | |
y = a + (b - a) * exp(-exp(c)*x) | |
a is the asymptote | |
b is the intercept at 0 input | |
c is log rate constant ... the corresponding half saturation value is ln(2)/c | |
also see ?SSasymp | |
```{r} | |
fit <- nls(y~SSasymp(x, a, b, c), data=dat) | |
summary(fit) | |
plot(y~x, ylab="Yield (kg)", xlab="P input (kg)", dat) | |
a <-coef(fit)[1] | |
b <-coef(fit)[2] | |
c <-coef(fit)[3] | |
lines(x<-c(0:50),a+(b-a)*exp(-exp(c)*x),col='red') | |
``` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment