diff --git a/DESCRIPTION b/DESCRIPTION index 9460deb..7d24546 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: TAM Type: Package Title: Test Analysis Modules -Version: 4.2-11 -Date: 2023-08-28 17:23:17.934842 +Version: 4.3-2 +Date: 2024-02-20 00:16:18 Author: Alexander Robitzsch [aut,cre] (), Thomas Kiefer [aut], @@ -37,4 +37,4 @@ License: GPL (>= 2) URL: http://www.edmeasurementsurveys.com/TAM/Tutorials/, https://github.com/alexanderrobitzsch/TAM, - https://sites.google.com/site/alexanderrobitzsch2/software + https://sites.google.com/view/alexander-robitzsch/software diff --git a/NAMESPACE b/NAMESPACE index 1544154..bfd13db 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -295,6 +295,7 @@ S3method(plot, tam.pv.mcmc) S3method(predict, tam.mml) S3method(predict, tam.mml.3pl) S3method(predict, tamaan) +S3method(print, designMatrices) S3method(print, IRT.threshold) S3method(print, tam) S3method(print, tam_linking_2studies) diff --git a/R/IRT.itemfit.R b/R/IRT.itemfit.R index abdfe97..59cb9e9 100644 --- a/R/IRT.itemfit.R +++ b/R/IRT.itemfit.R @@ -1,14 +1,14 @@ ## File Name: IRT.itemfit.R -## File Version: 9.08 +## File Version: 9.091 ########################################################################### -IRT.itemfit.rmsea.default <- function( object ) +IRT_itemfit_rmsea_default <- function(object) { mod1 <- object - probs <- IRT.irfprob( mod1 ) - n.ik <- IRT.expectedCounts( mod1 ) - pi.k <- attr( probs, "prob.theta") - if ( is.vector( pi.k) ){ + probs <- IRT.irfprob(mod1) + n.ik <- IRT.expectedCounts(mod1) + pi.k <- attr(probs, "prob.theta") + if ( is.vector(pi.k) ){ pi.k <- matrix( pi.k, ncol=1 ) } n.ik <- aperm( n.ik, c(3,1,2,4)) @@ -17,7 +17,7 @@ IRT.itemfit.rmsea.default <- function( object ) return(res) } ########################################################################### -IRT.itemfit.tam.default <- function( object, method="RMSD", ... ) +IRT.itemfit.tam.default <- function(object, method="RMSD", ... ) { res <- NULL if ( method %in% c("RMSD","rmsea") ){ diff --git a/R/IRT.modelfit.tam.R b/R/IRT_modelfit_TAM.R similarity index 84% rename from R/IRT.modelfit.tam.R rename to R/IRT_modelfit_TAM.R index e27c53b..c460dc2 100644 --- a/R/IRT.modelfit.tam.R +++ b/R/IRT_modelfit_TAM.R @@ -1,9 +1,9 @@ -## File Name: IRT.modelfit.tam.R -## File Version: 9.06 +## File Name: IRT_modelfit_TAM.R +## File Version: 9.122 ########################################################### # general model fit function for TAM objects -IRT.modelfit.TAM <- function( object, mod ) +IRT_modelfit_TAM <- function( object, mod ) { res <- tam.modelfit( object ) res$IRT.IC <- IRT.IC(object) @@ -18,7 +18,7 @@ IRT.modelfit.TAM <- function( object, mod ) IRT.modelfit.tam.mml <- function( object, ... ) { cl <- paste(match.call())[2] - res <- IRT.modelfit.TAM( object, mod=cl ) + res <- IRT_modelfit_TAM( object, mod=cl ) return(res) } IRT.modelfit.tam.mml.3pl <- IRT.modelfit.tam.mml @@ -34,9 +34,11 @@ summary.IRT.modelfit.TAM.helper <- function( object, ... ) print(obji) cat("\nFit Statistics\n") obji <- object$statlist - for (vv in seq(1,ncol(obji))){ obji[,vv] <- round( obji[,vv], 3 ) } + for (vv in seq(1,ncol(obji))){ + obji[,vv] <- round( obji[,vv], 3 ) + } print(obji) - } +} ################################################################# summary.IRT.modelfit.tam.mml <- summary.IRT.modelfit.TAM.helper diff --git a/R/RcppExports.R b/R/RcppExports.R index 9cacc60..ef6beb1 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -1,5 +1,5 @@ ## File Name: RcppExports.R -## File Version: 4.002011 +## File Version: 4.003002 # Generated by using Rcpp::compileAttributes() -> do not edit by hand # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 diff --git a/R/designMatrices_aux.R b/R/designMatrices_aux.R index 064018c..2dbc077 100644 --- a/R/designMatrices_aux.R +++ b/R/designMatrices_aux.R @@ -1,10 +1,8 @@ ## File Name: designMatrices_aux.R -## File Version: 9.104 +## File Version: 9.105 ############################################################# -print.designMatrices <- - function( X, ... ){ - x <- X +print.designMatrices <- function( x, ... ){ BB <- x$flatB colnames(BB) <- paste("B_", colnames(BB), sep="") out <- cbind( x$flatA, BB ) diff --git a/R/tam.mml.wle2.R b/R/tam.mml.wle2.R index 9f11b95..07b1112 100644 --- a/R/tam.mml.wle2.R +++ b/R/tam.mml.wle2.R @@ -1,11 +1,13 @@ ## File Name: tam.mml.wle2.R -## File Version: 0.853 +## File Version: 0.869 ################################################################ tam.mml.wle2 <- function( tamobj, score.resp=NULL, WLE=TRUE, adj=.3, Msteps=20, - convM=.0001, progress=TRUE, output.prob=FALSE, pid=NULL ) + convM=.0001, progress=TRUE, output.prob=FALSE, pid=NULL, + theta_init=NULL) { CALL <- match.call() + iweights <- NULL #--- process input data res <- tam_mml_wle_proc_input_data( tamobj=tamobj, score.resp=score.resp ) AXsi <- res$AXsi @@ -37,23 +39,33 @@ tam.mml.wle2 <- function( tamobj, score.resp=NULL, WLE=TRUE, adj=.3, Msteps=20, col.index <- rep( 1:nitems, each=maxK ) cResp <- resp[, col.index ]*resp.ind[, col.index ] cResp <- 1 * t( t(cResp)==rep(0:(maxK-1), nitems) ) - cB <- t( matrix( aperm( B, c(2,1,3) ), nrow=dim(B)[3], byrow=TRUE ) ) + if (!is.null(iweights)){ + B1 <- B*iweights + } else { + B1 <- B + iweights <- rep(1, nitems) + } + + cB <- t( matrix( aperm( B1, c(2,1,3) ), nrow=dim(B)[3], byrow=TRUE ) ) cB[is.na(cB)] <- 0 #Compute person sufficient statistics (total score on each dimension) PersonScores <- cResp %*% cB #Compute possible maximum score for each item on each dimension - maxBi <- apply(B, 3, tam_rowMaxs, na.rm=TRUE) + maxBi <- apply(B1, 3, tam_rowMaxs, na.rm=TRUE) + #Compute possible maximum score for each person on each dimension PersonMax <- resp.ind %*% maxBi PersonMax[ PersonMax==0 ] <- 2 * adj #Adjust perfect scores for each person on each dimension - PersonScores[PersonScores==PersonMax] <- PersonScores[PersonScores==PersonMax] - adj + ind_max <- which(PersonScores==PersonMax) + PersonScores[ind_max] <- PersonScores[ind_max] - adj #Adjust zero scores for each person on each dimension - PersonScores[PersonScores==0] <- PersonScores[PersonScores==0] + adj + ind0 <- which(PersonScores==0) + PersonScores[ind0] <- PersonScores[ind0] + adj #Calculate Axsi. Only need to do this once. # for (i in 1:nitems) { @@ -63,7 +75,12 @@ tam.mml.wle2 <- function( tamobj, score.resp=NULL, WLE=TRUE, adj=.3, Msteps=20, # } #Initialise theta (WLE) values for all students - theta <- log((PersonScores+.5)/(PersonMax-PersonScores+1)) #log of odds ratio of raw score + if (is.null(theta_init)){ + theta <- log((PersonScores+.5)/(PersonMax-PersonScores+1)) + #log of odds ratio of raw score + } else { + theta <- as.matrix( theta_init ) + } ###################################### #Compute WLE @@ -92,12 +109,13 @@ tam.mml.wle2 <- function( tamobj, score.resp=NULL, WLE=TRUE, adj=.3, Msteps=20, xsi=xsi, theta=theta, nnodes=nstud, maxK=maxK, recalc=FALSE, use_rcpp=TRUE, maxcat=max(maxK), avoid_outer=TRUE ) rprobsWLE <- resWLE$rprobs + rprobsWLEL <- matrix(rprobsWLE, nrow=nitems*maxK, ncol=nstud ) rprobsWLEL[is.na(rprobsWLEL)] <- 0 resB <- tam_rcpp_wle_suffstat( RPROBS=rprobsWLEL, CBL=BL, CBB=BBL, - CBBB=BBBL, cndim=ndim, cnitems=nitems, cmaxK=maxK, cnstud=nstud, - resp_ind=resp.ind ) + CBBB=BBBL, cndim=ndim, cnitems=nitems, cmaxK=maxK, + cnstud=nstud, resp_ind=resp.ind ) B_bari <- array(resB$B_bari, dim=c(nstud, nitems,ndim)) BB_bari <- array(resB$BB_bari, dim=c(nstud, nitems, ndim, ndim)) BBB_bari <- array(resB$BBB_bari, dim=c(nstud, nitems, ndim)) @@ -145,7 +163,7 @@ tam.mml.wle2 <- function( tamobj, score.resp=NULL, WLE=TRUE, adj=.3, Msteps=20, # dampening the increment for ( d1 in 1:ndim){ # increment[,d1] <- ifelse( abs(increment[,d1]) > 3, sign( increment[,d1] )*3, increment[,d1] ) - ci <- ceiling( abs(increment[,d1]) / ( abs( old_increment[,d1]) + 10^(-10) ) ) + ci <- ceiling( abs(increment[,d1]) / ( abs( old_increment[,d1]) + 1e-10 ) ) increment[,d1] <- ifelse( abs( increment[,d1]) > abs(old_increment[,d1]), increment[,d1]/(2*ci), increment[,d1] ) @@ -165,15 +183,16 @@ tam.mml.wle2 <- function( tamobj, score.resp=NULL, WLE=TRUE, adj=.3, Msteps=20, Miter <- Miter + 1 if (progress){ - cat( paste( "Iteration in WLE/MLE estimation ", Miter, - " | Maximal change ", round( max(abs(increment)), 4), "\n" ) ) - utils::flush.console() - } + cat( paste( "Iteration in WLE/MLE estimation ", Miter, + " | Maximal change ", round( max(abs(increment)), 4), "\n" )) + utils::flush.console() + } } # end of Newton-Raphson res <- tam_mml_wle_postproc( ndim=ndim, err_inv=err_inv, theta=theta, pid=pid, resp.ind=resp.ind, PersonScores=PersonScores, PersonMax=PersonMax, - adj=adj, WLE=WLE, rprobsWLE=rprobsWLE, output.prob=output.prob, progress=progress, - pweights=pweights, CALL=CALL, B=B, score.resp=score.resp ) + adj=adj, WLE=WLE, rprobsWLE=rprobsWLE, output.prob=output.prob, + progress=progress, pweights=pweights, CALL=CALL, B=B, + score.resp=score.resp ) return(res) } diff --git a/R/tam_rbind_twomatrices.R b/R/tam_rbind_twomatrices.R index 5aef1ac..c6c5952 100644 --- a/R/tam_rbind_twomatrices.R +++ b/R/tam_rbind_twomatrices.R @@ -1,5 +1,5 @@ ## File Name: tam_rbind_twomatrices.R -## File Version: 9.06 +## File Version: 9.071 ######################################### # bind two matrices @@ -13,4 +13,5 @@ tam_rbind_twomatrices <- function(X1, X2){ } ######################################### -rbind.twomatrices <- tam_rbind_twomatrices +# rbind.twomatrices <- tam_rbind_twomatrices +rbind_twomatrices <- tam_rbind_twomatrices diff --git a/R/tampv2datalist.R b/R/tampv2datalist.R index dabb1a0..8297816 100644 --- a/R/tampv2datalist.R +++ b/R/tampv2datalist.R @@ -1,20 +1,22 @@ ## File Name: tampv2datalist.R -## File Version: 9.13 +## File Version: 9.146 -################################################################## +##*** converts a pv object into a list of datasets tampv2datalist <- function( tam.pv.object, pvnames=NULL, Y=NULL, Y.pid="pid", as_mids=FALSE, stringsAsFactors=FALSE ) { pv <- tam.pv.object$pv ndim <- tam.pv.object$ndim nplausible <- tam.pv.object$nplausible - Y00 <- data.frame( "pid"=tam.pv.object$pid, "pweights"=tam.pv.object$pweights, + Y00 <- data.frame( pid=tam.pv.object$pid, pweights=tam.pv.object$pweights, stringsAsFactors=stringsAsFactors ) + if ( ! is.null(Y) ){ Y <- as.data.frame(Y) if( sum( colnames(Y) %in% Y.pid )==0 ){ - Y[, Y.pid] <- seq( 1, nrow(Y) ) + Y[, Y.pid] <- pv$pid + } } if ( is.null(pvnames) ){ @@ -39,4 +41,4 @@ tampv2datalist <- function( tam.pv.object, pvnames=NULL, Y=NULL, return(datalist) } -################################################################## + diff --git a/README.md b/README.md index 552f285..a696d24 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ a minimal runnable code necessary to reproduce the issue, which can be run on th all necessary information on the used librarys, the R version, and the OS it is run on, perhaps a ``sessionInfo()``. -#### CRAN version `TAM` 4.1-4 (2022-08-28) +#### CRAN version `TAM` 4.2-21 (2024-02-19) [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version-last-release/TAM)](https://cran.r-project.org/package=TAM) @@ -21,9 +21,9 @@ The CRAN version can be installed from within R using: utils::install.packages("TAM") ``` -#### GitHub version `TAM` 4.2-11 (2023-08-28) +#### GitHub version `TAM` 4.3-2 (2024-02-20) -[![](https://img.shields.io/badge/github%20version-4.2--11-orange.svg)](https://github.com/alexanderrobitzsch/TAM)   +[![](https://img.shields.io/badge/github%20version-4.3--2-orange.svg)](https://github.com/alexanderrobitzsch/TAM)   The version hosted [here](https://github.com/alexanderrobitzsch/TAM) is the development version of `TAM`. The GitHub version can be installed using `devtools` as diff --git a/inst/CITATION b/inst/CITATION index 72e1780..2653a87 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -26,7 +26,7 @@ citHeader( paste0( "To cite the '", pkg , "' package in publications use:") ) bibentry(key = paste0(pkg, "_", meta$Version), bibtype = "Manual", title = paste0( pkg , ": " , pkg_title ) , - author = personList( person_list1 ), + author = c( person_list1 ), year = year, note = vers, url = paste0( "https://CRAN.R-project.org/package=", pkg) , diff --git a/inst/NEWS b/inst/NEWS index 310fe5c..8d43c08 100644 --- a/inst/NEWS +++ b/inst/NEWS @@ -42,22 +42,37 @@ http://www.edmeasurementsurveys.com/TAM/Tutorials/ ------------------------------------------------------------- -VERSIONS TAM 4.2 | 2023-08-28 | Last: TAM 4.2-11 +VERSIONS TAM 4.3 | 2024-02-20 | Last: TAM 4.3-2 +------------------------------------------------------------- + +xxx * ... + + +DATA * included/modified datasets: --- +EXAMP * included/modified examples: --- + + + + +------------------------------------------------------------- +VERSIONS TAM 4.2 | 2024-02-19 | Last: TAM 4.2-21 ------------------------------------------------------------- NOTE * included output values 'M_post' and 'SD_post' in tam.latreg() FIXED * fixed a bug in tam.fa() due to changes in the GPArotation package (thanks to @StegmannK, @thkiefer, @bernaard; - https://github.com/alexanderrobitzsch/TAM/issues/22) - - + https://github.com/alexanderrobitzsch/TAM/issues/22; + https://github.com/alexanderrobitzsch/TAM/issues/23) +NOTE * included argument 'theta_init' in tam.mml.wle2() to + provide initial theta estimates (which is also available + in tam.wle()) +NOTE * fixed a typo in ?tam.mml (thanks to Nan Wang) +NOTE * minor changes in code due to CRAN requests DATA * included/modified datasets: --- EXAMP * included/modified examples: --- - - ------------------------------------------------------------- VERSIONS TAM 4.1 | 2022-08-28 | Last: TAM 4.1-4 ------------------------------------------------------------- diff --git a/man/designMatrices.Rd b/man/designMatrices.Rd index f08eb4b..a46d471 100644 --- a/man/designMatrices.Rd +++ b/man/designMatrices.Rd @@ -1,5 +1,5 @@ %% File Name: designMatrices.Rd -%% File Version: 2.222 +%% File Version: 2.228 \name{designMatrices} @@ -23,7 +23,7 @@ Generate design matrices, and display them at console. designMatrices(modeltype=c("PCM", "RSM"), maxKi=NULL, resp=resp, ndim=1, A=NULL, B=NULL, Q=NULL, R=NULL, constraint="cases",...) -print.designMatrices(X, ...) +\method{print}{designMatrices}(x, \dots) designMatrices.mfr(resp, formulaA=~ item + item:step, facets=NULL, constraint=c("cases", "items"), ndim=1, Q=NULL, A=NULL, B=NULL, @@ -73,6 +73,10 @@ rownames.design(X) } \item{R}{ This argument is not used +} + \item{x}{ + Object generated by \code{designMatrices}. This argument is used in + \code{print.designMatrices} and \code{rownames.design}. } \item{X}{ Object generated by \code{designMatrices}. This argument is used in @@ -135,8 +139,8 @@ items with differing number of response options. \seealso{ See \code{\link{data.sim.mfr}} for some examples for creating design matrices. -%% ~~objects to See Also as \code{\link{help}}, ~~~ } +%% ~~objects to See Also as \code{\link{help}}, ~~~ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/man/tam.mml.Rd b/man/tam.mml.Rd index 837ff0b..c54cbc5 100644 --- a/man/tam.mml.Rd +++ b/man/tam.mml.Rd @@ -1,5 +1,5 @@ %% File Name: tam.mml.Rd -%% File Version: 2.992 +%% File Version: 2.993 \name{tam.mml} @@ -236,7 +236,7 @@ be printed during iterations. This argument replaces \code{control$progress}. \code{ maxiter=1000, max.increment=1, }\cr \code{ min.variance=.001, progress=TRUE, ridge=0, }\cr \code{ seed=NULL, xsi.start0=0, increment.factor=1, }\cr - \code{ fac.oldxsi=0, acceleration="none", dev_crit="absolute" ) }\cr + \code{ fac.oldxsi=0, acceleration="none", dev_crit="absolute", }\cr \code{ trim_increment="half" ) }\cr \code{nodes}: the discretized \eqn{\theta} nodes for numerical integration diff --git a/man/tam.wle.Rd b/man/tam.wle.Rd index a2ad452..9f4f577 100644 --- a/man/tam.wle.Rd +++ b/man/tam.wle.Rd @@ -1,5 +1,5 @@ %% File Name: tam.wle.Rd -%% File Version: 2.506 +%% File Version: 2.507 \name{tam.wle} @@ -29,7 +29,7 @@ tam.mml.wle( tamobj, score.resp=NULL, WLE=TRUE, adj=.3, Msteps=20, convM=.0001, progress=TRUE, output.prob=FALSE ) tam.mml.wle2(tamobj, score.resp=NULL, WLE=TRUE, adj=0.3, Msteps=20, convM=1e-04, - progress=TRUE, output.prob=FALSE, pid=NULL ) + progress=TRUE, output.prob=FALSE, pid=NULL, theta_init=NULL ) tam_jml_wle(tamobj, resp, resp.ind, A, B, nstud, nitems, maxK, convM, PersonScores, theta, xsi, Msteps, WLE=FALSE, theta.fixed=NULL, progress=FALSE, @@ -73,6 +73,7 @@ tam_jml_wle(tamobj, resp, resp.ind, A, B, nstud, nitems, maxK, convM, \item{output.prob}{Logical indicating whether evaluated probabilities should be included in the list of outputs.} \item{pid}{Optional vector of person identifiers} +\item{theta_init}{Initial theta values} \item{resp}{Data frame with item responses (only for \code{tam.jml.WLE}) } \item{resp.ind}{Data frame with response indicators (only for \code{tam.jml.WLE}) diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 57eb843..ce31d18 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -1,5 +1,5 @@ //// File Name: RcppExports.cpp -//// File Version: 4.002011 +//// File Version: 4.003002 // Generated by using Rcpp::compileAttributes() -> do not edit by hand // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 diff --git a/src/init.c b/src/init.c index 2f2eae4..344f9c8 100644 --- a/src/init.c +++ b/src/init.c @@ -1,5 +1,5 @@ //// File Name: init.c -//// File Version: 4.002011 +//// File Version: 4.003002 #include #include #include // for NULL diff --git a/src/tam_rcpp_wle.cpp b/src/tam_rcpp_wle.cpp index 4ea3a71..b8571e9 100644 --- a/src/tam_rcpp_wle.cpp +++ b/src/tam_rcpp_wle.cpp @@ -1,5 +1,5 @@ //// File Name: tam_rcpp_wle.cpp -//// File Version: 3.453 +//// File Version: 3.461 // [[Rcpp::depends(RcppArmadillo)]]