#########################################
## MODEL FRAMES (method="model.frame") ##
#########################################
## --- ROOMMATES GAME ---
## 1. Simulate one-sided matching data for 3 markets (m=3) with 3 groups
## per market (gpm=3) and 2 individuals per group (ind=2)
idata <- stabsim(m=3, ind=2, gpm=3)
## 2. Obtain the model frame
# s1 <- stabit(x=idata, selection = list(add="pi", ieq="wst"),
outcome = list(add="pi", ieq="wst"),
method="model.frame", simulation="TU", roommates=TRUE)
## --- GROUP/COALITION FORMATION (I) ---
## 1. Simulate one-sided matching data for 3 markets (m=3) with 2 groups
## per market (gpm=2) and 2 to 4 individuals per group (ind=2:4)
idata <- stabsim(m=3, ind=2:4, gpm=2)
## 2. Obtain the model frame
s2 <- stabit(x=idata, selection = list(add="pi", ieq="wst"),
outcome = list(add="pi", ieq="wst"),
method="model.frame", simulation="NTU", roommates=FALSE)
## --- GROUP/COALITION FORMATION (II) ---
## 1. Load baac00 data from the Townsend Thai project
data(baac00)
## 2. Obtain the model frame
s3 <- stabit(x=baac00, selection = list(add="pi", int="pi", ieq="wst", ive="occ"),
outcome = list(add="pi", int="pi", ieq="wst", ive="occ",
add=c("loan_size","loan_size2","lngroup_agei")),
method="model.frame", simulation="none")
###############################
## ESTIMATION (method="NTU") ##
###############################
## --- SIMULATED EXAMPLE ---
## 1. Simulate one-sided matching data for 3 markets (m=3) with 2 groups
## per market (gpm=2) and 2 to 4 individuals per group (ind=2:4)
idata <- stabsim(m=3, ind=2:4, gpm=2)
## 2. Run Gibbs sampler
fit1 <- stabit(x=idata, selection = list(add="pi",ieq="wst"),
outcome = list(add="pi",ieq="wst"),
method="NTU", simulation="NTU", binary=FALSE, niter=2000)
## 3. Get results
names(fit1)
## --- REPLICATION, Klein (2014), Table 5 ---
## 1. Load data
data(baac00)
## 2. Run Gibbs sampler
fit2 <- stabit(x=baac00, selection = list(add="pi",int="pi",ive="occ",ieq="wst"),
outcome = list(add="pi",int="pi",ive="occ",ieq="wst",
add=c("loan_size","loan_size2","lngroup_agei")),
method="NTU", binary=TRUE, gPrior=TRUE, marketFE=TRUE, niter=2000)
## 3. Get results
names(fit2)Run the code above in your browser using DataLab