optimization - Why "lines()" doesn't draw anything on the plot in R? -
I have the following code, but This is a result I have: And this is the plot I hope to get: you In this way, Construct that starts in the same way and ends with line () attracts nothing at plot I I've been created by plot.ts (nhtemp). I do not want to use the HaltWinter function.
Data (required) data (nhtemp) str (nhtemp) mona.function & lt; - Function (beta, y = nhtemp) {y.hat = numerical (length (y) y.hat [1] = y [1] y.hat [2] = y [2] (i in 3: Length (y) {y.hat [i] = beta * Y [i-1] + (1-beta) * y.hat [i-1]} sq.sum = 0 (i in 2: length )} {sq.sum = sq.sum + (y [i] -y.hat [i]) ^ 2} plot.ts (nhtemp) line (y.hat, col = "red") returns (sq.sum)
line (ts ( Y.hat, start = start (nhtemp) [1], end = end (nhtemp) [1]), col = "red")
Comments
Post a Comment