21_continuous_kernel_smoothing: Continuous Kernel Smoothing Models

Description Usage Arguments Details Value References See Also Examples

Description

Fit probability distributions, via continuous kernel smoothing, from data.

NOTE THAT THESE OBJECTS ARE LIKELY TO BE CONVERTED TO S4 OBJECTS, IN THE NEAR FUTURE.
ALSO, NOTE THAT THEIR INTERNAL STRUCTURE (THAT IS, THEIR ATTRIBUTES/SLOTS), IS SUBJECT TO CHANGE.

IN PRINCIPLE, YOU SHOULD NOT ACCESS ATTRIBUTES/SLOTS, DIRECTLY.

Usage

 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#univariate
pdfuv.cks (x, ..., w,
    bw, smoothness=1,
    kernel=BIWEIGHT.CKERNEL,
    spline=TRUE, bw.method="ph.default", nc=30,
    trtype="local",
    Xlim = cbind (a, b), a=-Inf, b=Inf)

cdfuv.cks (x, ..., w,
    bw, smoothness=1,
    kernel=BIWEIGHT.CKERNEL,
    spline=TRUE, bw.method="ph.default", nc=30, tail="lower",
    trtype="local",
    Xlim = cbind (a, b), a=-Inf, b=Inf)

qfuv.cks (x, ..., w,
    bw, smoothness=1,
    kernel=BIWEIGHT.CKERNEL,
    bw.method="ph.default", nc=30,
    trtype="local",
    Xlim = cbind (a, b), a=-Inf, b=Inf)

#multivariate
pdfmv.cks (x, ..., w,
    bw, smoothness=1,
    kernel=BIWEIGHT.CKERNEL,
    bw.method="ph.default",
    Xlim = cbind (a, b), a=-Inf, b=Inf)

cdfmv.cks (x, ..., w,
    bw, smoothness=1,
    kernel=BIWEIGHT.CKERNEL,
    bw.method="ph.default", tail="lower",
    Xlim = cbind (a, b), a=-Inf, b=Inf)

#conditional
pdfc.cks (x, ..., conditions, w,
    bw, smoothness=1,
    kernel=BIWEIGHT.CKERNEL,
    spline=TRUE, bw.method="ph.default", nc=30,
    Xlim = cbind (a, b), a=-Inf, b=Inf,
    preserve.range=FALSE, as.cset=FALSE, as.list.cset=FALSE,
    warning=TRUE)

cdfc.cks (x, ..., conditions, w,
    bw, smoothness=1,
    kernel=BIWEIGHT.CKERNEL,
    spline=TRUE, bw.method="ph.default", nc=30, tail="lower",
    Xlim = cbind (a, b), a=-Inf, b=Inf,
    preserve.range=FALSE, as.cset=FALSE, as.list.cset=FALSE,
    warning=TRUE)

qfc.cks (x, ..., conditions, w,
    bw, smoothness=1,
    kernel=BIWEIGHT.CKERNEL,
    bw.method="ph.default", nc=30,
    Xlim = cbind (a, b), a=-Inf, b=Inf,
    preserve.range=FALSE, as.cset=FALSE, as.list.cset=FALSE,
    warning=TRUE)

pdfmvc.cks (x, ..., conditions, w,
    bw, smoothness=1,
    kernel=BIWEIGHT.CKERNEL,
    bw.method="ph.default",
    Xlim = cbind (a, b), a=-Inf, b=Inf,
    preserve.range=FALSE, as.cset=FALSE, as.list.cset=FALSE,
    warning=TRUE)

#multivariate-conditional
cdfmvc.cks (x, ..., conditions, w,
    bw, smoothness=1,
    kernel=BIWEIGHT.CKERNEL,
    bw.method="ph.default", tail="lower",
    Xlim = cbind (a, b), a=-Inf, b=Inf,
    preserve.range=FALSE, as.cset=FALSE, as.list.cset=FALSE,
    warning=TRUE)

#other
chqf.cks (x, ..., w,
    bw, smoothness=1,
    kernel=BIWEIGHT.CKERNEL,
    bw.method="ph.default", nc=16)

Arguments

x

IN UNIVARIATE CONSTRUCTORS:
Numeric vector of data.
Also, can be a single-column numeric matrix, preferably with a column name.

IN OTHER CONSTRUCTORS:
Numeric matrix, preferably, with column names.

conditions

SIMPLE USE:
(SINGLE SET OF CONDITIONS)
A numeric vector of conditioning values.

If named, then the names are matched against the variable names.
If unnamed, then the first condition applies to the first variable, and the second condition applies to the second variable, and so on. MULTIPLE SETS OF CONDITIONS: A numeric matrix of conditioning values. Names are matched, same as in the simple use, except using column names.
Each row defines one set of conditions.

Note that in univariate-conditional distributions, the number of conditioning variables needs to equal the total number of variables minus one.
By default (depending on the as.cset argument), a cks object is returned if there's one set of conditions, and a cset object is returned, if there's two or more sets conditions).

w

Optional numeric vector of weights.

bw

Postive numeric vector of length [1 or m], the bandwidth parameter(s).
If bw is missing, the bandwidth is computed for each variable using the bandwidth method (see bw.method below), which is subject to the smoothness parameter(s).

smoothness

Positive numeric vector of length [1 or m], the relative smoothness parameter(s).
Ignored, if bw provided

kernel

A (continuous) kernel object.

spline

Logical, if true, use cubic Hermite splines as intermediate models.
In general, this should be true.

bw.method

String, the bandwidth selection method.
Refer to Bandwidth Selection.

nc

Integer, number of control points, in the spline.
Ignored, if spline is false.

tail

Character vector of length [1 or M], either "lower" or "upper".
If lower (the default), lower tail probabilities, P (..., Xj <= xj, ...), are used.
If upper, upper tail probabilities, P (..., X >= xj, ...), are used.

trtype

String, either "simple", "local" or "reflect", refer to vignette.
Note that the local method is used, where there's no trtype argument.

Xlim

An ([1 or m] by 2) numeric matrix, giving the limits of each X variable.
The corresponding random variable is regarded as bounded, if either limit is finite.
In which case, a truncated smoothing algorithm is applied.

a, b

Numeric vectors of length [1 or m].
This is an alternative way of specifying Xlim, above.

preserve.range

Logical vector of length [1 or M].
If true, the default range used for range/sequence methods and plotting functions, will be the same as the original data.
If false (the default), the range is based on the data within a conditioning window, which is often smaller.

as.cset

Logical, if true, a cset object is returned regardless of the number of conditions.
Note that this is ignored, if there is not one set of conditions.

Also note that as.list.cset needs to be true, if as.cset is true, or the number of sets of conditions is not one.
(This requirement is temporary).

as.list.cset

Logical, refer to as.cset, above.

warning

Logical, if true, generate warning if there's no observations within the conditional window.

...

Additional arguments not allowed

Details

PLEASE SET NOTES IN DESCRIPTION FIELD.

Here, M refers to the number of random variables (in the model), and m refers to the total number of variables.
In nonconditional models, these are the same.
In univariate-conditional models, M is one and m is equals to the number of conditions plus one.

Variable names use default values, if the x matrix is unnamed.
(In conditional models, a warning is generated).

In conditional models, variables are reordered (internally), if there's named conditions.
Note you can check names (and their order), with names method.
(By default, only the conditional variables are returned).

Parameters that need to match m (the total number of variables), such as bw, smoothness and Xlim, will match the original data, regardless of the order of the conditions.
i.e. The first bw value will match the first column in x, regardless of the order of the conditions.

However, parameters that need to match M (the number of random variables), such as tail, need to match the order of the resulting conditional variables.
The same principle, applies to the x argument in the resulting function objects.

Refer to the vignette for more information.

Value

Self-referencing function objects.

Refer to Runtime Function Objects

Except:
The constructors for conditional distributions, return NULL, if there's no observations within the conditional window.
(And by default, generate a warning).

They may also return cset objects, if as.cset is true, or there's more than one set of conditions.

References

Refer to the vignette for an overview, references and better examples.

See Also

Kernels

Succinct Constructors
Discrete Kernel Smoothing, Categorical Distributions, Empirical-Like Distributions

Conditional Distributions with Mixed Input Types
These can be used for statistical classification purposes.

is.cks, ph.printf.phmodel, ph.plotf.cksuv, ph.plotf.cksmv

Bandwidth Selection

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
prep.ph.data ()

###########
#univariate
###########
uvfh <- pdfuv.cks (height)
uvFh <- cdfuv.cks (height)
uvFht <- qfuv.cks (height)

plot (uvfh)
plot (uvFh)
plot (uvfh, TRUE)

uvFht (c (0.25, 0.5, 0.75) )
ph.mode (uvfh)
ph.mode (uvfh, TRUE)

#############
#multivariate
#############
mvfh <- pdfmv.cks (trees2 [,-2])
mvFh <- cdfmv.cks (trees2 [,-2])

plot (mvfh, TRUE)
plot (mvfh,, TRUE)
plot (mvFh, TRUE)
plot (mvFh, fb = c (0.2, 0.8), clabs = c ("A", "B") )

##############
#conditional
#(single model)
###############
cons.c1 <- c (height=25, girth=35)
cfh <- pdfc.cks (trees2, conditions=cons.c1)
cFh <- cdfc.cks (trees2, conditions=cons.c1)
cFht <- qfc.cks (trees2, conditions=cons.c1)

plot (cfh)
plot (cFh)
plot (cfh, TRUE)

cFht (c (0.25, 0.5, 0.75) )
ph.mode (cfh)
ph.mode (cfh, TRUE)

#############
#conditional
#(two models)
#############
cons.c2 <- cbind (height=25:26, girth=35:36)

cfhs <- pdfc.cks (trees2, conditions=cons.c2, as.list.cset=TRUE)

plot (cfhs [[1]])

#########################
#multivariate-conditional
#########################
cons.mvc <- c (depth=311)

mvcFh <- cdfmvc.cks (quakes2, conditions=cons.mvc)

probhat documentation built on May 12, 2021, 5:08 p.m.