Insight network: Difference between revisions

From Opasnet
Jump to navigation Jump to search
(→‎Process: link to code)
(→‎Calculations: chooseGr function added to server code)
Line 857: Line 857:
}
}


makeUi <- 0
objects.store(ui)
 
cat("Function ui stored (makeUi is depreciated and not stored). Usage: shinyApp(ui, server, enableBookmarking = 'url')\n")
objects.store(ui, makeUi)
cat("Function ui stored (makeUi is dummy). Usage: shinyApp(ui, server, enableBookmarking = 'url')\n")
</rcode>
</rcode>


Line 866: Line 864:
# This is code Op_en3861/server on page [[Insight diagram]].
# This is code Op_en3861/server on page [[Insight diagram]].
library(OpasnetUtils)
library(OpasnetUtils)
#' Function chooseGr takes a diagrammer graph and selects s subgraph based on topic, labels, steps from selected nodes etc.
#' @param gr diagrammer graph
#' @param input list of arguments to be used in selection
#' @seeds ovariable where @data has columns Topic to be chosen and Node for Oldid's to select.
#' @return diagrammer graph where node_selection contains the selected nodes
chooseGr <- function(gr, input, seeds) {
  nods <- union(c(
    match(seeds@data$Node[seeds@data$Topic==input$topic], gr$nodes_df$Oldid),
    match(input$addnodes, gr$nodes_df$label)),
    match(input$addnodesByOldid, gr$nodes_df$Oldid)
  )
  nods <- nods[!is.na(nods)]
  gr <- deselect_nodes(gr, get_selection(gr))
  gr <- select_nodes_by_id(gr, nods)
  if(input$steps>0) {
    for(i in 1:input$steps) {
      gr <- deselect_nodes(gr,match(input$removenodes, gr$nodes_df$label))
      gr <- trav_both(gr,add_to_selection = TRUE)
    }
    if("Remove branches only" %in% input$formatting) {
      gr <- select_nodes_by_id(gr,match(input$removenodes, gr$nodes_df$label))
    } else {
      gr <- deselect_nodes(gr,match(input$removenodes, gr$nodes_df$label))
    }
  }
  if("Show legend nodes" %in% input$formatting) {
    gr <- select_nodes_by_id(gr, match(seeds@data$Node[seeds@data$Topic=="Selitykset"], gr$nodes_df$Oldid))
  }
  gr <- deselect_nodes(gr, match(input$ignoreobj, gr$nodes_df$type))
  return(gr)
}


#### Create shiny server at file server.R
#### Create shiny server at file server.R


server <- function(input, output, session) {
server <- function(input, output, session) {
# grr <- reactive({
   output$plot1 <- renderGrViz({
   output$plot1 <- renderGrViz({
     nods <- union(c(
     gr2 <- chooseGr(gr = gr, input = input, seeds = seeds)
      match(seeds@data$Node[seeds@data$Topic==input$topic], gr$nodes_df$Oldid),
      match(input$addnodes, gr$nodes_df$label)),
      match(input$addnodesByOldid, gr$nodes_df$Oldid)
    )
    nods <- nods[!is.na(nods)]
    gr <- deselect_nodes(gr, get_selection(gr))
    gr <- select_nodes_by_id(gr, nods)
    if(input$steps>0) {
      for(i in 1:input$steps) {
        gr <- deselect_nodes(gr,match(input$removenodes, gr$nodes_df$label))
        gr <- trav_both(gr,add_to_selection = TRUE)
      }
      if("Remove branches only" %in% input$formatting) {
        gr <- select_nodes_by_id(gr,match(input$removenodes, gr$nodes_df$label))
      } else {
        gr <- deselect_nodes(gr,match(input$removenodes, gr$nodes_df$label))
      }
    }
    if("Show legend nodes" %in% input$formatting) {
      gr <- select_nodes_by_id(gr, match(seeds@data$Node[seeds@data$Topic=="Selitykset"], gr$nodes_df$Oldid))
    }
    gr <- deselect_nodes(gr, match(input$ignoreobj, gr$nodes_df$type))
#    gr <- deselect_nodes(gr, union( # This should find the INTERCEPT of from is selected AND to is selected and rel  %in% ignorerel.
#    gr <- deselect_nodes(gr, union( # This should find the INTERCEPT of from is selected AND to is selected and rel  %in% ignorerel.
# However, it is more complicated than that, because we may not want both from and to to disappear, only the one who is further away from core.
# However, it is more complicated than that, because we may not want both from and to to disappear, only the one who is further away from core.
Line 901: Line 909:
#      tmp$edges_df$to[tmp$edges_df$rel %in% input$ignorerel]
#      tmp$edges_df$to[tmp$edges_df$rel %in% input$ignorerel]
#    ))
#    ))
    gr
#  })


# output$plot1 <- renderGrViz({
#  gr2 <- grr()
    gr2 <- gr
     gr2$nodes_df$label <- gsub("(.{1,18})(\\s|$)", "\\1\n", gr2$nodes_df$label) # Cut labels to max 18 characters long on one line (except if a word is longer)
     gr2$nodes_df$label <- gsub("(.{1,18})(\\s|$)", "\\1\n", gr2$nodes_df$label) # Cut labels to max 18 characters long on one line (except if a word is longer)
     # Alternative possibility is to use strwrap function from {base} or stri_wrap from stringi.
     # Alternative possibility is to use strwrap function from {base} or stri_wrap from stringi.
     if("Hide node labels" %in% input$formatting) gr2$nodes_df$label <- ""
     if("Hide node labels" %in% input$formatting) gr2$nodes_df$label <- ""
     if("Hide edge labels" %in% input$formatting) gr2$edges_df$label <- " "
     if("Hide edge labels" %in% input$formatting) gr2$edges_df$label <- " "
   
 
     grViz(generate_dot(transform_to_subgraph_ws(gr2)))
     grViz(generate_dot(transform_to_subgraph_ws(gr2)))
   })
   })
Line 926: Line 929:
}
}


objects.store(server)
objects.store(chooseGr, server)
cat("Function server stored.\n")
cat("Functions chooseGr, server stored. Usage: shinyApp(ui, server, enableBookmarking = 'url')\n")
</rcode>
</rcode>



Revision as of 08:08, 21 December 2018


Insight networks are graphical representations of a particular situation, where the objects described are causally related to each other. In addition, the diagrams contain non-causal elements such as value judgements or inferences based on data. Insight networks utilise the ideas of directed acyclic graphs, but they have additional features.

Question

What notation is simple and flexible enough so that it can be used to represent all major issues related to a policy situation? It must be usable in both graphical and data formats.

Answer

+ Show code

Rationale

Process

The parameters of an argument and possible combinations.
Id Title Content Sign Target Type Paradigm Relation Result Comment
arg1234 Short title for display Actual argument Signature arg9876 relevance science attack 1 If paradigm changes (all else equal), relation may change, although typically only the result changes.
arg1234 Short title for display Actual argument Signature arg5555 relevance science comment 0
arg1234 Short title for display Actual argument Signature arg6666 truth science defense 1 Truth refers to the truth of the target
arg1234 Short title for display Actual argument Signature arg1234 selftruth science attack 0 Selftruth refers to the truth of the argument itself, unlike other types that refer to the target.
arg1234 Short title for display Actual argument Signature arg9876 relevance toldya comment 0
arg1234 Short title for display Actual argument Signature arg5555 relevance toldya defense 1
arg1234 Short title for display Actual argument Signature arg6666 truth toldya attack 0
arg1234 Short title for display Actual argument Signature arg1234 selftruth toldya comment 1 The relation in case of type=selftruth is irrelevant and is ignored.
These are unique to an argument
These are unique to an argument-target pair
These are unique to a triple of argument-target-paradigm
Insight networks have been described in a scientific article manuscript From open assessment to shared understanding: practical experiences#Insight networks. Objects and their relations used in open policy practice are described on page Open policy ontology.

There is a need for methods facilitating the flow of information and understanding between science and policy. The principle is to describe a risk situation in a formal manner. Insight networks contain items along a causal pathway (or network) from e.g. abatement strategies to emissions to dispersion to exposure to effects. They have been designed to describe also non-causal connections such as non-causal reasoning, values, preferences, and arguments.

These diagrams use graph theory with vertices (or nodes) and arcs (or arrows). They are used to describe and define all the pieces needed for a description of the situation under scrutiny. Diagrams may be produced with any graphics software, providing that calculation functions are not required. If calculations are needed, we recommend the use of R software and OpasnetUtils package.

Parameter properties
Parameter Css selector (Opasnet page scraping) Requirements
Id .argument attr=id Must start with a letter
Title .argument .title Short text. Is shown on insight graph as node label
Content .argument .content Text, may be long. Is shown with hover on graph
Sign .argument .sign a:first-of-type Must contain a link to participant's user page. Is shown with hover on graph
Target NA Previous argument one level up, or the statement for arguments on the first level
Type .argument i.type One of the three: relevance, truth, or selftruth (or "both", which is depreciated)
Paradigm .argument .paradigm Each paradigm should be described on a dedicated page. The rules implemented must be clear
Relation .argument .relation Is one of these: attack, defense, comment. "Branches" are typically uninteresting and ignored.
Result
  • relevance= .argument .relation attr=color. Gray= 0 (irrelevant), other=1 (relevant).
  • truth= .argument .relation attr=color. Gray=0 (untrue), other=1 (true)
  • selftruth= .argument .selftruth attr=color. Gray=0 (untrue), other=1 (true)
Truthlikeness of the relation. Either 1 or 0

This is the process how data flows into insight diagrams:

  • List of data tables of different insight diagrams is found from https://yhteistyotilat.fi/wiki08/x/1oGxAg. It has the following columns:
    • Ilmio: Name of the phenomenon. This will become the name of a csv data file.
    • Id: Identifier of the phenomenon. This will be used in Oldid of the items and relations.
    • Tyyppi: Type of the table. In practice, it defines the columns that the data table has. Different types are listed on #Types of insight network tables.
    • URL: Location of the data table. If the URL contains "google.com", it is assumed to be a google sheet. If the type (Tyyppi) is "keskustelu", it is assumed to be an Opasnet page with discussions. Otherwise, it is assumed to be a table on a web page that can be scraped with read_html() function.
    • Taulu: If the data is a table on a web page, it is the number of the table on that page. If the data is a discussion, it is the number of discussion; missing value means that all discussions on that page are read.
    • Alkurivi: In case of google sheets, it is the first row with actual data.
    • Kuvaus: Description of the table, with possible links to relevant description page.

All data tables and discussions are listed, formatted and saved as csv files in a zip file called op_fi:File:Näkemysverkkojen tietotauluja.zip. From there, the data can be accessed from within Opasnet Rtools. (The code scraping web pages does not work in Opasnet, although it is stored there.) Little formatting is done here, mainly the column titles are standardised. But the number and type of columns is not changed.

In the next phase, each csv file is opened, interpreted, and defined as items and relations. This is done in code Op_fi5810/graphs on page op_fi:Ympäristöterveysindikaattori. All these are saved as a DiagrammeR graph, and each topic may be separately selected as a subgraph.

Data

Graphical properties of objects and relations

Graphical properties of objects and relations(-)
ObsPropertyValueParameterResultDescription
1defaultdefaultnode.shapecircleDefault values unless something else is specified
2defaultdefaultnode.sides4
3defaultdefaultnode.skew0
4defaultdefaultnode.fillcolorwhite
5defaultdefaultnode.fontsize11
6defaultdefaultnode.height0.5
7defaultdefaultnode.width0.5
8defaultdefaultnode.colorbrown
9defaultdefaultnode.penwidth2
10defaultdefaultnode.fontcolorblack
11defaultdefaultnode.distortion0
12defaultdefaultedge.colorgrey
13defaultdefaultedge.fontsize10Not currently used
14defaultdefaultedge.fontcolorgrey
15defaultdefaultedge.styledotted
16defaultdefaultedge.penwidth2
17defaultdefaultedge.arrowsize1Not currently used
18typeunknownnode.fillcoloryellowThis formatting is used if there are undefined objects
19typeunknownnode.colorgreen
20typesubstancenode.shapecircleSubstantive type object
21typesubstancenode.fillcolorskyblue2Substantive type object
22typeknowledge crystalnode.colorgoldKnowledge crystal type object (including ovariables and key ovariables)
23typeoptionnode.colorpalevioletredOption for a decision
24typeoptionnode.fillcolorwhiteOption for a decision
25typeindexnode.shapepolygonIndex or other classifying determinant
26typeindexnode.sides4
27typeindexnode.skew0.5
28typeindexnode.fillcolorpurple1
29typeindexnode.height0.3
30typegraphnode.shapepolygonIndex or other classifying determinant
31typegraphnode.sides3
32typegraphnode.fillcolorpink
33typeassessmentnode.shapepolygonAssessment
34typeassessmentnode.sides8
35typeassessmentnode.fillcolorpurple1
36typestakeholdernode.shapehexagonStakeholder type object
37typestakeholdernode.fillcolorkhaki1Stakeholder type object
38typestakeholdernode.width0.8Stakeholder type object
39typemethodnode.shapepolygonMethod type object
40typemethodnode.sides6Method type object
41typemethodnode.fillcolorpurple1Method type object
42typeprocessnode.shapepentagonProcess type object
43typeprocessnode.fillcolorpurple1Process type object
44typeactionnode.fillcolorpinkProcess type object
45typetask 1node.colorbrownIllustration of the responsible organisation of the task
46typetask 2node.coloryellowIllustration of the responsible organisation of the task
47typetask 3node.colorblueIllustration of the responsible organisation of the task
48typetask 4node.colorgreenIllustration of the responsible organisation of the task
49typetask 5node.colorredIllustration of the responsible organisation of the task
50typedecisionnode.shaperectangleDecision type object
51typedecisionnode.fillcolorredDecision type object
52typedatanode.shaperectangleData type object
53typedatanode.fillcolorgoldData type object
54typeobjectivenode.shapediamondObjective type object
55typeobjectivenode.fillcoloryellowObjective type object
56typeobjectivenode.width0.8Objective type object
57typepublicationnode.fillcolorgrayPublication type object
58typestatementnode.shapepolygonArgument type object
59typestatementnode.sides4Argument type object
60typestatementnode.width0.8Argument type object
61typestatementnode.distortion-0.5Argument type object
62typetrue statementnode.fillcolorgoldArgument type object
63typefalse statementnode.fillcolorgrayArgument type object
64typefact opening statementnode.fillcolorlightskyblue1Argument type object
65typevalue opening statementnode.fillcolorpalegreen1Argument type object
66typefact closing statementnode.fillcolorskyblueArgument type object
67typevalue closing statementnode.fillcolorspringgreenArgument type object
68typefact discussionnode.fillcolorskyblueArgument type object. Not neede?
69typevalue discussionnode.fillcolorspringgreenValue judgement type object. Not needed?
70typerisk factornode.colorpinkAdditional information about object class
71typeindicatornode.colorbrownAdditional information about object class
72typeindicatornode.fillcolorgoldAdditional information about object class
73typearviointikriteerinode.colororangeNot quite clear what criteria objects are: indicators or value statements, or something else
74typetasknode.colorgreenAdditional information about object class
75typedatanode.colororangeAdditional information about object class
76typehealth organisationnode.coloryellowAdditional information about object class
77Relationcausal linkedge.colorblackCausal link
78Relationcausal linkedge.stylesolidCausal link
79Relationpositive causal linkedge.fontcolorgreenCausal link
80Relationnegative causal linkedge.fontcolorredCausal link
81Relationparticipatory linkedge.colorpurpleParticipatory link
82Relationparticipatory linkedge.styledashedParticipatory link
83Relationoperational linkedge.colorblackOperational link
84Relationoperational linkedge.styledashedOperational link
85Relationevaluative linkedge.colorgreenEvaluative link
86Relationrelevant attackedge.colorredAttacking argument
87Relationrelevant defenseedge.colorgreenDefending argument
88Relationrelevant commentedge.colorblueCommenting argument
89Relationirrelevant argumentedge.colorgrayInvalid argument
90Relationargumentative linkedge.styledottedArgumentative link
91Relationargumentative linkedge.penwidth4Argumentative link
92Relationreferential linkedge.colorredReferential link
93Relationreferential linkedge.styledashedReferential link

Types of insight network tables

Table types(-)
ObsTypeColumn namesDummy
1oletustype, Item, label, Relation, Object, Description, URL1
2sotearvIkaryhma, AHVK, Item, Teema, Ulottuvuus, Osiotyyppi, Tietolahde, KUVA id, Sotkanet id, JHS-luokka, Ryhman perustelut1
3hnh2035Teema, Oldid, Item, Ohjelma, Vastuu, Aikajanne, Vaativuus, Kustannukset, Kust.kaupungille, Hyodyt.kaupungille, Kust.muille, Hyodyt.muille, Paastovahenema, Muut.vaikutukset, Seurantaindikaattori, Esimerkki, Description1
4kuvaindOldid, Item, Teema, Aihe2, Aihe3, Tietopaketti1, Tietopaketti2, Tietopaketti3, Mita.mittaa, Mitta-arvo ja muodostaminen, Tietolahde, Tietolahde ja tausta, Tuotannossa, Tietotarpeen taso, Tuottamistaso, Kansainvaliset tietotoimitukset, Muut kayttotarkoitukset, Description1
5sitra100Item, Suuruus, Teema, URL1
6hvkertomusOldid, Item, Teema, Vaestoryhma, Lahde ja muodostaminen, Mita mittaa, KUVA-mittarissa, Hyte-kertoimessa, Arviointiraportissa, Hyvinvointikertomuksessa, Perustelut1
7hnhosOldid, type, Item, Description1
8keskusteluOldid, type, Item, label, Relation, Object, Description, URL1
9arviointiOldid, type, Item, Relation, Object, Description, URL, label1

Calculations

There are three different identifiers for a subject item.

  • Oldid: a technical identifier typically of format context.number, where number is a sequential number within a context.
  • Item: the actual name of the item, detailed enough to give a good understanding of its meaning.
  • label: a short name shown on insight networks. Does not exmplain everything, just enough to distinguish it from other items.

If Oldid is not given, it is created from the context and a number. If label is not given in data, it is truncated from Item.

Object item has one column Object that may contain any of these. The priority is Item > label > Oldid > Object. The last option means that it is assumed that Object refers to a new item that is not mentioned in the Item column.

An insight network is produced in this order (last object mentioned first).

  1. gr: a diagrammer graph with all data and formatting for an insight network. Produced by makeInsightGraph.
  2. makeInsightGraph


Making insight graphs

+ Show code

+ Show code

+ Show code

+ Show code

Fetch data from the web: makeInsightTables function

+ Show code

Insight network

This is an overall ovariable that automatically fetches all dependencies.

+ Show code

Shiny server

+ Show code

+ Show code

Scrape functions

These functions will be placed in the OpasnetUtils package. For now, it must be manually copied to your code.

+ Show code

+ Show code

Copy descriptions to ovariables

The function assessmentDescriptions scans through an assessment ovarible that has all relevant assessment objects as parents. Dependencies slot may also have additional information, such as the following.

  • Name: name of parent (obligatory)
  • Ident: Opasnet page identifier and code name where the parent object can be loaded (e.g. Op_en7748/hia). Note: This is typically the code for the whole assessment, not the individual codes for the objects.
  • Token: Token for the model run where the parent object can be loaded (e.g. xxNsLw5hWdM6xyYp)
  • Description: A short description about what the object is. This is typically shown when cursor hovers over the object on an online insight diagram.
  • Page: Opasnet page identifier for the object's knowledge crystal page, which contains the research question, answer, and description of the object, together with discussion, if any. Typically this is empty for ovariables, because this information can be found from ovariable@meta slot and there is no need to duplicate it here.
  • Child: An object to which this object links. This is typically needed for objects such as graphs and data.frames that do not contain this information in their own structure, unlike ovariables. The direction of a relation is away from this object because then this object is the subject in triple sentences and can be given other parameters as well in other columns. A typical sentence is "graph describes ovariable", but for illustrative purposes this is inversed on insight networks so that the arrow points from an ovariable to a graph ("ovariable is described by graph").
  • Other columns are allowed.

+ Show code

Old notation

⇤--#: . Look at the table below together with Open policy ontology and merge. Decide which things should be on this page and which should be on the other. --Jouni (talk) 06:55, 24 April 2018 (UTC) (type: truth; paradigms: science: attack)

Node type Object Colour code in Analytica Comments
General variable 8R3B (automatic) This is a deterministic function of the quantities it depends on.
Chance variable 11L4B (autom) This is a variable which is uncertain and uncontrollable (in a direct sense).
Data-driven variable 3R1B A general variable where the result is mostly driven by data (observations or literature).
Author judgement variable 4R2B A general variable where the result is mainly driven by author judgement (estimates with poor or no data).
Decision variable 9L3B This is the variable that a decision-maker has the power to control. The decision variable should always be at the top of the chain of causality, even if this is a subchain i.e. it should not have any parent variables. Essentially the decision variable should be regarded as a decision that has to be made; since many factors affect all decisions it is not (in the case of INTARESE) an efficient use of resources to attempt to model what leads a decision-maker to make his decision.
Indicator 1R3B (autom) This is a variable of special interest. One of the indicators in an assessment may be the quantitative criterion that you are trying to optimize.

A particularly important variable in relation to the interests of the intended users of the assessment output (i.e. it must be a means of effective communication of assessment results).

  • It must be in causal connection to the endpoints of the assessment and thus address causality throughout the full chain.
  • It should reflect the use/purpose of the assessment.
  • It should address and be adapted according to the target audience.
  • It should be the ‘leading component’ in the assessment process.
Value judgement variable 8L4B A preference or value that a person or a group assigns to a particular condition or state of the world.
Index (or dimension) 5R2B (autom) This identifies the dimensions of the variable to which it is linked. Note that these dimensions do not have to be numeric, but can also be classes etc.
Risk assessment 8R3B (autom)
Scope 6R1B The scope of the object
Conclusion 6L3B A conclusion of the risk assessment (Result/Conclusion attribute).
Module 6R3B (autom) A group of variables that are put together for illustrative or other practical reasons.
Data 2L3B (autom) Contents of the Definition/Data attribute of a variable. If the Result attribute of a variable is used as Data for another variable, the first variable is called a proxy, and this node is used in the diagram. If an arrow or line is drawn between these objects, it must be noticed that this is NOT a causal link but an inference link. The direction of the arrow would be from the proxy to the variable.
Argument 8R2B A piece of argumentation related to an object (variable, risk assessment, or class)
Formula 9L3B Contents of the Definition/Formula attribute of a variable.
Class 1L2B A class object (a set of objects that share a particular property).
Function 4R2B (autom) A special kind of class. The particular property that is shared contains a full description of the Scope and the Definition attributes with given parameters.
Causal arrow This states a causal relationship (or influence) of one variable onto another. Note that causal arrows can only exist between two arrows; any arrows to or from non-causal objects are non-causal inference arrows.
Non-causal arrow This states an inference relationship between two objects. This means that the object where the arrow starts from is in the Data attribute of the other object. It is thus used to infer something about the value of the result of the latter object. Either object can be a variable or a non-variable. Note that Analytica is only able to show one kind of arrows, so in some cases the nature of the arrow (causal or inference) must be concluded from the context.

Previous notations

Previous notation for insight networks. This version was optimised for Analytica use.

Insight networks have previously been called pyrkilo diagrams, extended causal diagrams, and factor-effect-value networks. These names are no longer in active use. An archived version of the notation can be found from an earlier version of this page.

See also

References