A blog for physicists or biologists. Mainly for experimentalists interested in Statistics. R scripts detailed and explained.
wilfried.grangeu-paris.fr
Associate Professor at Université Paris Cité
A step by step guide to perform a single-factor ANOVA
Let's first have a look at the code below:
rm(list = ls())
n<-2:20
m<-factorial(n)/(factorial(n-2)*factorial(2))
p<- 1- (1-0.05)^m
plot(n,p, main='Probability to observe at least 1 false discovery', xlab='Number of samples')
grid()
Here, I demonstrate how to fit multiple data at once using an easy script
For this example, I use ggplot2 and so you need to enter:
rm(list = ls())
if (!require(ggplot2)) install.packages('ggplot2')
Non-linear fitting with R (few points, with error bars). I also discuss how some parameters can give statistical information regarding the quality of the fit
As an example of non-linear fitting, I will perform a Michaelis Menten fit on some synthetic data. I am using 3 vectors, which represent the Substrate concentration (S), the rate of product formation (v) as well as the error on v (dv).
rm(list = ls())
# data (use c to create a vector and combine elements of identical types)
v<-c(0.004507692,0.004192308,0.00355384,0.002576923,0.001661538,0.001064286)
S<-c(3.6000,1.8000,0.9000,0.4800,0.2250,0.1125)
dv<-c(0.00012, 0.00008, 0.00012, 0.00010, 0.00007, 0.00005)
How to make a very simple linear fit with R (few points, no error bars)
rm(list = ls()) #remove ~ everything in the working environment
myX<-1:10
myY<-jitter(1:10)
adjust<-lm(myY ~ myX) # Use adjust<-lm(myY ~ 0 + myX) to force the intercept at 0
plot(myX,myY,abline(adjust))