Sine curve fit using lm and nls in R

后端 未结 4 1481
自闭症患者
自闭症患者 2020-12-30 09:42

I am a beginner in curve fitting and several posts on Stackoverflow really helped me.

I tried to fit a sine curve to my data using lm and nls

4条回答
  •  天命终不由人
    2020-12-30 09:45

    How about choosing an X and an Y while doing your line plot instead of just choosing the Y.

    plot(time,predict(fit.nls),type="l", col="red", xlim=c(1, 900), pch=19, ann=FALSE, xaxt="n",
    yaxt="n")
    

    Also both lm and nls just give you the fitted points. So you must estimate the rest of the points in order to make a curve, a line plot. Since you are with nls and lm, perhaps the function predict maybe useful.

提交回复
热议问题