fakedata {handyplots} | R Documentation |
Fake Data
Description
A quick way to cook up some fake data.
Usage
fakedata(formula, s = 0.25)
Arguments
formula |
A formula which describes the relationship you wish your fake data to have to an existing numeric vector. For example, if you have a numeric vector |
s |
A numeric value which describes the amount of variablity you want your fake data to have. If |
Details
Quickly cooking up fake data may be useful for experimenting with differnt plotting functions in R with data that you can control. You can control the relationship between your data and an existing vector, and you can control the variablity of the data, i.e. how closely correlated the fake data is to the existing vector. You also know that the residuals are normally distributed with mean 0, which satisfies a major assumption of linear regression.
Value
The function returns a numeric vector.
Author(s)
Jonathan Schwartz
See Also
Examples
x=sample(0:1000,100)
y=fakedata(3*x+10) #y is a vector of fake data which will have a linear relationship with x
plot(x,y)
cor(x,y) #x and y are very highly correlated
y2=fakedata(3*x+10,1) #increasing the value of s decreases the correlation
plot(x,y2)
cor(x,y2) #x and y2 are not as highly correlated
##you can also, of course do non-linear relationships
y3=fakedata(sqrt(1/x))
plot(x,y3)