dG: Specify graph terms for 'formula' instances of objects...

Description Usage Arguments Details Author(s) Examples

Description

A symbolic wrapper to indicate a graph term in a formula call to either the s4pm, jtharm, agraph, or a call to the spa from the spa package.

The dG stands for a dissimilarity graph matrix, sG stands for a similarity graph matrix, and aG stands for an ‘anchor’ graph object.

Usage

1
2
3
	dG(x, k = 6L, nok = FALSE, metric = NULL)
	sG(x)
	aG(x)

Arguments

x

a symbolic representation depending on the context of call. For dG or sG this is either a symmetric ‘data.frame’ or ‘matrix’. For aG this must be an ‘anchor’ object. Refer to details below.

k

the k-NN graph parameter for the knnGraph call within the dG function.

metric

the metric used to compute distances.

nok

a parameter to treat the graph input as the final adjacency matrix, i.e., no k-NN graph is computed. This bypasses the k parameter.

Details

The y~. ‘formula’ case automatically accounts for graph terms based on their respective function calls, but there are cases where one must specify the graph terms directly.

In a ‘formula’ call with direct graph input (i.e., not y~.), the graph must be specified based on the original function call and the type of graph desired. There are three cases.

1) For the anchor graph, agraph, the aG function must be invoked and the graph must be of class ‘anchor’. The only way to create this object is to use the AnchorGraph function. Refer to AnchorGraph for an example.

2) The dG function passes or creates a dissimilarity graph (i.e., edges correspond to dissimilarity with ‘0’ as close and ‘Inf’ as far).

3) The sG passes a similarity graph (i.e., edges corresponding to dissimilarity with ‘1’ (typically) as close and ‘0’ as far).

Examples of each case are provided below.

These commands are designed to work in the ‘formula’ instance of the following S4 generics: agraph, s4pm, jtharm, and also the spa from the spa package.

Author(s)

Mark Vere Culp

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
#######
## Equivalent uses of the formula and default s4pm call.
#######

## Set up Sonar data with 20% labeled
library(mlbench)
data(Sonar)

n=dim(Sonar)[1]
p=dim(Sonar)[2]

nu=0.2
set.seed(100)
L=sort(sample(1:n,ceiling(nu*n)))
U=setdiff(1:n,L)

y.true<-Sonar$Class
Sonar$Class[U]=NA
control=SemiSupervised.control(stability=0.0) ## turn off adjustment parameters for comparison

(g.s4pm<-s4pm(Class~.,data=Sonar,control=control)) ### Fit s4pm to Sonar

##The following give equivalent output to the g.s4pm<-s4pm(Class~.,data=Sonar) call.

D11=as.matrix(cosineDist(x.scaleL(Sonar[,-p],L)))
(g.s4pm1<-s4pm(Class~.+dG(D11),data=Sonar,control=control))

#######
## Equivalent uses of the formula, Class ~ ., and default jtharm call.
#######
control=SemiSupervised.control(stability=0.0) 
(g.jtharm1<-jtharm(Class~.,data=Sonar,control=control))
(g.jtharm2<-jtharm(Class~dG(D11),data=Sonar,control=control))

SemiSupervised documentation built on May 11, 2018, 5:03 p.m.