lmr_data {exams.forge}R Documentation

lm Simple Linear Regression

Description

Computes an lm object for a simple linear regression from a range of x and y values, including intermediate values. If r is not given then zero correlation is used (with cor_data). digits determines the rounding for the x and y values. If only one value is given, then it will be used for x and y. If no value is given then it will be determined from the x and y values by 3+ceiling(-log10(diff(range(.)))).

Usage

lmr_data(xr, yr, n, r = 0, digits = NULL, ...)

lm_regression_data(xr, yr, n, r = 0, digits = NULL, ...)

Arguments

xr

numeric: range of x values

yr

numeric: range of y values

n

numeric: number of observations to generate

r

numeric: desired correlation, uses cor_data

digits

numeric(2): digits for rounding, for x digits[1] is used, for y digits[2] is used (default: NULL)

...

further parameters used in cor_data

Value

An object of the class lm with the additional components:

Examples

# Engine displacement typically ranges from 500 to 2000 cm^3
# Fuel economy typically ranges from 2 to 8 liter/100 km
lmr <- lmr_data(c(500, 2000), c(2, 8), n=8)
str(lmr)

[Package exams.forge version 1.0.10 Index]