Last data update: 2014.03.03

R: predict if there is a connection between node i and node j
predict,D2C-methodR Documentation

predict if there is a connection between node i and node j

Description

predict if there is a connection between node i and node j

Usage

## S4 method for signature 'D2C'
predict(object, i, j, data)

Arguments

object

: a D2C object

i

: index of putative cause (1 ≤ i ≤ n)

j

: index of putative effect (1 ≤ j ≤ n)

data

: dataset of observations from the DAG

Value

list with response and prob of the prediction

References

Gianluca Bontempi, Maxime Flauder (2014) From dependency to causality: a machine learning approach. Under submission

Examples

require(RBGL)
require(gRbase)
require(foreach)
data(example)
## load the D2C object
testDAG<-new("simulatedDAG",NDAG=1, N=50,noNodes=5,
           functionType = "linear", seed=1,sdn=c(0.25,0.5))
## creates a simulatedDAG object for testing
plot(testDAG@list.DAGs[[1]])
## plot the topology of the simulatedDAG
predict(example,1,2, testDAG@list.observationsDAGs[[1]])
## predict if the edge 1->2 exists
predict(example,4,3, testDAG@list.observationsDAGs[[1]])
## predict if the edge 4->3 exists
predict(example,4,1, testDAG@list.observationsDAGs[[1]])
## predict if the edge 4->1 exists

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(D2C)
Loading required package: randomForest
randomForest 4.6-12
Type rfNews() to see new features/changes/bug fixes.
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/D2C/predict-D2C-method.Rd_%03d_medium.png", width=480, height=480)
> ### Name: predict,D2C-method
> ### Title: predict if there is a connection between node i and node j
> ### Aliases: predict,D2C-method
> 
> ### ** Examples
> 
> require(RBGL)
Loading required package: RBGL
Loading required package: graph
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following object is masked from 'package:randomForest':

    combine

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

> require(gRbase)
Loading required package: gRbase
> require(foreach)
Loading required package: foreach
> data(example)
> ## load the D2C object
> testDAG<-new("simulatedDAG",NDAG=1, N=50,noNodes=5,
+            functionType = "linear", seed=1,sdn=c(0.25,0.5))
simulatedDAG: DAG number: 1 generated: #nodes= 5 # edges= 3 # samples= 50 
> ## creates a simulatedDAG object for testing
> plot(testDAG@list.DAGs[[1]])
> ## plot the topology of the simulatedDAG
> predict(example,1,2, testDAG@list.observationsDAGs[[1]])
$response
1 
0 
Levels: 0 1

$prob
      0     1
1 0.636 0.364
attr(,"class")
[1] "matrix" "votes" 

> ## predict if the edge 1->2 exists
> predict(example,4,3, testDAG@list.observationsDAGs[[1]])
$response
1 
1 
Levels: 0 1

$prob
      0     1
1 0.456 0.544
attr(,"class")
[1] "matrix" "votes" 

> ## predict if the edge 4->3 exists
> predict(example,4,1, testDAG@list.observationsDAGs[[1]])
$response
1 
1 
Levels: 0 1

$prob
      0     1
1 0.456 0.544
attr(,"class")
[1] "matrix" "votes" 

> ## predict if the edge 4->1 exists
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>