ReduceXspes: A modified version of RegSDC::ReduceX

Description Usage Arguments Value Author(s) Examples

View source: R/Reduce.R

Description

In this modified version of ReduceX, digits=NULL is default and use of Z2Yhat and RoundWhole is removed.

Usage

1
ReduceXspes(x, z = NULL, y = NULL, digits = NULL)

Arguments

x

X as a matrix

z

Z as a matrix

y

Y as a matrix

digits

When non-NULL and when NULL y input, output y estimates close to whole numbers will be rounded using digits as input to RoundWhole.

Value

A list of four elements:

x

Reduced x

z

Corresponding reduced z or NULL when no z in input

yKnown

Logical vector specifying elements of y that can be found directly as elements in z

y

As y in input (not reduced) or estimated y when NULL y in input

Author(s)

Øyvind Langsrud

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Same data as in the paper
z <- RegSDCdata("sec7z")
x <- RegSDCdata("sec7x")
y <- RegSDCdata("sec7y")  # Now z is t(x) %*% y 

a <- ReduceXspes(x, z, y)
b <- ReduceXspes(x, z)
d <- ReduceXspes(x, z = NULL, y)  # No z in output

# Identical output for x and z
identical(a$x, b$x)
identical(a$x, d$x)
identical(a$z, b$z)

# Same y in output as input
identical(a$y, y)
identical(d$y, y)

# Estimate of y (yHat) when NULL y input
# NaN in this modified version of RegSDC::ReduceX
b$y

# These elements of y can be found directly in in z
y[a$yKnown, , drop = FALSE]
# They can be found by searching for unit colSums
colSums(x)[colSums(x) == 1]

# These trivial data rows can be omitted when processing data
x[!a$yKnown, ]
# Now several columns can be omitted since zero colSums
colSums0 <- colSums(x[!a$yKnown, ]) == 0
# The resulting matrix is output from the function
identical(x[!a$yKnown, !colSums0], a$x)

# Output z can be computed from this output x
identical(t(a$x) %*% y[!a$yKnown, , drop = FALSE], a$z)

olangsrud/experimentalRpackage documentation built on Sept. 20, 2021, 10:32 p.m.