一项测量显示出一个类似于平方根函数带有偏移和系数的信号。我该如何找到系数并在同一张图中绘制原始数据和拟合曲线?
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)
,而不是a + b*sqrt(c*x)
。 - Hong Ooi