plot issue in multipleGroup

50 views
Skip to first unread message

Giacomo Mason

unread,
Nov 29, 2016, 7:27:01 AM11/29/16
to mirt-package
Hey Phil,

first of all great package, accessible even to dumb economists like me :)

I'm trying to estimate a Confirmatory Multiple Group model with two groups and two latent dimensions. I've done some EFA to establish the pattern of loadings and decided how to assign each item to each of the two factors. I have 30 items in total: the first 6 I want to use as "anchors" since they are the same in the two groups, and the remaining 24 are specific to either group (so they are NA in the other group). My ultimate aim is to assess the level of "skills" in the two groups, and then score the individuals on both dimensions.

I thus set up and run the model in the following way:

model.syntax <- ('
                  EXT = 1-3, 7-12, 14, 15, 18, 19, 21, 23, 24, 26, 28
                  INT = 4-6, 13, 16, 17, 20, 22, 25, 27, 29, 30
                  CONSTRAINB = (1-3, a1), (4-6, a2), (1-6, d), (7-12, 14, 15, 18, 19, 21, 23, 24, 26, 28, a1), (13, 16, 17, 20, 22, 25, 27, 29, 30, a2), (7-30, d)
                  COV = EXT*INT
                 ')
mod.anch <- multipleGroup(items, model=model.syntax, group=cohort, invariance=c('free_means', 'free_var'), method = 'MHRM') 

Everything runs smoothly, but I get an error when I try to plot anything from the model object (I'm particularly interested in having a look at the trace lines):
> plot(mod.anch, type='trace')
Error: length of the degrees vector not equal to the number of factors

Do you know what might be going wrong? Am I asking mirt something that does not make sense?

Thanks so much!

Giacomo

Phil Chalmers

unread,
Nov 29, 2016, 12:25:24 PM11/29/16
to Giacomo Mason, mirt-package
Hi Giacomo,

Are you certain this occurs with the trace input? It should only be required when computing information-based plots. I see the expected total score functions when I run this example code:

set.seed(12345)
a <- matrix(abs(rnorm(15,1,.3)), ncol=1)
d <- matrix(rnorm(15,0,.7),ncol=1)
itemtype <- rep('dich', nrow(a))
N <- 1000
dataset1 <- simdata(a, d, N, itemtype)
dataset2 <- simdata(a, d, N, itemtype, mu = .1, sigma = matrix(1.5))
dat <- rbind(dataset1, dataset2)
group <- c(rep('D1', N), rep('D2', N))
models <- 'F1 = 1-7
                 F2=8-15'

mod_configural <- multipleGroup(dat, models, group = group)
plot(mod_configural)  #equivalent to type = 'trace'



Thanks so much!

Giacomo

--
You received this message because you are subscribed to the Google Groups "mirt-package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mirt-package+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Giacomo Mason

unread,
Nov 30, 2016, 7:22:46 AM11/30/16
to mirt-package, jackju...@gmail.com
Hi Phil,

thanks for getting back so quick.

I get the same error when I run your code snippet, funnily!

Do you think there might be something wrong with my version of mirt? 

Here's my session info (I'm running everything from RStudio)

R version 3.3.0 (2016-05-03)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.12.1 (unknown)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] hexbin_1.27.1              shiny_0.14.2               cowplot_0.6.2              mirt_1.20.1               
 [5] ggplot2_2.1.0              foreign_0.8-66             random.polychor.pa_1.1.4-2 polycor_0.7-9             
 [9] nFactors_2.3.3             lattice_0.20-33            boot_1.3-18                psych_1.6.6               
[13] MASS_7.3-45               

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.6           git2r_0.15.0          plyr_1.8.4            tools_3.3.0           digest_0.6.10        
 [6] memoise_1.0.0         jsonlite_1.0          nlme_3.1-128          gtable_0.2.0          mgcv_1.8-14          
[11] Matrix_1.2-6          curl_1.2              parallel_3.3.0        mvtnorm_1.0-5         httr_1.2.1           
[16] withr_1.0.2           knitr_1.14            devtools_1.12.0       grid_3.3.0            R6_2.1.3             
[21] GPArotation_2014.11-1 scales_0.4.0          htmltools_0.3.5       sfsmisc_1.1-0         splines_3.3.0        
[26] mnormt_1.5-4          mime_0.5              colorspace_1.2-6      xtable_1.8-2          httpuv_1.3.3         
[31] labeling_0.3          munsell_0.4.3 


Giacomo
Hi Giacomo,


Thanks so much!

Giacomo
To unsubscribe from this group and stop receiving emails from it, send an email to mirt-package...@googlegroups.com.

Phil Chalmers

unread,
Nov 30, 2016, 9:29:23 AM11/30/16
to Giacomo Mason, mirt-package
On Wed, Nov 30, 2016 at 7:22 AM, Giacomo Mason <jackju...@gmail.com> wrote:
Hi Phil,

thanks for getting back so quick.

I get the same error when I run your code snippet, funnily!

Do you think there might be something wrong with my version of mirt? 

Very possible, I've played around with the multiple-group plots in the dev version, and perhaps some of the tweaks fixed this problem. You're welcome to install it to see if it fixes your issue. https://github.com/philchalmers/mirt
 
To unsubscribe from this group and stop receiving emails from it, send an email to mirt-package+unsubscribe@googlegroups.com.

Giacomo Mason

unread,
Nov 30, 2016, 11:18:42 AM11/30/16
to mirt-package, jackju...@gmail.com
Installed from github and works like a charm. Thanks!

Giacomo

Giacomo Mason

unread,
Dec 1, 2016, 7:22:09 AM12/1/16
to mirt-package, jackju...@gmail.com
Hey Phil,

just a followup on this: with the latest github version, the default plot type indeed works. However:
  • type = 'trace' does not produce any output
  • all other plot types seem to give the same error: "Error: length of the degrees vector not equal to the number of factors"
Giacomo

Phil Chalmers

unread,
Dec 1, 2016, 7:34:08 AM12/1/16
to Giacomo Mason, mirt-package
On Thu, Dec 1, 2016 at 7:22 AM, Giacomo Mason <jackju...@gmail.com> wrote:
Hey Phil,

just a followup on this: with the latest github version, the default plot type indeed works. However:
  • type = 'trace' does not produce any output
Looks like an error should have been thrown for 'trace' because it's not yet supported. 
 
  • all other plot types seem to give the same error: "Error: length of the degrees vector not equal to the number of factors"
Pass something like degrees = c(45, 45) to plot().

 
To unsubscribe from this group and stop receiving emails from it, send an email to mirt-package+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages