Fast estimation of multinomial (MNL) and mixed logit (MXL) models in R with "Preference" space or "Willingness-to-pay" (WTP) space utility parameterizations in R
I've been trying to use nnets multinom' for my problem but logitr seems like a much better approach, but I'd be grateful to get some help on usage.
My problem comes from single-cell sequencing in biology. In our experiment we take an organ, such as the spleen, from several animals (samples: biological replicates) with covariates (e.g., a categorical variable such as age with two levels: young and 'old) and we dissociate it to its single cells, and then we profile the gene expression in each of these cells, such that the readout data (after some processing and analyzing), is a table with these columns:
cell_ID: a barcode of the cell (an integer equivalent to the id variable in the yogurt data)
cell_type: a label of the biological cell type of the cell (e.g., CD4 T cell, which is equivalent to the choice variable in the yogurt data, and hence all possible cell types would be equivalent to the alt variable in the yogurt data)
sample_ID: the animal's label, which would be a random effect variable
age: the animal's age, which would be a fixed effect variable
So these are clearly compositional data because in each sample we get a distribution of cells across the cell_types, which sum up to 100%.
My goal is to test for age effects in each of the cell_types, or in other words wether the estimated old/young ratio in each cell_type is different from 1.
In my data I have a total of 38168 cells from three young samples and four old samples, each assigned to one of five different cell_types.
I constructed the input data.frame such that id is an integer that encodes cell, obsID is identical to id because a cell is only observed once and hence assigned to a single cell_type once, alt encodes cell_type, choice has a value of 1 to the cell_type of cell and 0 for all other 4 cell_type's, and then age and sample_ID are factors.
Here are the two first ids in the input data.frame:
id obsID alt choice age sample
1 1 NKT.cell 1 young young_2
1 1 CD4.T.cell 0 young young_2
1 1 CD8.T.cell 0 young young_2
1 1 Treg 0 young young_2
1 1 NK.cell 0 young young_2
2 2 NKT.cell 0 young young_2
2 2 CD4.T.cell 1 young young_2
2 2 CD8.T.cell 0 young young_2
2 2 Treg 0 young young_2
2 2 NK.cell 0 young young_2
The output only reports on the age and sample coefficients but not on alt.
So my question is if it is actually possible to the age effect for each alt? I guess it'd be an interaction between alt and age but I don't see how that can be specified to logitr.
Hi,
I've been trying to use
nnet
smultinom'
for my problem butlogitr
seems like a much better approach, but I'd be grateful to get some help on usage.My problem comes from single-cell sequencing in biology. In our experiment we take an organ, such as the spleen, from several animals (samples: biological replicates) with covariates (e.g., a categorical variable such as age with two levels:
young
and'old
) and we dissociate it to its single cells, and then we profile the gene expression in each of these cells, such that the readout data (after some processing and analyzing), is a table with these columns:cell_ID
: a barcode of the cell (an integer equivalent to theid
variable in theyogurt
data)cell_type
: a label of the biological cell type of the cell (e.g., CD4 T cell, which is equivalent to thechoice
variable in theyogurt
data, and hence all possible cell types would be equivalent to thealt
variable in theyogurt
data)sample_ID
: the animal's label, which would be a random effect variableage
: the animal's age, which would be a fixed effect variableSo these are clearly compositional data because in each sample we get a distribution of cells across the
cell_type
s, which sum up to 100%.My goal is to test for age effects in each of the
cell_type
s, or in other words wether the estimatedold
/young
ratio in eachcell_type
is different from 1.In my data I have a total of 38168
cell
s from threeyoung
samples and fourold
samples, each assigned to one of five differentcell_type
s.I constructed the input
data.frame
such thatid
is an integer that encodescell
,obsID
is identical toid
because acell
is only observed once and hence assigned to a singlecell_type
once,alt
encodescell_type
,choice
has a value of 1 to thecell_type
ofcell
and 0 for all other 4cell_type
's, and thenage
andsample_ID
arefactor
s.Here are the two first
id
s in the inputdata.frame
:Then I run this
logitr
model command:The output only reports on the
age
andsample
coefficients but not onalt
.So my question is if it is actually possible to the
age
effect for eachalt
? I guess it'd be an interaction betweenalt
andage
but I don't see how that can be specified tologitr
.Thanks a lot