Shige's Research Blog

Sunday, August 07, 2022

Marginalia

 Very nice and comprehensive post on marginal effects

Wednesday, April 27, 2022

Processing the sugar map

 Different implementations of the Sugarscpe agent-based model have different ways to get up the sugar map. SugarscapeCW used a built-in matrix (no space between each number) whereas the NetLogo model library uses an external text file with a blank space between each number. 

The easy way to translate between these two different format is to use the readr R package, something like this:

library(readr)

sugar_map1 <- read_fwf("~/tmp/sugar-map1.txt", fwf_widths(c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), col_names = NULL))

write_delim(sugar_map1, "~/tmp/sugar-map-out.txt", delim = " ", col_names = FALSE)

Wednesday, December 29, 2021

Using Obsidian as a Markdown editor

 I have been using the open source Typora editor for light editing. It appears to become commercial recently. I was about to purchase a licence when I realized that the recent upgrade of Obsidian (v. 0.13.14) has provided very nice Markdown editor feature and can complete replace a dedicated editor such as Typora. 

I really like Obsidian!

Wednesday, August 18, 2021

The pandemic is back

 According to this report, despite the vaccination and other efforts, the daily new COVID-19 cases has reached the 200,000 mark on August 17 in the US. It appears that a new wave of the pandemic has begun. 

Wednesday, August 11, 2021

Obsidian

 I have been searching for a note taking/management tool for some time. From a book, I encountered Roam, which looks exactly what I need. After some research, I realized that is is a proprietary software using proprietary data storage format, and store all data on a remote cloud server. This, along with its not so modest price tag, raises a red flag. 

Then I discovered Obsidian, which is itself proprietary (as opposed to open source) but it works on local, plain text (including Markdown) files, which can be opened and modified by any text editors. For now, it looks really promising!

Tuesday, April 06, 2021

NetLogo code for Party Competition

 Today I spent some time to manually convert the NetLogo code for Party Competition from version 5 to version 6. 

Fascinating book, by the way. 

Friday, February 26, 2021

Thunderbird conversation mode

 Just discovered Thunderbird conversations extension that displays Thunderbird emails like Gmail. Very cool. 

Thursday, February 25, 2021

Convert email to event or task

 I just found out that Thunderbird can convert an email into an event or task with deadline. This is extremely useful for me. 

Monday, February 15, 2021

Using tikzDevice in R Markdown document

 When I was LaTeX user in the past, I like TikZ and tikzDevice a lot. After switching to R Markdown, however, I gradually forgot about them. Today I spent some time figuring out how to make TikZ and tikzDevice work for R Markdown. Here is some simple code: 

---
title: "Using tikzDevice"
output: 
  pdf_document: 
    latex_engine: xelatex
    keep_tex: yes
    includes:
      in_header: setup.tex
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
```{r, fig.cap="Without tikzDevice"}
x<- rnorm(10)
y<-x +rnorm(5,sd=0.25)
model <- lm(y~x)
rsq<- summary(model)$r.squared
rsq<- signif(rsq,4)
plot(x, y, main='Hello \\LaTeX!')
abline(model,col='red')
mtext(paste("Linear model:$R^{2}=",
            rsq, "$"), line=0.5)
legend('bottomright',legend=paste("$y = ",round(coef(model)[2],3),'x +',round(coef(model)[1],3),'$',sep =''), bty ='n')
```
```{r, echo=FALSE}
library(tikzDevice)
```
```{r, echo=FALSE, message=FALSE, results='hide'}
tikz('latexEx.tex',width=7,height=4.5)
x<- rnorm(10)
y<-x +rnorm(5,sd=0.25)
model <- lm(y~x)
rsq<- summary(model)$r.squared
rsq<- signif(rsq,4)
plot(x, y, main='Hello \\LaTeX!')
abline(model,col='red')
mtext(paste("Linear model:$R^{2}=",
            rsq, "$"), line=0.5)
legend('bottomright',legend=paste("$y = ",round(coef(model)[2],3),'x +',round(coef(model)[1],3),'$',sep =''), bty ='n')
dev.off()
```
```{r, fig.cap="With tikzDevice", message=FALSE, engine='tikz'}
\input{latexEx.tex}

Counter