[R] factor.scores

Bill.Venables at csiro.au Bill.Venables at csiro.au
Thu Feb 10 04:45:13 CET 2011


The function factor.scores does not "inherit" anything.  It is a generic function that provieds methods for a number of classes, including those you mention.  (The terminology is important if you are to understand what is going on here):


> library(ltm)
Loading required package: MASS
Loading required package: msm
Loading required package: mvtnorm
Loading required package: polycor
Loading required package: sfsmisc

This is package 'ltm' version '0.9-5'

> find("factor.scores")
[1] "package:ltm"
> factor.scores
function (object, ...) 
{
    UseMethod("factor.scores")
}
<environment: namespace:ltm>
> methods("factor.scores")
[1] factor.scores.gpcm  factor.scores.grm   factor.scores.ltm   factor.scores.rasch
[5] factor.scores.tpm  
>  

So what you have to do, if you want factor.scores() to work on objects that you create is two things:

1. Give your objects an S3 class attribute, say "bifactor", and
2. Write your own S3 method function 

factor.scores.bifactor <- function(object, z, y, x, ...) { .... }

to perform the task.  The name of the function has to be "factor.scores.bifactor" and the name of the first formal argument has to be "object" and you must have a ... in the argument list, but from that point on you have a pretty free hand.

What you probably want to do is use some of the existing method functions to do the hard work once you have munged you object into a form that makes that possible.

Bill Venables.


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of James Lewis
Sent: Thursday, 10 February 2011 12:09 PM
To: r-help at R-project.org
Subject: [R] factor.scores

The function factor.scores is used with package ltm and others to estimate IRT type scores for various models.  It inherits objects of class grm, gpcm and a few others.  What I would like to do is to use the factor.scores function, but feed it my own item parameters (from a bifactor model where the 2PL parameters are adjusted for the bifactor structure). Does anybody have an idea of how this might be done?  I can, of course, create a list, matrix or other object containing the item parameters, but factor.scores only inherits particular object classes.  Any thoughts would be great. Thanks,

Jimmy

	[[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list