[R] lines() warning message
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Thu Jul 3 23:07:43 CEST 2008
Ranney, Steven wrote:
> I have data that looks like
>
> Year,Recruit,Spawner,Mtempcv
> 1958,4532,775,0.24125
> 1959,22996,2310,0.16319
> 1960,628,2990,0.46056
> 1961,879,1400,0.33028
> 1962,14747,1130,0.22618
> 1963,13205,790,0.20596
> 1964,31793,1195,0.19229
> 1965,10621,981,0.20363
> 1966,22271,870,0.3452
> 1967,8736,1104,0.27511
> 1968,8761,883,0.10884
> 1969,18885,1421,0.17799
> 1970,10098,1198,0.2106
> 1971,3394,760,0.22098
> 1972,1697,1354,0.39461
> 1973,25159,1308,0.19696
> [truncated]
>
> with program
>
> #Ricker Curve
> mod2=nls(Recruit~(Spawner*exp((delta+echo*Spawner)+(foxtrot*Mtempcv))), data=box48,
> start=list(delta=4, echo=0, foxtrot=-7), trace=TRUE)
> plot(Recruit~Spawner, data=box48, pch=19)
> mod2a=seq(369, 3000)
> lines(mod2a, predict(mod2, list(Spawner=mod2a)), col="red", lty=2)
>
> R has no problem finding a solution to the nls() model (only 7 iterations are needed), but when I try to plot the line on the requested plot, I get the warning message "Warning message:
> In (delta + echo * Spawner) + (foxtrot * Mtempcv) :
> longer object length is not a multiple of shorter object length."
>
> R tries to plot the line, but it appears as just a mess of vertical lines that get more dense where (I would imagine) the actual line is to go. Any ideas what may be causing this issue?
>
>
Hmm,,, The predict() call looks dodgy. The model depends on Spawner AND
Mtempcv, but you're only giving the former in the newdata= part. So a
good guess that one of them is recycled to the length of the other.
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list