powered by
The function simulates a pair of correlated variables.
simCorVars(n, r, plot = TRUE)
data.frame with entries Var1 and Var2
Var1
Var2
integer: sample size.
numeric: correlation.
logical: generate scatter plot of the variables.
Matthias Kohl Matthias.Kohl@stamats.de
The function is mainly for teaching purposes and simulates n observations from a pair of normal distributed variables with correlation r.
n
r
By specifying plot = TRUE a scatter plot of the data is generated.
plot = TRUE
res <- simCorVars(n = 100, r = 0.8) cor(res$Var1, res$Var2)
Run the code above in your browser using DataLab