A measurement shows a signal that is formed like a square root function with offset and a factor. How can I find the coefficients and plot the raw data and the fitted curve in one plot?
require(ggplot2)
require(nlmrt) # may be this will help later..?
# generate simulated measurement data
time <- seq(-10,20,0.2)
signal <- sqrt(time + 2) # generate sqrt signal; includes some NA
signal[is.na(signal)] <- 0 # set all NA to zero
signal <- signal + rnorm(length(time)) * 0.1 # add noise
df <- data.frame(x=time, y=signal)
# find coefficiants for y ~ b * sqrt(x - a)
# no idea how...
# plot raw data and fitted curve in one ggplot diagram
ggplot()+
geom_point(data=df, aes(x=x, y=y))
y ~ b * sqrt(x - a)
, as opposed toa + b*sqrt(c*x)
. – Hong Ooi Jun 14 '13 at 17:33