Posts

Showing posts with the label graph

Error in effect.default…argument “offset” is missing, with no default

Error in effect.default…argument “offset” is missing, with no default I'm looking to plot the effects for a TOBIT regression model at -1SD and +1SD using a bar graph. I would normally use a line graph, but my co-authors have asked for a bar graph instead. I have had some help identifying what I should do here, but I am getting an error that no one seems to be able to figure out. Creating dataframe - this runs fine. tobitforgraph <- survreg(Surv(S1, S2, type='right') ~ +(Var1centered)*Var2centered*Var3standardized,data=Datafilename, dist='gaussian', robust=TRUE)) Load effects library. library(effects) Extract values for plotting (the values coming from here are then supposed to be used to plot as normal in Excel, although there may be a way to do it in R; regardless, this is where I am getting an error). print((intplot<-as.data.frame(ef< Effect(c("Var1centered","Var3standardized"),mod=tobitforgraph,xlevels=list(Var1centered=c(-.4987531,.5...

Difference between DFS vs BFS in this example?

Image
Difference between DFS vs BFS in this example? I am bit confused after reading examples at DFS where output is printed in different fashion for both DFS approaches though both are said to be DFS. In fact DFS recursion approach print the output just in same fashion as BFS. Then what's the difference ? Is recursion approach given here not an example of DFS ? Using Stack // Iterative DFS using stack public void dfsUsingStack(Node node) { Stack<Node> stack=new Stack<Node>(); stack.add(node); node.visited=true; while (!stack.isEmpty()) { Node element=stack.pop(); System.out.print(element.data + " "); List<Node> neighbours=element.getNeighbours(); for (int i = 0; i < neighbours.size(); i++) { Node n=neighbours.get(i); if(n!=null && !n.visited) { stack.add(n); n.visi...

Minefield Challenge [on hold]

Minefield Challenge [on hold] Got interesting code challenge recently (below), thought about it for awhile, but could not really come up with solution. Would really appreciate help!! Notice that it's not 2D matrix and traditional minesweeper challenge. Thoughts coming to mind - sub-graph, recursive algorithms, but seems I am over-thinking the problem.. (say I have 10,000 mines - I have to iterate thru all 10K, and then collect winning mines for a 2nd level of explosions etc.) Explosive power is basically to calculate a distance to the near-by mine (if reachable) Challenge Write a program which takes as input a list of mines composing a 2D minefield; each mine has an X position, a Y position, and an explosive power. All three parameters may be assumed to be single-precision floats; explosive power may not be negative. There may not be more than one mine at the same coordinates. When a mine in the minefield is triggered at time T=0, it causes all other mines within a straight-line di...

Graphing a network in igraph or other packages in R that has each node dependent on covariates?

Image
Graphing a network in igraph or other packages in R that has each node dependent on covariates? I currently have a network in R, available in an adjacency matrix, edgelist, and network format, that I would like to plot based on the covariates of each of the nodes. I have three covariates, age , class , and score , with age being 0 or 1, class ranging from 1 to 50, and score from 0 to 100. I am wondering which packages in R might facilitate plotting nodes and their network edges with node colors depending on class , the symbol of a node depending on age , and the size of a node dependent on the score ? Do there exists such methods in igraph ? Thanks! age class score age class score class age score igraph 1 Answer 1 Here is an example using igraph . Since you do not provide any data, I illustrate with some randomly generated data. igraph library(igraph) set.seed(12) g = erdos.renyi.game(10,0.33) V(...