errorsINx {DAAG}R Documentation

Simulate data for straight line regression, with "errors in x".

Description

Simulates $y-$ and $x-$values for the straight line regression model, but with $x-$values subject to random measurement error, following the classical “errors in x” model. Optionally, the x-values can be split into two groups, with one group shifted relative to the other

Usage

errorsINx(mu = 12.5, n = 200, a = 15, b = 1.5, SDx=2, SDyerr = 1.5,
           timesSDx=(1:5)/2.5, gpfactor=if(missing(gpdiff))FALSE else TRUE,
           gpdiff=if(gpfactor) 1.5 else 0, layout=NULL,
           parset = simpleTheme(alpha = 0.75, col = c("black","gray45"),
             col.line = c("black","gray45"), lwd=c(1,1.5), pch=c(1,2),
           lty=c(1,2)), print.summary=TRUE, plotit=TRUE, xrelation="same")

Arguments

mu

Mean of $z$

n

Number of points

a

Intercept in model where $z$ is measured without error

b

Slope in model where $z$ is measured without error

SDx

SD of $z$-values, measured without error

SDyerr

SD of error term in y where $z$ is measured without error

timesSDx

SD of measurement error is timesSDx, as a multiple of SDx

gpfactor

Should x-values be split into two groups, with one shifted relative to the other?

gpdiff

Amount of shift of one group of z-values relative to the other

layout

Layout for lattice graph, if requested

parset

Parameters to be supplied to the lattice plot, if any

print.summary

Print summary information on fits?

plotit

logical: plot the data?

xrelation

character: sets the x-axis relation component of scales to "same" or "free" or (though this does not make make sense here) "sliced".

Details

The argument timesSDx can be a numeric vector. One set of $x$-values that are contaminated with measurement error is simulated for each element of timesSDx.

Value

gph

the trellis graphics object

mat

A matrix, with length(timesSDx)+2 columns. Values of $z$ are in the first column. There is one further column (x with error) for each element of timesSDx, followed by a column for $y$. If there is a grouping variable, a further column identifies the groups.

Author(s)

John Maindonald

References

Data Analysis and Graphics Using R, 3rd edn, Section 6.7

Examples

library(lattice)
errorsINx()
errorsINx(gpdiff=2, timesSDx=1.25, SDyerr=2.5, n=80)

[Package DAAG version 1.25.6 Index]