From 9bdfbd4fe85ba597f7fbedb771d9e8a261cc2214 Mon Sep 17 00:00:00 2001 From: Marianne Corvellec Date: Mon, 15 Oct 2018 20:01:45 +0200 Subject: [PATCH 1/4] Improve minor inconsistencies --- education/dina_independent/dina_independent.Rmd | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/education/dina_independent/dina_independent.Rmd b/education/dina_independent/dina_independent.Rmd index 9356fd7ed..8474e2014 100644 --- a/education/dina_independent/dina_independent.Rmd +++ b/education/dina_independent/dina_independent.Rmd @@ -41,9 +41,9 @@ In educational measurement, cognitive diagnosis models (CDMs) have been used to The *deterministic inputs, noisy "and"" gate* (DINA) model [@Junker2001] is a popular conjunctive CDM, which assumes that a respondent must have mastered all required attributes in order to correctly respond to an item on an assessment. -To estimate respondents' knowledge of attributes, we need information about which attributes are required for each item. For this, we use a Q-matrix which is an $I \times K$ matrix where $q_{ik}$=1 if item $i$ requires attribute $k$ and 0 if not. $I$ is the number of items and $K$ is the number of attributes in the assessment. +To estimate respondents' mastery of attributes, we need information about which attributes are required for each item. For this, we use a Q-matrix which is an $I \times K$ matrix where $q_{ik}$=1 if item $i$ requires attribute $k$ and 0 if not. $I$ is the number of items and $K$ is the number of attributes in the assessment. -A binary latent variable $\alpha_{jk}$ indicates respondent $j$'s knowledge of attribute $k$, where $\alpha_{jk}=1$ if respondent $j$ has mastered attribute $k$ and 0 if he or she has not. Then, an underlying attribute profile of respondent $j$, $\boldsymbol{\alpha_j}$, is a binary vector of length $K$ that indicates whether or not the respondent has mastered each of the $K$ attributes. +A binary latent variable $\alpha_{jk}$ indicates respondent $j$'s mastery of attribute $k$, where $\alpha_{jk}=1$ if respondent $j$ has mastered attribute $k$ and 0 if he or she has not. Then, an underlying attribute profile of respondent $j$, $\boldsymbol{\alpha_j}$, is a binary vector of length $K$ that indicates whether or not the respondent has mastered each of the $K$ attributes. The deterministic element of the DINA model is a latent variable $\xi_{ij}$ that indicates whether or not respondent $j$ has mastered all attributes required for item $i$: $$ @@ -309,7 +309,6 @@ for (k in 1:K){ wanted_pars <- c(paste0("prob_resp_attr[", 1:dina_data_ind$J, ",", k, "]")) # Get predicted posterior probabilities of each attribute mastery for all respondents posterior_prob_attr <- sim_summary[wanted_pars, c("mean")] - dim(posterior_prob_attr) # Calculate mean of the probabilities for respondents who have mastered the attributes and for those who do not table_mean[k,"Group 1"] <- mean(posterior_prob_attr[A[,k]==1]) table_mean[k,"Group 2"] <- mean(posterior_prob_attr[A[,k]==0]) @@ -371,10 +370,10 @@ colnames(alpha_patt) <- paste0("A", 1:5) alpha_patt # Assemble data list for Stan -I=ncol(y) -J=nrow(y) -K=ncol(Q) -C=nrow(alpha_patt) +I <- ncol(y) +J <- nrow(y) +K <- ncol(Q) +C <- nrow(alpha_patt) xi <- matrix(0,I,C) for (i in 1:I){ @@ -449,4 +448,4 @@ ggplot(data=estimates, aes(x=mle, y=post.means, shape=pars)) + geom_point() + g # References - \ No newline at end of file + From a475db43a62ebe022b13f4d0bcbbd4672ed418c1 Mon Sep 17 00:00:00 2001 From: Marianne Corvellec Date: Tue, 16 Oct 2018 12:59:02 +0200 Subject: [PATCH 2/4] Use fresh notation for iteration index --- education/dina_independent/dina_independent.Rmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/education/dina_independent/dina_independent.Rmd b/education/dina_independent/dina_independent.Rmd index 8474e2014..38e91efd4 100644 --- a/education/dina_independent/dina_independent.Rmd +++ b/education/dina_independent/dina_independent.Rmd @@ -110,9 +110,9 @@ $$ \mathrm{Pr}(\alpha_{jk}=1 \, | \, \boldsymbol{y}_j)=\sum_{c=1}^{C}\mathrm{Pr}(\boldsymbol{\alpha_j}=\boldsymbol{\alpha_c} \, | \, \boldsymbol{y}_j)\times\alpha_{ck}. $$ -Instead of conditioning on the parameters $\nu_c,s_i,g_i$ to obtain $\mathrm{Pr}(\boldsymbol{\alpha_j}=\boldsymbol{\alpha_c}|\boldsymbol{Y}_j=\boldsymbol{y}_j)$, we want to derive the posterior probabilities, averaged over the posterior distribution of the parameters. This is achieved by evaluating the expressions above for posterior draws of the parameters and averaging these over the MCMC iterations. Let the vector of all parameters be denoted $\boldsymbol{\theta}$ and let the posterior draw in iteration $s$ be denoted $\boldsymbol{\theta}^{(s)}_{.}$ Then we estimate the posterior probability, not conditioning on the parameters, as +Instead of conditioning on the parameters $\nu_c,s_i,g_i$ to obtain $\mathrm{Pr}(\boldsymbol{\alpha_j}=\boldsymbol{\alpha_c}|\boldsymbol{Y}_j=\boldsymbol{y}_j)$, we want to derive the posterior probabilities, averaged over the posterior distribution of the parameters. This is achieved by evaluating the expressions above for posterior draws of the parameters and averaging these over the MCMC iterations. Let the vector of all parameters be denoted $\boldsymbol{\theta}$ and let the posterior draw in iteration $t$ be denoted $\boldsymbol{\theta}^{(t)}_{.}$ Then we estimate the posterior probability, not conditioning on the parameters, as $$ -\frac{1}{S}\sum_{s=1}^{S}\mathrm{Pr}(\boldsymbol{\alpha_j}=\boldsymbol{\alpha_c} \, | \, \boldsymbol{y}_j,\boldsymbol{\theta}^{(s)}). +\frac{1}{T}\sum_{t=1}^{T}\mathrm{Pr}(\boldsymbol{\alpha_j}=\boldsymbol{\alpha_c} \, | \, \boldsymbol{y}_j,\boldsymbol{\theta}^{(t)}). $$ In [Section 1.4](#stan_nostructure), we introduce the **Stan** program with no structure for $\nu_c$. [Section 2](#stan_ind) describes modification of this **Stan** program to specify the independence model for $\nu_c$ and presents simulation results. From d8c08ffbe908ddc06cf3819c332a15d83085d988 Mon Sep 17 00:00:00 2001 From: Marianne Corvellec Date: Tue, 16 Oct 2018 13:02:44 +0200 Subject: [PATCH 3/4] Remove unnecessary Mac-specific file --- education/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 education/.DS_Store diff --git a/education/.DS_Store b/education/.DS_Store deleted file mode 100644 index 10a68da468bc07c39a2f66ed685e42e0fee6a7fb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKyH3ME5S)V)k)Uu%dB4CPoTBgr`G63SC_(~*P@r~~-_Gm Date: Tue, 16 Oct 2018 13:05:40 +0200 Subject: [PATCH 4/4] Break line which was >80-character-long --- education/dina_independent/dina_independent.Rmd | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/education/dina_independent/dina_independent.Rmd b/education/dina_independent/dina_independent.Rmd index 38e91efd4..ad0fbb12e 100644 --- a/education/dina_independent/dina_independent.Rmd +++ b/education/dina_independent/dina_independent.Rmd @@ -43,7 +43,12 @@ The *deterministic inputs, noisy "and"" gate* (DINA) model [@Junker2001] is a po To estimate respondents' mastery of attributes, we need information about which attributes are required for each item. For this, we use a Q-matrix which is an $I \times K$ matrix where $q_{ik}$=1 if item $i$ requires attribute $k$ and 0 if not. $I$ is the number of items and $K$ is the number of attributes in the assessment. -A binary latent variable $\alpha_{jk}$ indicates respondent $j$'s mastery of attribute $k$, where $\alpha_{jk}=1$ if respondent $j$ has mastered attribute $k$ and 0 if he or she has not. Then, an underlying attribute profile of respondent $j$, $\boldsymbol{\alpha_j}$, is a binary vector of length $K$ that indicates whether or not the respondent has mastered each of the $K$ attributes. +A binary latent variable $\alpha_{jk}$ indicates respondent $j$'s mastery of +attribute $k$, where $\alpha_{jk}=1$ if respondent $j$ has mastered attribute +$k$ and 0 if he or she has not. Then, an underlying attribute profile of +respondent $j$, $\boldsymbol{\alpha_j}$, is a binary vector of length $K$ that +indicates whether or not the respondent has mastered each of the $K$ +attributes. The deterministic element of the DINA model is a latent variable $\xi_{ij}$ that indicates whether or not respondent $j$ has mastered all attributes required for item $i$: $$