lm1_data {exams.forge} | R Documentation |
Simple Linear Regression and Data Generation
Description
Creates data suitable for a simple linear regression. In the first step, data is computed using pearson_data()
,
satisfying the conditions \sum_{i=1}^{nmax} x_i^2 = n
and \sum_{i=1}^{nmax} x_i = 0
(similar conditions apply to y
.
The data are then rescaled with x' = center[1]+scale[1]*x
and
y' = center[2]+scale[2]*y
.
Finally, a simple linear regression is performed on the transformed data.
Usage
lm1_data(
r,
n = 100,
nmax = 6,
maxt = 30,
xsos = NULL,
ysos = NULL,
center = numeric(0),
scale = numeric(0),
...
)
slr_data(
r,
n = 100,
nmax = 6,
maxt = 30,
xsos = NULL,
ysos = NULL,
center = numeric(0),
scale = numeric(0),
...
)
Arguments
r |
numeric: desired correlation |
n |
integer: number to decompose as sum of squares, see |
nmax |
integer: maximal number of squares in the sum, see |
maxt |
numeric: maximal number of seconds the routine should run, see |
xsos |
sos matrix: precomputed matrix, see |
ysos |
sos matrix: precomputed matrix, see |
center |
numeric(2): center of |
scale |
numeric(2): standard deviation for |
... |
further named parameters given to |
Value
Returns an extended lm
object and the additional list elements:
-
inter
contains intermediate results (the last column contains the row sums), and -
xy
the generatedx
- andy
-values.
Examples
data(sos)
n <- sample(5:10, 1)
lm1 <- lm1_data(0.6, nmax=n, xsos=sos100)
str(lm1)