Skip to content

Commit

Permalink
4.3-2
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderrobitzsch committed Feb 19, 2024
1 parent b74dcfb commit 65d709b
Show file tree
Hide file tree
Showing 18 changed files with 107 additions and 64 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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] (<https://orcid.org/0000-0002-8226-3132>),
Thomas Kiefer [aut],
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions R/IRT.itemfit.R
Original file line number Diff line number Diff line change
@@ -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))
Expand All @@ -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") ){
Expand Down
14 changes: 8 additions & 6 deletions R/IRT.modelfit.tam.R → R/IRT_modelfit_TAM.R
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -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

Expand Down
6 changes: 2 additions & 4 deletions R/designMatrices_aux.R
Original file line number Diff line number Diff line change
@@ -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 )
Expand Down
51 changes: 35 additions & 16 deletions R/tam.mml.wle2.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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] )
Expand All @@ -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)
}
5 changes: 3 additions & 2 deletions R/tam_rbind_twomatrices.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## File Name: tam_rbind_twomatrices.R
## File Version: 9.06
## File Version: 9.071

#########################################
# bind two matrices
Expand All @@ -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
12 changes: 7 additions & 5 deletions R/tampv2datalist.R
Original file line number Diff line number Diff line change
@@ -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) ){
Expand All @@ -39,4 +41,4 @@ tampv2datalist <- function( tam.pv.object, pvnames=NULL, Y=NULL,

return(datalist)
}
##################################################################

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)&#160;&#160;
[![](https://img.shields.io/badge/github%20version-4.3--2-orange.svg)](https://github.com/alexanderrobitzsch/TAM)&#160;&#160;

The version hosted [here](https://github.com/alexanderrobitzsch/TAM) is the development version of `TAM`.
The GitHub version can be installed using `devtools` as
Expand Down
2 changes: 1 addition & 1 deletion inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -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) ,
Expand Down
27 changes: 21 additions & 6 deletions inst/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------------------------------------------------------
Expand Down
10 changes: 7 additions & 3 deletions man/designMatrices.Rd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%% File Name: designMatrices.Rd
%% File Version: 2.222
%% File Version: 2.228

\name{designMatrices}

Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}}, ~~~


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
Loading

0 comments on commit 65d709b

Please sign in to comment.