###################
### Coordinate representation of a CoDa Table
# example from Fa\v cevicov\'a (2018):
data(manu_abs)
manu_USA <- manu_abs[which(manu_abs$country=='USA'),]
manu_USA$output <- factor(manu_USA$output, levels=c('LAB', 'SUR', 'INP'))
# pivot coordinates
tabCoord(manu_USA, row.factor = 'output', col.factor = 'isic', value='value')
# SBPs defined in paper
r <- rbind(c(-1,-1,1), c(-1,1,0))
c <- rbind(c(-1,-1,-1,-1,1), c(-1,-1,-1,1,0), c(-1,-1,1,0,0), c(-1,1,0,0,0))
tabCoord(manu_USA, row.factor = 'output', col.factor = 'isic', value='value', SBPr=r, SBPc=c)
###################
### Analysis of a sample of CoDa Tables
# example from Fa\v cevicov\'a (2018):
data(manu_abs)
### Compositional tables approach,
### analysis of the relative structure.
### An example from Facevi\v cov\'a (2018)
manu_abs$output <- factor(manu_abs$output, levels=c('LAB', 'SUR', 'INP'))
# pivot coordinates
tabCoordWrapper(manu_abs, obs.ID='country',
row.factor = 'output', col.factor = 'isic', value='value')
# SBPs defined in paper
r <- rbind(c(-1,-1,1), c(-1,1,0))
c <- rbind(c(-1,-1,-1,-1,1), c(-1,-1,-1,1,0),
c(-1,-1,1,0,0), c(-1,1,0,0,0))
tabCoordWrapper(manu_abs, obs.ID='country',row.factor = 'output',
col.factor = 'isic', value='value', SBPr=r, SBPc=c, test=TRUE)
### Classical approach,
### generalized linear mixed effect model.
if (FALSE) {
library(lme4)
glmer(value~output*as.factor(isic)+(1|country),data=manu_abs,family=poisson)
}
Run the code above in your browser using DataLab