| lmr_data | R Documentation |
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(.)))).
lmr_data(xr, yr, n, r = 0, digits = NULL, ...)
xr |
numeric: range of x values |
yr |
numeric: range of y values |
n |
numeric: number of observations to generate |
r |
numeric: desired correlation, uses |
digits |
numeric(2): digits for rounding, for x |
... |
further parameters used in |
An object of class lm with the additional components
x the generated x values
y the generated y values
sumx \sum_{i=1}^n x_i
sumy \sum_{i=1}^n y_i
sumx2 \sum_{i=1}^n x_i^2
sumy2 \sum_{i=1}^n y_i^2
sumxy \sum_{i=1}^n x_i y_i
meanx the mean of x: 1/n \sum_{i=1}^n x_i
meany the mean of y: 1/n \sum_{i=1}^n y_i
varx the variation of x: \sum_{i=1}^n (x_i-\bar{x})^2
vary the variation of y: \sum_{i=1}^n (y_i-\bar{y})^2
varxy the common variation of x and y:\sum_{i=1}^n (x_i-\bar{x})(y_i-\bar{y})
sxy the covariance of x and y
rxy the correlation of x and y
b0 the intercept of the linear regression
b1 the slope of the linear regression
r2 the coefficient of determination of the linear regression
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.