Sei sulla pagina 1di 9

In the spotlight: Uncovering unobserved groups in your

data with fmm


Often, data come from distinct and observable groups such as males and females, single and
married, or new and old manufacturing processes. If these groups behave differently, we
observe heterogeneity in the data.

But in many cases we cannot observe groups directly. Examples include individuals with
good and poor health, risk-averse and risk-seeking investors, and apples from different
orchards.

Here I show one way of addressing unobserved heterogeneity with finite mixture models.

We have data on individuals' standardized cholesterol levels (chol) and their mean-centered
monthly red wine consumption (wine).

A linear fit line superimposed on the scatterplot of the data suggests there is a positive
relationship between the two.

En el centro de atencin: descubriendo grupos no observados en sus datos


con fmm

Con frecuencia, los datos provienen de grupos distintos y observables, como


hombres y mujeres, solteros y casados, o procesos de fabricacin nuevos y
antiguos. Si estos grupos se comportan de manera diferente, observamos
heterogeneidad en los datos.
Pero en muchos casos no podemos observar grupos directamente. Los ejemplos
incluyen individuos con buena y mala salud, inversores con aversin al
riesgo y bsqueda de riesgo, y manzanas de diferentes huertos.
Aqu muestro una forma de abordar la heterogeneidad no observada con
modelos de mezclas finitas.

Tenemos datos sobre los niveles de colesterol estandarizados (chol) de las


personas y su consumo mensual de vino tinto (vino) centrado en la media.

Una lnea de ajuste lineal superpuesta a la grfica de dispersin de los


datos sugiere que existe una relacin positiva entre los dos.
And a simple regression model confirms the positive relationship.

. regress chol wine

chol Coef. Std. Err. t P>|t| [95% Conf. Interval]

wine .7243775 .0553511 13.09 0.000 .6158387 .8329162


_cons .2408989 .0267081 9.02 0.000 .1885266 .2932712

Let's see what happens when we add to our model a variable recording whether either parent
had high cholesterol (pchol).

Veamos qu sucede cuando agregamos a nuestro modelo una variable que


registra si cualquiera de los padres tena colesterol alto (pchol).

. regress chol wine pchol

chol Coef. Std. Err. t P>|t| [95% Conf. Interval]

wine -.1469443 .0632583 -2.32 0.020 -.2709885 -.0229001


pchol .5037735 .0221205 22.77 0.000 .4603971 .54715
_cons -.0488678 .0274366 -1.78 0.075 -.1026686 .004933

Now we find that wine consumption has a slight negative effect on cholesterol and that
parents' cholesterol has a positive effect.

We hypothesize that an individual may inherit a "high cholesterol" gene and that we have two
types of individuals in the populationthose with the cholesterol gene and those without.
However, we do not know who belongs to each group.

We use fmm to probabilistically classify the sample into groups. By adding the fmm prefix
followed by 2, we indicate that we want to fit a model for two underlying subpopulations. We
use the lcprob(pchol) option to include parents' cholesterol history as the predictor of the
unobserved group, also called the latent class.

Ahora descubrimos que el consumo de vino tiene un ligero efecto negativo


sobre el colesterol y que el colesterol de los padres tiene un efecto
positivo.
Nuestra hiptesis es que un individuo puede heredar un gen de "colesterol
alto" y que tenemos dos tipos de individuos en la poblacin: los que tienen
el gen del colesterol y los que no. Sin embargo, no sabemos quin pertenece
a cada grupo.
Usamos fmm para clasificar de manera probabilstica la muestra en grupos.
Al agregar el prefijo fmm seguido de 2, indicamos que queremos ajustar un
modelo para dos subpoblaciones subyacentes. Usamos la opcin lcprob (pchol)
para incluir el historial de colesterol de los padres como el predictor del
grupo no observado, tambin llamado clase latente.

. fmm 2, lcprob(pchol): regress chol wine

The output below shows a regression model for each class. Wine consumption has a negative
effect on cholesterol level in each class.

El resultado a continuacin muestra un modelo de regresin para cada clase.


El consumo de vino tiene un efecto negativo en el nivel de colesterol en
cada clase.

Class : 1

Response : chol
Model : regress

Coef. Std. Err. z P>|z| [95% Conf. Interval]

chol
wine -.6850974 .0783981 -8.74 0.000 -.8387549 -.5314399
_cons -.7401758 .0443478 -16.69 0.000 -.8270959 -.6532557

var(e.chol) .6152073 .0219867 .5735887 .6598457


Class : 2
Response : chol
Model : regress

Coef. Std. Err. z P>|z| [95% Conf. Interval]

chol
wine -.4798618 .1319125 -3.64 0.000 -.7384056 -.221318
_cons .8343004 .0323813 25.76 0.000 .7708342 .8977667

var(e.chol) .6720669 .0383181 .601009 .7515261

The table below gives the coefficients for the latent class membership on the logit scale.

La siguiente tabla muestra los coeficientes para la membresa de clase


latente en la escala logit.

Coef. Std. Err. z P>|z| [95% Conf. Interval]

1.Class (base outcome)

2.Class
pchol 7.473592 .8977705 8.32 0.000 5.713994 9.23319
_cons -3.228661 .3939579 -8.20 0.000 -4.000804 -2.456518

We use estat lcprob to display marginal class probabilities on the probability scale.

Usamos estat lcprob para mostrar las probabilidades marginales de clase en


la escala de probabilidad.

. estat lcprob

Delta-method
Margin Std. Err. [95% Conf. Interval]

Class
1 .6743291 .0055936 .6632719 .6851956
2 .3256709 .0055936 .3148044 .3367281
About 67% of individuals are expected to be in group 1 and 33% in group 2. But which group
is which? To find out, we use estat lcmean to calculate the marginal means for each class.
The reported mean for class 1 is lower than the reported mean for class 2. Therefore, class 1
corresponds to individuals with no cholesterol gene, and class 2 to those with the gene.

Se espera que aproximadamente el 67% de las personas estn en el grupo 1 y


el 33% en el grupo 2. Pero, qu grupo es cul? Para averiguarlo, usamos
estat lcmean para calcular los medios marginales para cada clase. La media
informada para la clase 1 es menor que la media informada para la clase 2.
Por lo tanto, la clase 1 corresponde a las personas sin gen de colesterol y
la clase 2 a las que tienen el gen.

. estat lcmean

Delta-method
Margin Std. Err. z P>|z| [95% Conf. Interval]

1
chol -.5123399 .024033 -21.32 0.000 -.5594438 -.465236

2
chol .9938833 .0601744 16.52 0.000 .8759435 1.111823

We can even classify the individuals in our dataset into the two groups by predicting
posterior latent-class probabilities and using a cutpoint (we will use 0.5) to assign each
observation to a group.

Incluso podemos clasificar a los individuos de nuestro conjunto de datos en


los dos grupos al predecir las probabilidades de la clase latente posterior
y usar un punto de corte (utilizaremos 0.5) para asignar cada observacin a
un grupo.

. predict c1, classposteriorpr

. summarize c2

Variable Obs Mean Std. Dev. Min Max

c1 2,500 .6743291 .4538173 6.22e-09 1

. generate lgroup = c1 < 0.5

. tabulate lgroup
lgroup Freq. Percent Cum.

0 1,690 67.60 67.60


1 810 32.40 100.00

Total 2,500 100.00

From the tabulation of predicted group membership, we see that our classification is close to
the output produced by estat lcprob above.

Finally, we draw a scatterplot with the linear fit line for each group.

De la tabulacin de la membresa del grupo predicho, vemos que nuestra


clasificacin est cerca de la salida producida por estat lcprob arriba.
Finalmente, dibujamos un diagrama de dispersin con la lnea de ajuste
lineal para cada grupo.
Some of you may recognize this graph as an illustration of Simpson's paradox, where a trend
present in the data reverses when the data are divided into

Algunos de ustedes pueden reconocer este grfico como una ilustracin de la


paradoja de Simpson, donde una tendencia presente en los datos se invierte
cuando los datos se dividen en subgrupos.

In the spotlight: Nonlinear multilevel mixed-effects models


You have a model that is nonlinear in the parameters. Perhaps it is a model of tree growth and
therefore asymptotes to a maximum value. Perhaps it is a model of serum concentrations of a
drug that rise rapidly to a peak concentration and then decay exponentially. Easy enough: use
nonlinear regression ([R] nl) to fit your model. But ... what if you have repeated measures for
each tree or repeated blood serum levels for each patient? You might like to account for the
correlation within tree or patient. You might even believe that each tree has its own
asymptotic growth. You need nonlinear mixed-effects modelsalso called nonlinear
hierarchical models or nonlinear multilevel models.

Stata 15's new menl command can handle everything described above and much more. In my
recent blog post, I walk you through a few examples and demonstrate how to use Stata to fit
nonlinear models to multilevel data, including repeated-measures data or panel data.

Houssein Assaad
Senior Statistician and Software Developer

En el centro de atencin: modelos no lineales multinivel de efectos mixtos


Tienes un modelo que no es lineal en los parmetros. Tal vez sea un modelo
de crecimiento de los rboles y, por lo tanto, asntotas hasta un valor
mximo. Tal vez es un modelo de concentraciones sricas de un medicamento
que aumenta rpidamente a una concentracin mxima y luego se descompone
exponencialmente. Lo suficientemente fcil: use la regresin no lineal ([R]
nl) para adaptarse a su modelo. Pero ... qu pasa si tiene medidas
repetidas para cada rbol o niveles de suero sanguneo repetidos para cada
paciente? Es posible que desee contabilizar la correlacin dentro del rbol
o paciente. Incluso podra creer que cada rbol tiene su propio crecimiento
asinttico. Necesita modelos de efectos mixtos no lineales, tambin
llamados modelos jerrquicos no lineales o modelos multinivel no lineales.
El nuevo comando menl de Stata 15 puede manejar todo lo descrito
anteriormente y mucho ms. En mi publicacin reciente en el blog, lo guo a
travs de algunos ejemplos y le enseo cmo usar Stata para adaptar modelos
no lineales a datos multinivel, incluidos datos de mediciones repetidas o
datos de panel.
- Houssein Assaad
Desarrollador Senior de Estadstica y Software

Potrebbero piacerti anche