Learn R Programming

sirt (version 0.36-30)

R2noharm: Estimation of a NOHARM Analysis from within R

Description

This function enables the estimation of a NOHARM analysis (Fraser & McDonald, 1988; McDonald, 1997) from within R. NOHARM estimates a compensatory multidimensional factor analysis for dichotomous response data. Arguments of this function strictly follows the rules of the NOHARM manual (see Fraser & McDonald, 2012).

Usage

R2noharm(dat, model.type, dimensions = NULL, guesses = rep(0, ncol(dat)), 
	    noharm.path, F.pattern = NULL, F.init = NULL, P.pattern = NULL, 
	    P.init = NULL, digits.pm = 4, writename = NULL, display.fit = 5, 
	    dec = ".", display = TRUE)

## S3 method for class 'R2noharm':
summary(object, logfile=NULL , \dots)

Arguments

dat
An $N \times I$ data frame of item responses for $N$ subjects and $I$ items
model.type
Can be "EFA" (exploratory factor analysis) or "CFA" (confirmatory factor analysis).
dimensions
Number of dimensions in exploratory factor analysis
guesses
Fixed vector of guessing parameters of length $I$. The default is rep(0,ncol(dat)).
noharm.path
Local path where the NOHARM 4 command line 64-bit version is being located.
F.pattern
Pattern matrix for $F$ ($I \times D$)
F.init
Initial matrix for $F$ ($I \times D$)
P.pattern
Pattern matrix for $P$ ($D \times D$)
P.init
Initial matrix for $P$ ($D \times D$)
digits.pm
Number of digits after decimal separator which are used for estimation
writename
Name for NOHARM input and output files
display.fit
How many digits (after decimal separator) should be used for printing results on the Rconsole?
dec
Decimal separator ("." or ",")
display
Display output?
object
Object of class R2noharm
logfile
File name if the summary should be sinked into a file
...
Further arguments to be passed

Value

  • A list with following entries
  • tanakaTanaka index
  • rmsrRMSR statistic
  • N.itempairSample sizes of pairwise item observations
  • pmProduct moment matrix
  • guessesFixed guessing parameters
  • residualsResidual covariance matrix
  • final.constantsVector of final constants
  • thresholdsThreshold parameters
  • uniquenessesItem uniquenesses
  • loadings.thetaMatrix of loadings in theta parametrization (common factor parametrization)
  • factor.corCovariance matrix of factors
  • difficultiesItem difficulties (for unidimensional models)
  • discriminationsItem discriminations (for unidimensional models)
  • loadingsLoading matrix (latent trait parametrization)
  • model.typeUsed model type
  • NobsNumber of observations
  • NitemsNumber of items
  • modtypeModel type according to the NOHARM specification (see NOHARM manual)
  • F.initInitial loading matrix for $F$
  • F.patternPattern loading matrix for $F$
  • P.initInitial covariance matrix for $P$
  • P.patternPattern covariance matrix for $P$
  • datOriginal data frame
  • systimeSystem time
  • noharm.pathUsed NOHARM directory
  • digits.pmNumber of digits in product moment matrix
  • decUsed decimal symbol
  • display.fitNumber of digits for fit display
  • dimensionsNumber of dimensions
  • chisquareStatistic $\chi^2$
  • NestparsNumber of estimated parameters
  • dfDegrees of freedom
  • chisquare_dfRatio $\chi^2 / df$
  • rmseaRMSEA statistic
  • p.chisquareSignificance for $\chi^2$ statistic

Details

NOHARM estimates a multidimensional compensatory item response model with the probit link function $\Phi$. For item responses $X_{pi}$ of person $p$ on item $i$ the model equation is defined as $$P( X_{pi} = 1 | \bold{\theta}_p ) = c_i + ( 1 - c_i ) \Phi( f_{i0} + f_{i1} \theta_{p1} + ... + f_{iD} \theta_{pD} )$$ where $F=(f_{id})$ is a loading matrix and $P$ the covariance matrix of $\bold{\theta}_p$. The guessing parameters $c_i$ must be provided as fixed inputs. For the definition of $F$ and $P$ matrices, please consult the NOHARM manual. This function needs the 64-bit command line version which can be downloaded at http://noharm.niagararesearch.ca/nh4cldl.html.

References

Fraser, C., & McDonald, R. P. (1988). NOHARM: Least squares item factor analysis. Multivariate Behavioral Research, 23, 267-269. Fraser, C., & McDonald, R. P. (2012). NOHARM 4 Manual. http://noharm.niagararesearch.ca/nh4man/nhman.html McDonald, R. P. (1997). Normal-ogive multidimensional model. In W. van der Linden & R. K. Hambleton (1997): Handbook of modern item response theory (pp. 257-269). New York: Springer.

See Also

For estimating standard errors see R2noharm.jackknife.

Examples

Run this code
# load data
data( data.noharm )
dat <- data.noharm
I <- ncol(dat) # number of items

# locate noharm.path
noharm.path <- "c:/NOHARM"

#############################################################################
# EXAMPLE 1: 1-dimensional Rasch model (1-PL model)
#############################################################################

# estimate one factor variance
P.pattern <- matrix( 1 , ncol=1 , nrow=1 )
P.init <- P.pattern
# fix all entries in the loading matrix to 1
F.pattern <- matrix( 0 , nrow=I , ncol=1 )
F.init <- 1 + 0*F.pattern       # 
# estimate model
mod <- R2noharm( dat = dat , model.type="CFA" ,  
		F.pattern = F.pattern , F.init = F.init , P.pattern = P.pattern ,
        P.init = P.init , writename = "ex1__1dim_1pl" , 
		noharm.path = noharm.path , dec ="," )
# summary
summary(mod , logfile="ex1__1dim_1pl__SUMMARY")
# jackknife
jmod <- R2noharm.jackknife( mod , jackunits = 20 )
summary(jmod, logfile="ex1__1dim_1pl__JACKKNIFE")
# extract factor scores
emod <- R2noharm.EAP(mod)

#############################################################################
# EXAMPLE 2: 1-dimensional 2PL Model
#############################################################################

# set trait variance equal to 1
P.pattern <- matrix( 0 , ncol=1 , nrow=1 )
P.init <- 1+0*P.pattern
# loading matrix
F.pattern <- matrix( 1 , nrow=I , ncol=1 )
F.init <- 1 + 0*F.pattern       

mod <- R2noharm( dat = dat , model.type="CFA" ,  
		F.pattern = F.pattern , F.init = F.init , P.pattern = P.pattern ,
        P.init = P.init , writename = "ex2__1dim_2pl" , 
		noharm.path = noharm.path , dec = "," )

summary(mod)
jmod <- R2noharm.jackknife( mod , jackunits = 20 )
summary(jmod)

#############################################################################
# EXAMPLE 3: 1-dimensional 3PL Model with fixed guessing parameters
#############################################################################

# set trait variance equal to 1
P.pattern <- matrix( 0 , ncol=1 , nrow=1 )
P.init <- 1+0*P.pattern
# loading matrix
F.pattern <- matrix( 1 , nrow=I , ncol=1 )
F.init <- 1 + 0*F.pattern       # 
# fix guessing parameters equal to .2 (for all items)
guesses <- rep( .1 , I )

mod <- R2noharm( dat = dat , model.type="CFA" ,  
		F.pattern = F.pattern , F.init = F.init , P.pattern = P.pattern ,
        P.init = P.init , guesses = guesses , 
		writename = "ex3__1dim_3pl" , noharm.path = noharm.path , dec=","  )
summary(mod)
jmod <- R2noharm.jackknife( mod , jackunits = 20 )
summary(jmod)

#############################################################################
# EXAMPLE 4: 3-dimensional Rasch model
#############################################################################

# estimate one factor variance
P.pattern <- matrix( 1 , ncol=3 , nrow=3 )
P.init <- .8*P.pattern
diag(P.init) <- 1
# fix all entries in the loading matrix to 1
F.init <- F.pattern <- matrix( 0 , nrow=I , ncol=3 )
F.init[1:6,1] <- 1
F.init[7:12,2] <- 1
F.init[13:18,3] <- 1
F.init

mod <- R2noharm( dat = dat , model.type="CFA" ,  
		F.pattern = F.pattern , F.init = F.init , P.pattern = P.pattern ,
        P.init = P.init , writename = "ex4__3dim_1pl" , 
		noharm.path = noharm.path  , dec ="," )
# write output from R console in a file
summary(mod , logfile="ex4__3dim_1pl__SUMMARY.Rout")

jmod <- R2noharm.jackknife( mod , jackunits = 20 )
summary(jmod)

# extract factor scores
emod <- R2noharm.EAP(mod)

#############################################################################
# EXAMPLE 5: 3-dimensional 2PL model
#############################################################################

# estimate one factor variance
P.pattern <- matrix( 1 , ncol=3 , nrow=3 )
P.init <- .8*P.pattern
diag(P.init) <- 0
# fix all entries in the loading matrix to 1
F.pattern <- matrix( 0 , nrow=I , ncol=3 )
F.pattern[1:6,1] <- 1
F.pattern[7:12,2] <- 1
F.pattern[13:18,3] <- 1
F.init <- F.pattern

mod <- R2noharm( dat = dat , model.type="CFA" ,  
		F.pattern = F.pattern , F.init = F.init , P.pattern = P.pattern ,
        P.init = P.init , writename = "ex5__3dim_2pl" , 
		noharm.path = noharm.path  , dec = "," )

summary(mod)
# use 50 jackknife units with 4 persons within a unit
jmod <- R2noharm.jackknife( mod , jackunits = seq( 1:50 , each = 4 ) )
summary(jmod)

#############################################################################
# EXAMPLE 6: Exploratory Factor Analysis with 3 factors
#############################################################################

mod <- R2noharm( dat = dat , model.type="EFA" ,  dimensions = 3 , 
               writename = "ex6__3dim_efa" , noharm.path = noharm.path ,
			   dec = ",")
summary(mod)

jmod <- R2noharm.jackknife( mod , jackunits = 20 )

Run the code above in your browser using DataLab