Dear R experts, I was wondering how I could do a fit (say minimum chi2) to a 1D data with error bars. I searched quite a lot on the web, found out about the fitdistr() function in MASS, etc., but none of the things I found gives what I am really looking for. Perhaps I do not exactly know the proper terminology and this is why I cannot find the solution. We could also probably describe it as "parameter estimation using the minimum chi2 method using data with error bars and an arbitrary fitting function". Anyway, in order not to confuse people with possibly incorrect terminology, let me show you what I am really looking for. Here is a page that shows what I want in Matlab (see the section on weighted fit): http://www.mathworks.com/matlabcentral/fileexchange/10176-ezyfit-2-41/content/ezyfit/demo/html/efdemo.html#19 Could you please help? Thanks in advance, e. [[alternative HTML version deleted]]
Suzen, Mehmet
2013-Nov-14 02:21 UTC
[R] Fitting arbitrary curve to 1D data with error bars
If you are after adding error bars in a scatter plot; one example is given below : #some example data set.seed(42) df <- data.frame(x = rep(1:10,each=5), y = rnorm(50)) #calculate mean, min and max for each x-value library(plyr) df2 <- ddply(df,.(x),function(df) c(mean=mean(df$y),min=min(df$y),max=max(df$y))) #plot error bars library(Hmisc) with(df2,errbar(x,mean,max,min)) grid(nx=NA,ny=NULL) (From: http://stackoverflow.com/questions/13032777/scatter-plot-with-error-bars)