Learn R Programming

smnet (version 1.0)

simulateNetwork: Simulate river network topology and data

Description

Simulates a graph, where nodes correspond to stream segments and an edge denotes that two stream segments are connected via a confluence. In addition data is simulated on the network, with one datum associated with each stream segment. Not of practical use, but good for checking that other utilities in SmoothNetwork work. Uses the igraph package to construct the graph.

Usage

simulateNetwork(n.segments, beta = NULL, lambda = 1, subs = F)

Arguments

n.segments
Number of nodes the simulated network should have
lambda
Positive real number: level of smoothness the simulated data should have. Small values mean less smoothness. Default = 1.
beta
Numeric vector of covariate effects. If supplied, independent random normal covariate data is generated on each stream segment with true coefficients as in beta.
subs
Number between 0 and 1. Determines whether data is simulated on a random subset of the network nodes of size subs*n.segments.

Value

  • responseVector of simulated data of length n.segments, or if subs is supplied, of length subs*n.segments
  • response.locsVector indicating which node each value of responsecame from
  • alphaRandom intercept term, generated from U(0,1) draw
  • zVector of true spatial effects (response - alpha - random noise)
  • ZIf subs is supplied these are the true values for all nodes
  • wgtsVector of (flow) weights, based on Shreve order
  • adjacencyn.segments*n.segments adjacency matrix of class spam
  • coordsn.segments*2 matrix of coordinates of node locations, useful for plotting

References

Csardi G, Nepusz T: The igraph software package for complex network research, InterJournal, Complex Systems 1695. 2006. http://igraph.sf.net

See Also

plot.smnet, summary.smnet

Examples

Run this code
# Generate some simulated data with 100 stream segments
x<-simulateNetwork(n.segments = 100, lambda = 1)

lmSim<-smnet(formula=response~1 + 
               network(adjacency = x$adjacency, weight = x$wgts,
               locs = x$response.locs), 
               data.object = x$obsdata,
               method = "AICC")

plot(lmSim, type = "nodes", coords = x$obsdata[,2:3])

Run the code above in your browser using DataLab