create.prepared_list: Manually create a 'prepared_list'

View source: R/create.prepared_list.R

create.prepared_listR Documentation

Manually create a prepared_list

Description

create.prepared_list creates a prepared_list manually. Typically, one would simply use the prepare.list, but there are situations where the data argument would be too large to read into memory.
This function assumes that the user has used the assemble function to construct a list of the relevant assembled_splines and manually computed Ytilde for a number of relevant data observations and stored them in a list. The user should also manually compute the sum of the squared data for each data observation. The user must also specify the dimensions of each data set (which are assumed to be the same) as a vector and provide the relevant set of values at which each data object is observed. See Examples.

Usage

create.prepared_list(assembled, x, Ytilde, sum_ysq, n)

Arguments

assembled

A list of assembled_splines. See Examples.

x

The list of arguments at which to evaluate each of the splines used to construct assembled.

Ytilde

A list of prepared_* objects.

sum_ysq

A vector with the sum of squared data objects used to construct Ytilde.

n

The dimensions of the data objects used to construct Ytilde.

Value

A prepared list.

Examples

# generate and prepare 3d data
set.seed(9)
dat = generate.data3d()

# list giving the locations to evaluate the basis functions
x = dat$x
# construct a set of basic B-splines for each dimension
splines = default.splines(x)

# construct assembled splines from splines list
a = assemble(splines, x)

# imagine there are 4 data obsevations we want to smooth
# but that they can't be loaded into memory
Ytilde = vector("list", 4)
sum_ysq = numeric(4)

# prepare each data set manually
# notice the use of the assembled arguments so that
# the splines are not "assembled" again for each data set
for(i in seq_along(Ytilde)) {
    data = generate.data3d()$data3d
    Ytilde[[i]] = prepare(data, x = x, splines = splines,
                          assembled = a)
    sum_ysq[i] = sum(data^2)
}
n = dim(data)
p = create.prepared_list(assembled = a, x = x,
                         Ytilde = Ytilde, sum_ysq = sum_ysq,
                         n = n)

hero documentation built on July 26, 2023, 5:11 p.m.