[R] generating points over a function, its possible???
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Fri Jun 21 23:04:03 CEST 2002
kjetil halvorsen <kjetilh at umsanet.edu.bo> writes:
> what you need is rnorm, which gives N(0,1) variates, and then multiply
> with the standard deviation you have estimated, sqrt(13.01403). Then
>
> x (your data ve ctor)
> yhat <- 9.7909 + 0.035*x
> ysim <- yhat + sqrt(13.01403)*rnorm(x)
Or, using the fact that rnorm has further arguments:
ysim <- rnorm(length(x), mean=9.7909+0.035*x, sd=sqrt(13.01403))
(Yes, you can use x instead of length(x), but once bitten...)
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list