Public Repository

Last pushed: 2 months ago
Short Description
Short description is empty for this repo.
Full Description

To run RStudio Server:

$ docker run -p 8787:8787 chirayukong/r-causal-rstudio

You can then open a web browser pointing to your docker host on port 8787. If you’re on Linux and using default settings, the docker host is 127.0.0.1 (or localhost, so the full URL to RStudio would be http://localhost:8787). If you are on Mac or Windows and running Docker Toolbox, you can determine the docker host with the command:

$ docker-machine ip default

Log in to RStudio with the username rstudio and password rstudio.

Example

Continuous Dataset

library(rcausal)
data("charity") #Load the charity dataset
fgs <- fgs(df = charity, penaltydiscount = 2, maxDegree = 3, faithfulnessAssumed = TRUE,
verbose = TRUE) #Compute FGS search
fgs$parameters #Show the FGS's parameters
fgs$datasets #Show the dataset
fgs$nodes #Show the result's nodes
fgs$edges #Show the result's edges
library(Rgraphviz)
plot(fgs$graphNEL) #Plot the causal model

Discrete Dataset

data("audiology") #Load the charity dataset
fgs.discrete <- fgs.discrete(df=audiology,structurePrior=1.0,samplePrior=1.0, maxDegree = 3, faithfulnessAssumed = TRUE, numOfThreads = 2,verbose = TRUE) #Compute FGS Discrete search
fgs.discrete$parameters #Show the FGS Discrete's parameters
fgs.discrete$datasets #Show the dataset
fgs.discrete$nodes #Show the result's nodes
fgs.discrete$edges #Show the result's edges
library(Rgraphviz)
plot(fgs.discrete$graphNEL) #Plot the causal model

Prior Knowledge

Create PriorKnowledge Object

forbid <- list(c('TangibilityCondition','Impact')) # List of forbidden directed edges
require <- list(c('Sympathy','TangibilityCondition')) # List of required directed edges
forbiddenWithin <- c('TangibilityCondition','Imaginability')
class(forbiddenWithin) <- 'forbiddenWithin' # Make this tier forbidden within
temporal <- list(forbiddenWithin, c('Sympathy','AmountDonated'),c('Impact')) # List of temporal node tiers
prior <- priorKnowledge(forbiddirect = forbid, requiredirect = require, addtemporal = temporal)
fgs <- fgs(df = charity, penaltydiscount = 2, depth = -1, ignoreLinearDependence = TRUE,
heuristicSpeedup = TRUE, numOfThreads = 2, verbose = TRUE, priorKnowledge = prior)

Load Knowledge File

knowledge file: audiology.prior

/knowledge

forbiddirect

class tymp

class age_gt_60

class notch_at_4k

requiredirect

history_noise class

addtemporal

0 bser late_wave_poor tymp notch_at_4k o_ar_c ar_c airBoneGap air bone o_ar_u airBoneGap

1 history_noise history_dizziness history_buzzing history_roaring history_recruitment history_fluctuating history_heredity history_nausea

2 class

prior <- priorKnowledgeFromFile('audiology.prior')
fgs.discrete <- fgs.discrete(df=audiology,structurePrior=1.0,samplePrior=1.0,
maxDegree = 3, faithfulnessAssumed = TRUE, numOfThreads = 2,verbose = TRUE, priorKnowledge = prior)

Docker Pull Command
Owner
chirayukong