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
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")
Mean of $z$
Number of points
Intercept in model where $z$ is measured without error
Slope in model where $z$ is measured without error
SD of $z$-values, measured without error
SD of error term in y
where $z$ is measured without error
SD of measurement error is timesSDx
, as a
multiple of SDx
Should x-values be split into two groups, with one shifted relative to the other?
Amount of shift of one group of z-values relative to the other
Layout for lattice graph, if requested
Parameters to be supplied to the lattice plot, if any
Print summary information on fits?
logical: plot the data?
character: sets the x-axis relation
component of
scales
to "same"
or "free"
or (though this does
not make make sense here) "sliced"
.
the trellis graphics object
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.
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
.
Data Analysis and Graphics Using R, 3rd edn, Section 6.7
# NOT RUN {
library(lattice)
errorsINx()
errorsINx(gpdiff=2, timesSDx=1.25, SDyerr=2.5, n=80)
# }
Run the code above in your browser using DataLab