-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
213afad
commit 0612b1b
Showing
24 changed files
with
383 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
Package: sirt | ||
Type: Package | ||
Title: Supplementary Item Response Theory Models | ||
Version: 3.10-79 | ||
Date: 2021-03-09 13:01:29 | ||
Version: 3.10-91 | ||
Date: 2021-04-02 14:53:21 | ||
Author: Alexander Robitzsch [aut,cre] (<https://orcid.org/0000-0002-8226-3132>) | ||
Maintainer: Alexander Robitzsch <[email protected]> | ||
Description: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
## File Name: dif.strata.variance.R | ||
## File Version: 0.14 | ||
|
||
|
||
|
||
#* stratified DIF variance | ||
dif.strata.variance <- function( dif, se.dif, itemcluster ) | ||
{ | ||
# stratified DIF variance | ||
# means in differential item functioning | ||
# itemcluster is a vector of strata corresponding to items | ||
stratadif <- stats::aggregate( 1+0*dif, list(itemcluster), sum, na.rm=TRUE ) | ||
colnames(stratadif) <- c("strata", "N.Items" ) | ||
stratadif <- data.frame(stratadif) | ||
stratadif$M.DIF <- stats::aggregate( dif, list(itemcluster), mean, na.rm=TRUE )[,2] | ||
# DIF in strata | ||
SS <- nrow(stratadif) | ||
for (ss in 1:SS){ | ||
items.ss <- which( itemcluster==stratadif[ss,"strata"] ) | ||
dif.ss <- dif[ items.ss ] | ||
difv.ss <- dif.variance( dif=dif.ss, se.dif=se.dif[ items.ss ] ) | ||
stratadif$weighted.tau[ss] <- difv.ss$weighted.DIFSD | ||
stratadif$unweighted.tau[ss] <- difv.ss$unweighted.DIFSD | ||
} | ||
stratadif[ is.na(stratadif ) ] <- 0 | ||
|
||
sd_ni1 <- stratadif$N.Items-1 | ||
weighted.DIFSD <- sum(stratadif$N.Items/sum(stratadif$N.Items)*stratadif$weighted.tau) | ||
unweighted.DIFSD <- sum( sd_ni1/ (sum(stratadif$N.Items)-1)*stratadif$unweighted.tau) | ||
|
||
#-- output | ||
res <- list( stratadif=stratadif, weighted.DIFSD=weighted.DIFSD, | ||
unweighted.DIFSD=unweighted.DIFSD) | ||
return(res) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,33 @@ | ||
## File Name: dif.variance.R | ||
## File Version: 0.18 | ||
## File Version: 0.193 | ||
|
||
|
||
#-------------------------------------------------------------------------# | ||
# Routine for calculating DIF variance (Camilli & Penfield, 1997) # | ||
dif.variance <- function( dif, se.dif, items=paste("item",1:length(dif),sep="") ){ | ||
# calculating the weights | ||
wi <- 1/se.dif^2 | ||
# mean DIF | ||
md <- mean(dif) | ||
# weighted tau2 estimator | ||
# formula (5) of PENFIELD & ALGINA (2006) | ||
weighted.tauq <- sum( wi^2 * ( dif - md )^2 - wi ) / sum( wi^2 ) | ||
# unweighted tau2 estimator | ||
# formula (5) of PENFIELD & ALGINA (2006) | ||
unweighted.tauq <- sum( ( dif - md )^2 - se.dif^2 ) / ( length(items) - 1 ) | ||
# calculation of variances v_i | ||
vi <- weighted.tauq + se.dif^2 | ||
weighted.tauq[ weighted.tauq < 0 ] <- 0 | ||
unweighted.tauq[ unweighted.tauq < 0 ] <- 0 | ||
# Empirical Bayes DIF estimate | ||
lambda.i <- weighted.tauq / vi | ||
eb.dif <- lambda.i * ( dif - md ) + ( 1 - lambda.i) *md | ||
list( weighted.DIFSD=sqrt(weighted.tauq), | ||
unweighted.DIFSD=sqrt(unweighted.tauq), | ||
mean.se.dif=sqrt( mean( se.dif^2 ) ), eb.dif=eb.dif ) | ||
} | ||
#-------------------------------------------------------------------------# | ||
|
||
#*** Routine for calculating DIF variance (Camilli & Penfield, 1997) # | ||
dif.variance <- function( dif, se.dif, items=paste("item",1:length(dif),sep="") ) | ||
{ | ||
# calculating the weights | ||
wi <- 1/se.dif^2 | ||
# mean DIF | ||
md <- mean(dif) | ||
# weighted tau2 estimator | ||
# formula (5) of PENFIELD & ALGINA (2006) | ||
weighted.tauq <- sum( wi^2 * ( dif - md )^2 - wi ) / sum( wi^2 ) | ||
# unweighted tau2 estimator | ||
# formula (5) of PENFIELD & ALGINA (2006) | ||
unweighted.tauq <- sum( ( dif - md )^2 - se.dif^2 ) / ( length(items) - 1 ) | ||
# calculation of variances v_i | ||
vi <- weighted.tauq + se.dif^2 | ||
weighted.tauq[ weighted.tauq < 0 ] <- 0 | ||
unweighted.tauq[ unweighted.tauq < 0 ] <- 0 | ||
# Empirical Bayes DIF estimate | ||
lambda.i <- weighted.tauq / vi | ||
eb.dif <- lambda.i * ( dif - md ) + ( 1 - lambda.i) *md | ||
|
||
################################################################################# | ||
dif.strata.variance <- function( dif, se.dif, itemcluster ){ | ||
# stratified DIF variance | ||
# means in differential item functioning | ||
# itemcluster is a vector of strata corresponding to items | ||
stratadif <- stats::aggregate( 1+0*dif, list( itemcluster ), sum, na.rm=T ) | ||
colnames(stratadif) <- c("strata", "N.Items" ) | ||
stratadif <- data.frame(stratadif) | ||
stratadif$M.DIF <- stats::aggregate( dif, list( itemcluster ), mean, na.rm=T )[,2] | ||
# DIF in strata | ||
SS <- nrow(stratadif) | ||
for (ss in 1:SS){ | ||
# ss <- 1 | ||
items.ss <- which( itemcluster==stratadif[ss,"strata"] ) | ||
dif.ss <- dif[ items.ss ] | ||
difv.ss <- dif.variance( dif=dif.ss, se.dif=se.dif[ items.ss ] ) | ||
stratadif$weighted.tau[ss] <- difv.ss$weighted.DIFSD | ||
stratadif$unweighted.tau[ss] <- difv.ss$unweighted.DIFSD | ||
} | ||
stratadif[ is.na(stratadif ) ] <- 0 | ||
res <- list( "stratadif"=stratadif, | ||
"weighted.DIFSD"=sum( stratadif$N.Items / sum( stratadif$N.Items ) * | ||
stratadif$weighted.tau ), | ||
"unweighted.DIFSD"=sum( | ||
( stratadif$N.Items -1 )/ ( sum( stratadif$N.Items ) - 1) * stratadif$unweighted.tau ) | ||
) | ||
#* output | ||
res <- list( weighted.DIFSD=sqrt(weighted.tauq), | ||
unweighted.DIFSD=sqrt(unweighted.tauq), | ||
mean.se.dif=sqrt( mean( se.dif^2 ) ), eb.dif=eb.dif ) | ||
return(res) | ||
} | ||
################################################################################# | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,42 @@ | ||
## File Name: fuzcluster.R | ||
## File Version: 0.15 | ||
## File Version: 0.163 | ||
|
||
#********************************************* | ||
# Clustering for continuous fuzzy data | ||
|
||
#*** Clustering for continuous fuzzy data | ||
fuzcluster <- function(dat_m, dat_s, K=2, nstarts=7, | ||
seed=NULL, maxiter=100, parmconv=.001, | ||
fac.oldxsi=0.75, progress=TRUE ){ | ||
seed=NULL, maxiter=100, parmconv=.001, fac.oldxsi=0.75, progress=TRUE ) | ||
{ | ||
s1 <- Sys.time() | ||
dev0 <- 10^(200) | ||
dev0 <- 1e200 | ||
dat_resp <- 1 - is.na(dat_m) | ||
if ( ! is.null(seed) ){ nstarts <- 1 } | ||
if ( ! is.null(seed) ){ | ||
nstarts <- 1 | ||
} | ||
for ( rr in 1:nstarts ){ | ||
res1 <- fuzcluster_estimate(K, dat_m, dat_s, dat_resp, | ||
maxiter=maxiter, parmconv=parmconv, progress=progress, | ||
seed=seed, fac.oldxsi=fac.oldxsi) | ||
maxiter=maxiter, parmconv=parmconv, progress=progress, | ||
seed=seed, fac.oldxsi=fac.oldxsi) | ||
if ( res1$deviance < dev0 ){ | ||
res <- res1 | ||
dev0 <- res1$deviance | ||
} | ||
} | ||
} | ||
} | ||
s2 <- Sys.time() | ||
### end random starts | ||
### computation of information criteria | ||
dev <- res$deviance | ||
ic <- list( "deviance"=dev, "n"=nrow(dat_m) ) | ||
ic <- list( deviance=dev, n=nrow(dat_m) ) | ||
I <- ncol(dat_m) | ||
ic$np <- (K-1) + 2*K*I | ||
# AIC | ||
ic$AIC <- dev + 2*ic$np | ||
# BIC | ||
ic$BIC <- dev + ( log(ic$n) )*ic$np | ||
# CAIC (conistent AIC) | ||
ic$CAIC <- dev + ( log(ic$n) + 1 )*ic$np | ||
# corrected AIC | ||
ic$AICc <- ic$AIC + 2*ic$np * ( ic$np + 1 ) / ( ic$n - ic$np - 1 ) | ||
ic$AIC <- dev + 2*ic$np | ||
ic$BIC <- dev + ( log(ic$n) )*ic$np | ||
ic$CAIC <- dev + ( log(ic$n) + 1 )*ic$np | ||
ic$AICc <- ic$AIC + 2*ic$np * ( ic$np + 1 ) / ( ic$n - ic$np - 1 ) | ||
res$ic <- ic | ||
res$K <- K | ||
res$s1 <- s1 | ||
res$s2 <- s2 | ||
res$nstarts <- nstarts | ||
class(res) <- "fuzcluster" | ||
### | ||
return(res) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.