Description Usage Arguments Details Value Author(s) See Also Examples

Generates a random tree structure, with observed and prediction locations, and stores as an object of class SpatialStreamNetwork-class.

1 2 | ```
createSSN(n, obsDesign, predDesign = noPoints, path, importToR = FALSE,
treeFunction = igraphKamadaKawai)
``` |

`n` |
A numeric vector, where the generated |

`obsDesign` |
A function representing a sampling strategy. It is used to select observation points on the network. Input obsDesign is required and cannot have value noPoints, as there must be at least one observed point generated. At present the only implemented designs are binomialDesign, systematicDesign, systematicDesign, poissonDesign and hardCoreDesign. For further details, which will allow users to to write your their own design function, please see the design functions. |

`predDesign` |
A function having the same signature as the |

`path` |
The path where the new .ssn directory is to be stored. |

`importToR` |
If |

`treeFunction` |
An input function that is used to generate the tree structure. This function must have the signature function(n) Where |

This function generates random tree structure using the `igraph`

package and then turns these into an `SpatialStreamNetwork`

object
with prediction and observation sites generated by the `obsDesign`

and `predDesign`

functions. The main difficulty is assigning
locations to the vertices of the random trees, in such a way that the result
has the sort of layout that we want. This is a graph layout / embedding problem,
more specifically a tree layout problem. For now we are using the `layout.kamada.kawai`

function of the `igraph`

package to construct this layout. Unlike some of the other
layouts available, it still gives interesting layouts when applied to trees
(some of the others tend to give highly structured layouts for such a
simple graph. The downside is that it the resulting layout can have self
intersections, and often does.

An `SpatialStreamNetwork`

object if `importToR`

is `TRUE`

, otherwise `NULL`

.

Rohan Shah and Pascal Monestiez support@SpatialStreamNetworks.com

`SimulateOnSSN`

, `importSSN`

, `igraph`

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 | ```
library(SSN)
#Simulate three networks, the first consisting of ten straight line segments,
#the second of 20 and the third of 30. There are two observed points on the first
#network, four on the second and six on the third. All the observed points are
#distributed uniformly. The default for prediction points is no prediction points.
ssn1 <- createSSN(c(10, 20, 30), obsDesign = binomialDesign(c(2,4,6)),
path=paste(tempdir(),"/simulated1.ssn", sep = ""), importToR = TRUE)
#NOT RUN plot(ssn1)
#Same as above, but using iterativeTreeLayout
#set.seed(5)
#ssn2 <- createSSN(c(10, 20, 30), obsDesign = binomialDesign(c(2,4,6)),
# path=paste(tempdir(),"/simulated2.ssn", sep = ""), importToR = TRUE,
# treeFunction = iterativeTreeLayout)
#NOT RUN plot(ssn2)
#Simulate the same number of line segments per network, but this time the observed
#points have the distribution of a Poisson process with rates 2, 1 and 0.5
#respectively. Again there are no prediction points.
#ssn3 <- createSSN(c(10, 20, 30), obsDesign = poissonDesign(c(2,1,0.5)),
# path=paste(tempdir(),"/simulated3.ssn", sep = ""), importToR = TRUE)
#NOT RUN plot(ssn3)
#Simulate the same number of line segments per network, but this time the observed
#points have a hard-core process distribution. Two hundred points are placed on
#every network according to the binomial process, and then points are removed
#until every poir of points is at least a distance 0.5 apart on the first network,
#0.25 on the second and 0.1 on the third. Again there are no prediction points.
#ssn4 <- createSSN(c(10, 20, 30), obsDesign = hardCoreDesign(200, c(0.5, 0.25, 0.1)),
# path=paste(tempdir(),"/simulated4.ssn", sep = ""), importToR = TRUE)
#NOT RUN plot(ssn4)
#This time there are the same number of observed points on each of the networks,
#but there are ten prediction sites on each network.
ssn5 <- createSSN(c(10, 20, 30), obsDesign = binomialDesign(c(2, 4, 6)),
predDesign = binomialDesign(c(10, 10, 10)),
path=paste(tempdir(),"/simulated5.ssn", sep = ""),
importToR = TRUE)
#NOT RUN plot(ssn5)
#This time the observed and prediction points are a regular grid, spacing 0.5
#ssn6 <- createSSN(c(10, 20, 30), obsDesign = systematicDesign(0.5),
# predDesign = systematicDesign(0.5),
# path=paste(tempdir(),"/simulated6.ssn", sep = ""),
# importToR = TRUE)
#NOT RUN plot(ssn6)
#Same as example number 5, but this time the observed (but not predicted) points
#are replicated twice with different time values
#ssn7 <- createSSN(c(10, 20, 30), obsDesign = binomialDesign(c(2, 4, 6),
# replications=2),
# predDesign = binomialDesign(c(10, 10, 10)),
# path=paste(tempdir(),"/simulated7.ssn", sep = ""),
# importToR = TRUE)
#NOT RUN plot(ssn7)
ssn1@obspoints@SSNPoints[[1]]@point.data
ssn5@obspoints@SSNPoints[[1]]@point.data
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.