rpearson: Generate two variables linear correlated

View source: R/rpearson.r

rpearsonR Documentation

Generate two variables linear correlated

Description

Simulates two numeric variables linear correlated, given a Pearson linear correlation coefficient, that also follows a normal distribution.

Usage

rpearson(n = 25, pearson = 0.5, tol = 0.1, mean = 0, sd = 1)

Arguments

n

A numeric integer single value (default = 25), that will be the number of observations to simulate

pearson

A numeric single value (default = 0.50), that will be the expected Pearson linear correlation coefficient

tol

A numeric single value (default = 0.10), that will be the tolerance between the simulated and estimated correlation

mean

A numeric single value (default = 0), that will be the mean of the simulated data

sd

A numeric single value (default = 1), that will be the standard deviation of the simulated data

Value

A tibble (nx2) with two numeric variables (x and y).

Examples


df <- rpearson(n = 100, pearson = .8, mean = 3)

head(df)

plot(df)


vbfelix/relper documentation built on Jan. 28, 2025, 12:15 p.m.