测量显示一个信号,该信号形成为具有偏移和因子的平方根函数。如何找到系数并将原始数据和拟合曲线绘制在一个图中?
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))