4
$\begingroup$

I have a series of high-low tide values, approx. every 6h, and each one has the corresponding time. I would like to get (an estimation of) the values between each record. I was thinking I could create a sinusoidal curve but I am not sure if just simply giving the min-max y-values are enough.

Here is a part of the data:

y <- c(0.96, 0.27, 1.11, 0.35, 0.90, 0.35, 1.06, 0.34, 0.90, 0.38, 1.06, 0.28)
t <- c(42489.02, 42489.27, 42489.55, 42489.82, 42490.07, 42490.32, 42490.60, 42490.88, 42491.13, 42491.39, 42491.66, 42491.94)

I tried to apply the following formula (following this question: Fit a sinusoidal term to data):

res <- nls(y ~ A*sin(omega*t+phi)+C, data=data.frame(t,y), start=list(A=1,omega=1,phi=1,C=1))

But I got this error:

Error in nls(y ~ A * sin(omega * t + phi) + C, data = data.frame(t, y),  : 
  step factor 0.000488281 reduced below 'minFactor' of 0.000976562

1º Question: Is this approach correct for the result I want?

2º Question: If it is, how can I solve this error?

$\endgroup$
9
  • 3
    $\begingroup$ I think it's easier to use least squares on sine and cosine. That way the phase is implicit but recoverable. See e.g. stats.stackexchange.com/questions/163837/… stata-journal.com/sjpdf.html?articlenum=st0116 (esp. p.567) $\endgroup$
    – Nick Cox
    Jun 11, 2018 at 11:23
  • 1
    $\begingroup$ Use the direct and inverse Fourier transforms, way easier (and equivalent to regression on sine and cosine terms). $\endgroup$
    – Firebug
    Jun 11, 2018 at 11:44
  • 1
    $\begingroup$ Tidal data tends not to be sinusoidal: the pattern is asymmetric. Consider obtaining some data about the intervening times. $\endgroup$
    – whuber
    Jun 11, 2018 at 13:38
  • 1
    $\begingroup$ Tide table predictions are fairly well established and behave a bit like train schedules, e.g., here, tidesandcurrents.noaa.gov/predmach.html, see formulas #1 and #2. Along with time if you have date, location and plugging average values in for the unknowns into the NOAA formulas you would have a much greater chance of obtaining reasonable estimates. $\endgroup$
    – user78229
    Jun 11, 2018 at 13:41
  • 1
    $\begingroup$ Not a routine R user, sorry, but how do anything in any particular software is off-topic here unless there is a statistical issue. (I quoted the Stata Journal paper for its explanation of principles, not its Stata code.) The positive point is that the recommended procedure is just regression (notwithstanding other key comments that tides have a different basis). $\endgroup$
    – Nick Cox
    Jun 11, 2018 at 18:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.