################################
# 1. Example on Windows
################################
# define data generating parameters
set.seed(1997)
N <- 500 # number of persons
I <- 4 # number of items
R <- 3 # number of raters
K <- 3 # maximum score
sigma <- 2 # standard deviation
theta <- rnorm( N , sd = sigma ) # abilities
# item intercepts
b <- outer( seq( -1.5 , 1.5 , len = I) , seq( -2 , 2 , len = K) , "+" )
# item loadings
a <- rep(1,I)
# rater severity parameters
phi <- matrix( c(-.3 , -.2 , .5) , nrow = I , ncol = R , byrow = TRUE )
phi <- phi + rnorm( phi , sd = .3 )
phi <- phi - rowMeans(phi)
# rater variability parameters
psi <- matrix( c(.1 , .4 , .8) , nrow = I , ncol = R , byrow = TRUE )
# simulate HRM data
data <- simulate_HRM( theta , a , b , phi = phi, psi = psi )
# prepare data for FACETS
data2FACETS <- function(data){
tmp <- match(c("pid","rater"),colnames(data))
items <- grep("I",colnames(data))
cbind(data[ , match(c("pid","rater"),
colnames(data))],gr = paste0("1-",length(items)),data[,items])
}
facets_in <- data2FACETS(data)
# Example of FACETS
mod1.a <- immer_FACETS(
title = "Example 1 with simulated data",
convergence = NULL,
totalscore = "YES",
facets = 3,
noncenter = NULL,
arrange = "m,N",
entered_in_data = "2,1,1",
models = "?$,?$,?$,R4",
inter_rater = NULL,
pt_biserial = NULL,
faire_score = "Zero",
unexpected = 2,
usort = NULL,
positive = 1,
labels = c("1,Persons","1-500","2,Rater","1-3","3,Item","1-4"),
fileinput = NULL,
data = facets_in,
path.dosbox = NULL,
path.facets = "C:\\Facets",
model.name = "Example.SD",
facetsEXE = NULL
)
################################
# 2. Example on Windows using existing input-files of FACETS
################################
data(data.immer06)
mod1b <- immer_FACETS(
fileinput = data.immer06,
path.facets = "C:\\Facets",
model.name = "Example.SD",
facetsEXE = NULL
)
Run the code above in your browser using DataLab