<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments for BabelGraph</title>
	<atom:link href="http://www.babelgraph.org/wp/?feed=comments-rss2" rel="self" type="application/rss+xml" />
	<link>http://www.babelgraph.org/wp</link>
	<description>health care, medicine, R, social network analysis, random nerdy stuff</description>
	<lastBuildDate>Wed, 18 Apr 2012 18:31:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>Comment on Calculating the mixing matrix and assortativity coefficient with igraph in R by Vessy</title>
		<link>http://www.babelgraph.org/wp/?p=351#comment-157</link>
		<dc:creator>Vessy</dc:creator>
		<pubDate>Wed, 18 Apr 2012 18:31:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.babelgraph.org/wp/?p=351#comment-157</guid>
		<description>Nice!

However, I&#039;ve noticed that your code does not distinguish between directed and undirected graphs and does not produce eij =eji (it seems that the program always considers first node in the edge list as a source and the second node as a target). 

This part should fix it (and it also should run bit faster)

for (i in 1:numatts)
    for (j in 1:numatts)
    {
      iNode &lt;- V(mygraph)[attrib == attlist[i]]
      jNode &lt;- V(mygraph)[attrib == attlist[j]]
      
      if (is.directed(mygraph))
        mm[i, j] %jNode])
      else
        mm[i, j] &lt;- length(E(mygraph)[iNode%--%jNode])
    }</description>
		<content:encoded><![CDATA[<p>Nice!</p>
<p>However, I&#8217;ve noticed that your code does not distinguish between directed and undirected graphs and does not produce eij =eji (it seems that the program always considers first node in the edge list as a source and the second node as a target). </p>
<p>This part should fix it (and it also should run bit faster)</p>
<p>for (i in 1:numatts)<br />
    for (j in 1:numatts)<br />
    {<br />
      iNode &lt;- V(mygraph)[attrib == attlist[i]]<br />
      jNode &lt;- V(mygraph)[attrib == attlist[j]]</p>
<p>      if (is.directed(mygraph))<br />
        mm[i, j] %jNode])<br />
      else<br />
        mm[i, j] &lt;- length(E(mygraph)[iNode%--%jNode])<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on R can write R code, too by ray w</title>
		<link>http://www.babelgraph.org/wp/?p=312#comment-156</link>
		<dc:creator>ray w</dc:creator>
		<pubDate>Tue, 17 Apr 2012 15:32:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.babelgraph.org/wp/?p=312#comment-156</guid>
		<description>I figured out the answer like a preschooler ... the next step is to solve via programming ... Thanks for sharing!  Ray</description>
		<content:encoded><![CDATA[<p>I figured out the answer like a preschooler &#8230; the next step is to solve via programming &#8230; Thanks for sharing!  Ray</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Using R and clinical heuristics to explore the Heritage Health Prize: what do we gain? by Thomson</title>
		<link>http://www.babelgraph.org/wp/?p=178#comment-153</link>
		<dc:creator>Thomson</dc:creator>
		<pubDate>Fri, 01 Jul 2011 22:12:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.babelgraph.org/wp/?p=178#comment-153</guid>
		<description>Hello,

Thanks for posting the plots--very interesting results. 

Have you followed up on the most recent HHP release? In an effort to anonymize data, the Drug/Lab data simply contains information on how many drug prescriptions/lab tests a patient has received in the past year, with no insight as to what the drugs or lab tests are. Not exactly what I was hoping....</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>Thanks for posting the plots&#8211;very interesting results. </p>
<p>Have you followed up on the most recent HHP release? In an effort to anonymize data, the Drug/Lab data simply contains information on how many drug prescriptions/lab tests a patient has received in the past year, with no insight as to what the drugs or lab tests are. Not exactly what I was hoping&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Speeding up agent-based simulations with data frames in R by Adam Laiacano</title>
		<link>http://www.babelgraph.org/wp/?p=237#comment-97</link>
		<dc:creator>Adam Laiacano</dc:creator>
		<pubDate>Mon, 18 Apr 2011 19:52:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.babelgraph.org/wp/?p=237#comment-97</guid>
		<description>Gary,

I don&#039;t have much experience with panel data, so I&#039;m sure if it&#039;s better to use 3-dimensional arrays, lists of data frames, or what. Perhaps someone else can chime in.  I&#039;d also check out the plyr package: http://www.jstatsoft.org/v40/i01/paper

A for loop might be unavoidable for generating iterative data.  I&#039;ve done loops like this in matlab and was able to speed them up by an order of magnitude by re-writing it in c, but I&#039;m not sure about R.

As for updating the data within each iteration, I&#039;d do something like this:

&lt;code&gt;
df1 &lt;- cohortD(400)
df2 &lt;- df1
df2$age &lt;- df2$age + 1/12
update.index &lt;- runif(nrow(df2) &gt; 0.8
update.values &lt;- sample(df1$fav.flavor, size=sum(update.index), replace=TRUE)
df2$fav.flavor[update.index] &lt;- update.values

# comparing the fav.flavor distributions
x&lt;-melt.data.frame(data.frame(id=df1$id,df1=df1$fav.flavor, df2=df2$fav.flavor),
               id.vars=&quot;id&quot;)
ggplot(x, aes(x=value))+geom_bar(aes(fill=variable), position=&quot;dodge&quot;)
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Gary,</p>
<p>I don&#8217;t have much experience with panel data, so I&#8217;m sure if it&#8217;s better to use 3-dimensional arrays, lists of data frames, or what. Perhaps someone else can chime in.  I&#8217;d also check out the plyr package: <a href="http://www.jstatsoft.org/v40/i01/paper" rel="nofollow">http://www.jstatsoft.org/v40/i01/paper</a></p>
<p>A for loop might be unavoidable for generating iterative data.  I&#8217;ve done loops like this in matlab and was able to speed them up by an order of magnitude by re-writing it in c, but I&#8217;m not sure about R.</p>
<p>As for updating the data within each iteration, I&#8217;d do something like this:</p>
<p><code><br />
df1 &lt;- cohortD(400)<br />
df2 &lt;- df1<br />
df2$age &lt;- df2$age + 1/12<br />
update.index < - runif(nrow(df2) > 0.8<br />
update.values &lt;- sample(df1$fav.flavor, size=sum(update.index), replace=TRUE)<br />
df2$fav.flavor[update.index] &lt;- update.values</p>
<p># comparing the fav.flavor distributions<br />
x&lt;-melt.data.frame(data.frame(id=df1$id,df1=df1$fav.flavor, df2=df2$fav.flavor),<br />
               id.vars=&quot;id&quot;)<br />
ggplot(x, aes(x=value))+geom_bar(aes(fill=variable), position=&quot;dodge&quot;)<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Speeding up agent-based simulations with data frames in R by gary</title>
		<link>http://www.babelgraph.org/wp/?p=237#comment-85</link>
		<dc:creator>gary</dc:creator>
		<pubDate>Sun, 17 Apr 2011 18:06:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.babelgraph.org/wp/?p=237#comment-85</guid>
		<description>Tom, thanks for the tip.  I may rerun the benchmark using the data.table package.
Gary</description>
		<content:encoded><![CDATA[<p>Tom, thanks for the tip.  I may rerun the benchmark using the data.table package.<br />
Gary</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Speeding up agent-based simulations with data frames in R by gary</title>
		<link>http://www.babelgraph.org/wp/?p=237#comment-84</link>
		<dc:creator>gary</dc:creator>
		<pubDate>Sun, 17 Apr 2011 18:04:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.babelgraph.org/wp/?p=237#comment-84</guid>
		<description>Patrick, I would be interested to apply a function across each row that &quot;updated&quot; the values of the data frame at each time step.  The function would, for example, on each member of the cohort (row) :

	1) Age each member of the cohort by 1 month
	2) With 20% probability, select a new favorite flavor based on the prevalence of favorites in the wider population


Essentially the form of the output of the function would be the same as the data frame, and would just update the entries as specified in the function.  Is this possible with the &lt;code&gt;apply&lt;/code&gt; approach?</description>
		<content:encoded><![CDATA[<p>Patrick, I would be interested to apply a function across each row that &#8220;updated&#8221; the values of the data frame at each time step.  The function would, for example, on each member of the cohort (row) :</p>
<p>	1) Age each member of the cohort by 1 month<br />
	2) With 20% probability, select a new favorite flavor based on the prevalence of favorites in the wider population</p>
<p>Essentially the form of the output of the function would be the same as the data frame, and would just update the entries as specified in the function.  Is this possible with the <code>apply</code> approach?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Speeding up agent-based simulations with data frames in R by Tom</title>
		<link>http://www.babelgraph.org/wp/?p=237#comment-79</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Sun, 17 Apr 2011 08:26:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.babelgraph.org/wp/?p=237#comment-79</guid>
		<description>Gary, thanks for sharing your analysis and code; the speed gains are impressive!

You might also look into the data.table library. It is designed to speed up certain operations on data frames.</description>
		<content:encoded><![CDATA[<p>Gary, thanks for sharing your analysis and code; the speed gains are impressive!</p>
<p>You might also look into the data.table library. It is designed to speed up certain operations on data frames.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Speeding up agent-based simulations with data frames in R by Patrick</title>
		<link>http://www.babelgraph.org/wp/?p=237#comment-78</link>
		<dc:creator>Patrick</dc:creator>
		<pubDate>Sun, 17 Apr 2011 06:34:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.babelgraph.org/wp/?p=237#comment-78</guid>
		<description>The for loop is generally avoidable, one can use the apply family of functions, or the doBY, sqldf, plyr packages. My favorite is sqldf whenever I can use it, as it typically is very fast.

I second Adam&#039;s post; this is classic inefficient R programming, and Adam&#039;s method is much better.

What operation are you looking to try to eliminate looping through rows?</description>
		<content:encoded><![CDATA[<p>The for loop is generally avoidable, one can use the apply family of functions, or the doBY, sqldf, plyr packages. My favorite is sqldf whenever I can use it, as it typically is very fast.</p>
<p>I second Adam&#8217;s post; this is classic inefficient R programming, and Adam&#8217;s method is much better.</p>
<p>What operation are you looking to try to eliminate looping through rows?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Speeding up agent-based simulations with data frames in R by gary</title>
		<link>http://www.babelgraph.org/wp/?p=237#comment-75</link>
		<dc:creator>gary</dc:creator>
		<pubDate>Sat, 16 Apr 2011 22:10:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.babelgraph.org/wp/?p=237#comment-75</guid>
		<description>Adam, 
That makes sense given the benchmarks you provided.  What do you usually use for values in a data frame not producible via a vectorized function like &lt;code&gt;sample()&lt;/code&gt;?  Is the &lt;code&gt;for&lt;/code&gt; loop avoidable?  The world of actual modeling may warrant an exploration into C/Rcpp...
Gary</description>
		<content:encoded><![CDATA[<p>Adam,<br />
That makes sense given the benchmarks you provided.  What do you usually use for values in a data frame not producible via a vectorized function like <code>sample()</code>?  Is the <code>for</code> loop avoidable?  The world of actual modeling may warrant an exploration into C/Rcpp&#8230;<br />
Gary</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Speeding up agent-based simulations with data frames in R by Adam Laiacano</title>
		<link>http://www.babelgraph.org/wp/?p=237#comment-74</link>
		<dc:creator>Adam Laiacano</dc:creator>
		<pubDate>Sat, 16 Apr 2011 21:42:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.babelgraph.org/wp/?p=237#comment-74</guid>
		<description>Gary,

I realize it isn&#039;t clear, but I meant the &quot;Cohort C&quot; method, for which I include the (poorly formatted) benchmark results above.  Not an implementation in c/Rcpp, which I haven&#039;t tried and seems like overkill for this task.

Adam</description>
		<content:encoded><![CDATA[<p>Gary,</p>
<p>I realize it isn&#8217;t clear, but I meant the &#8220;Cohort C&#8221; method, for which I include the (poorly formatted) benchmark results above.  Not an implementation in c/Rcpp, which I haven&#8217;t tried and seems like overkill for this task.</p>
<p>Adam</p>
]]></content:encoded>
	</item>
</channel>
</rss>

