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.

skip to main |
skip to sidebar
#
Shige's Research Blog

## Tuesday, April 06, 2021

###
NetLogo code for Party Competition

## Friday, February 26, 2021

###
Thunderbird conversation mode

## Thursday, February 25, 2021

###
Convert email to event or task

## Monday, February 15, 2021

###
Using tikzDevice in R Markdown document

## Thursday, February 11, 2021

## Saturday, January 30, 2021

## Friday, January 08, 2021

## Wednesday, December 30, 2020

###
Estimating and testing GLMs with `emmeans`

## Important Links

## Labels

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.

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

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

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}

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}

This post shows how to use *emmeans* package to generate first difference with confidence intervals.

Subscribe to:
Posts (Atom)

- ADMB
- Advanced R Programming
- Bayesian Analysis
- brms
- Causality
- CCPR
- China Migration Project
- CIDR
- DAGitty
- Developmental Origins Project
- Doing Bayesian Data Analysis
- Emacs
- ESS
- ggdag
- Journal of Statistical Software
- LaTeX wiki book
- Lavaan
- Lazarus
- Maxima
- Mplus
- My Home Page
- NetLogo
- Nimble
- OpenMX
- PracTeX
- Queens College
- R
- R bloggers
- R-INLA
- Rcpp
- Research Progress
- RStudio
- ShareLaTeX
- Stan
- Stata
- Stata Journal
- StatET
- TeXstudio
- TUGboat

academic research
(2)
ADMB
(16)
agent-based model
(7)
air quality
(1)
algebra
(1)
Amazon
(1)
American Community Survey
(1)
aML
(11)
anamation
(1)
Android
(2)
Apophenia
(3)
Apple
(15)
Atom
(2)
AUCTeX
(2)
Azure
(1)
Bayesian
(74)
BayesX
(1)
Beamer
(1)
benchmark
(1)
beta regression
(1)
bibliographic software
(11)
bibtex
(4)
big data
(15)
BLAS
(2)
blockchain
(5)
blog
(26)
book
(50)
book reader
(3)
bootstrap
(1)
brms
(2)
BUGS
(29)
build dependency
(1)
C
(8)
C++
(25)
causal inference
(10)
ceemple
(1)
China
(6)
Chinese
(18)
Cinnamon
(1)
citation
(3)
Clojure
(5)
cloud computing
(6)
computer
(15)
computing
(3)
console
(1)
COVID-19
(2)
CPU
(1)
css
(1)
Cure model
(5)
cygwin
(3)
DAG
(2)
data entry
(1)
data manipulation
(7)
data science
(12)
database
(2)
Debian
(10)
debug
(4)
demography
(9)
desktop
(2)
diagram
(2)
difference-in-difference
(1)
documentation
(1)
dplyr
(2)
eclipse
(11)
ecology
(1)
econometrics
(2)
Emacs
(43)
email
(1)
encryption
(1)
ESS
(3)
evolutionary psychology
(2)
exams
(1)
first difference
(1)
flash drive
(1)
font
(2)
Fortran
(10)
frailty
(3)
fraud
(1)
free books
(2)
Free software
(18)
freepascal
(3)
front-door criterion
(1)
g++
(5)
GEE
(1)
gganimate
(2)
ggdag
(1)
ggmap
(2)
ggplot2
(19)
GIS
(9)
github
(1)
GLMM
(5)
Gmail
(1)
Gnome
(2)
GPL
(1)
grant
(1)
graph
(19)
graphics
(4)
gtk
(1)
GUI
(2)
hacker
(1)
Hadoop
(3)
happiness
(1)
high performance
(3)
history
(2)
human nature
(1)
ide
(4)
Incanter
(1)
INLA
(4)
instrumental variables
(2)
interaction effect
(1)
ipython
(3)
IRT
(1)
JAGS
(20)
java
(5)
javascript
(1)
journal
(11)
Julia
(2)
Jupyter
(1)
kindle
(1)
knitr
(4)
kvm
(1)
LaplacesDemon
(2)
Laptop
(16)
Latent Gold
(1)
latent variable
(2)
LaTeX
(82)
legend
(1)
library
(4)
LibreOffice
(3)
linu
(1)
Linux
(102)
Lisp
(7)
literature review
(1)
Lubuntu
(1)
LyX
(1)
machine learning
(2)
make
(1)
map
(14)
marginal effect
(1)
Markdown
(22)
matlab
(3)
maximum likelihood
(2)
MCMC
(10)
methodology
(2)
mind mapping
(2)
Mint Linux
(20)
missing values
(3)
mixture model
(7)
MLwiN
(1)
mono
(1)
monte carlo
(1)
mortality
(2)
Mplus
(7)
multilevel model
(14)
multilevel multiprocess model
(8)
multiple imputation
(4)
natural selection
(1)
netlogo
(7)
network
(1)
news
(1)
NSF
(1)
numerical method
(1)
obesity
(1)
octave
(1)
open access
(1)
open source
(9)
OpenOffice
(9)
output
(3)
PAA
(2)
pandoc
(5)
Paper
(7)
parallel
(2)
pdf
(7)
performance
(16)
phone
(1)
pipeline
(1)
politics
(3)
poststratification
(1)
prediction
(2)
presentation
(3)
prior
(1)
programming
(27)
projection
(1)
propensity score
(1)
proposal
(3)
public use data
(7)
publishing
(5)
python
(20)
quantile regression
(1)
R
(119)
R packages
(7)
random effect
(3)
Rcpp
(11)
regular expression
(2)
relative distribution
(1)
Repast
(1)
report
(2)
reproducible research
(6)
rescue
(1)
research project
(1)
rpubs
(1)
rstan
(1)
rstudio
(21)
Russia
(1)
Sabre
(1)
scam
(1)
Sciviews
(2)
scripting
(2)
security
(1)
sequence analysis
(1)
sex ratio
(1)
sex selection
(1)
sharing monitor
(2)
shell
(2)
simulation
(15)
skewed distribution
(1)
skype
(1)
sociology
(4)
software
(20)
solid state drive
(1)
source tarball
(1)
Spark
(7)
SparkR
(8)
spatial analysis
(12)
spell checking
(1)
spline
(1)
ssh
(3)
stan
(16)
Stata
(37)
StatET
(3)
statistics
(5)
structural equation modeling
(5)
summary statistics
(1)
survey data
(1)
survival model
(2)
sweave
(15)
synchronize
(1)
SyncTeX
(1)
table
(24)
tablet pc
(10)
talk
(1)
teaching
(11)
text analysis
(3)
text editor
(8)
text mining
(4)
theme
(1)
Thunderbird
(2)
tidyr
(1)
tidyverse
(3)
TikZ
(1)
time series
(1)
tmap
(1)
to-do
(1)
trust
(1)
ubuntu
(31)
Unix
(3)
Unix philosophy
(1)
version control
(7)
vim
(1)
virtualization
(3)
vmware
(2)
voip
(2)
vpn
(3)
web data
(3)
web log
(1)
web scraping
(3)
wiki
(2)
Windows
(1)
word count
(1)
workflow
(5)
workstation
(2)
writing
(2)
Xfce
(1)
Zelig
(3)
Zotero
(4)