lm1_data: lm1_data

View source: R/lm1_data.R

lm1_dataR Documentation

lm1_data

Description

Creates data suitable for a simple linear regression. In a first step with pearson_data() are data computed for which holds \sum_{i=1}^{nmax} x_i^2 = n and \sum_{i=1}^{nmax} x_i = 0 (the same for y). The data are rescaled with x' = center[1]+scale[1]*x and y' = center[2]+scale[2]*y anbd for the tranformed data is simple linear regression performed.

Usage

lm1_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 pearson_data().

nmax

integer: maximal number of squares in the sum, see pearson_data().

maxt

numeric: maximal number of seconds the routine should run, see pearson_data().

xsos

sos matrix: precomputed matrix, see pearson_data().

ysos

sos matrix: precomputed matrix, see pearson_data().

center

numeric(2): center of x and y data

scale

numeric(2): standard deviation of x and y data

...

further named parameters given to stats::lm()

Value

returns an extended lm object. The additional list elements

  • inter contains intermediate results (the last column contains the row sums), and

  • xy the generated x- and y-values.

Examples

data(sos)
n   <- sample(5:10, 1)
lm1 <- lm1_data(0.6, nmax=n, xsos=sos100)
str(lm1)

sigbertklinke/exams2moodle documentation built on July 6, 2023, 3:26 p.m.