[R] generating points over a function, its possible???

Roger Peng rpeng at stat.ucla.edu
Fri Jun 21 21:55:01 CEST 2002


How about this?

f <- function(x) { 9.7909 - 0.035 * x }
x <- 1:100 ## or whatever
sigma <- sqrt(13.01403)
sim.y <- f(x) + sigma * rnorm(length(x))

This uses Normal errors, which (by your picture) seems like what you want.
You might want to use set.seed() so that you can reproduce the results.

-roger
_______________________________
UCLA Department of Statistics
rpeng at stat.ucla.edu
http://www.stat.ucla.edu/~rpeng

On Fri, 21 Jun 2002, Ronaldo Reis Jr. wrote:

> Hi,
> I have a new (for me) situation.
> I have a function for one linear model:
> y = 9.7909-0.035*x
> I have the variance of system
> var = 13.01403
> Is possible to create a random vector points of Y (simulating the real data) 
> over this curve using the function and the variance? I need this to a 
> discipline.
> 
> I have this:
> 
> | \
> |  \ -> y = 9.7909-0.035*x and var =  13.014
> |   \
> |    \ 
> |     \
> |      \
> |__________
> 
> I need something like this (generate this points):
> 
> |* \*
> | * \**
> |  **\ *
> |    *\ ** 
> |    * \*
> |     * \ *
> |       *\
> |____________
> 
> Thanks for all
> Ronaldo
> -- 
> "It ain't over until it's over."
> -- Casey Stengel
> --
> |   //|\\   [*****************************][*******************]
> || ( õ õ )  [Ronaldo Reis Júnior          ][PentiumIII-600     ]
> |     V     [ESALQ/USP-Entomologia, CP-09 ][HD: 30 + 10 Gb     ]
> ||  / l \   [13418-900 Piracicaba - SP    ][RAM: 128 Mb        ]
> |  /(lin)\  [Fone: 19-429-4199 r.229      ][Video: SiS620-8Mb  ]
> ||/(linux)\ [chrysopa at insecta.ufv.br      ][Modem: Pctel-onboar]
> |/ (linux) \[ICQ#: 5692561                ][SO: CL 7.0 (2.2.19)]
> ||  ( x )   [*****************************][*******************]
> ||| _/ \_Powered by Conectiva Linux 7.0 D+:) | Lxuser#: 205366
> 
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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