Hi deb,
I am not clear what you want exactly, but something like:
x <- runif(1000)
y <- x^2 + rnorm(1000, mean = 0, sd = 1)
might do what you want.
See
?runif
for documentation. It generates random numbers from the uniform
distribution, and ditto for rnorm except from normal.
Cheers,
Josh
On Sun, Mar 4, 2012 at 4:41 PM, mail me <mailme842 at googlemail.com>
wrote:> Hi:
> I am trying to generate data form a simple linear regression model.
> The training data
> ?T = {(x1, y1), . . . , (xn), yn}, want to sample x uniformly from the
> range [0,1], ?find uncorrupted response y = x^2, and generate random
> noise "e" from normal distribution N(0, 1). Any idea how to do in
> simple steps?
>
> Thanks in advance.
> deb
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/