R/inits_theta_1dim.R

Defines functions inits_theta_1dim

## File Name: inits_theta_1dim.R
## File Version: 0.13

#####################################################################
inits_theta_1dim <- function( dat, pid, eps=.05, sd_init=1 )
{
    N <- length(unique(pid))
    # initial values
    maxK <- apply( dat, 2, max, na.rm=TRUE )
    I <- ncol(dat)
    K <- max(maxK)
    # ability inits
    theta <- stats::aggregate( dat, list(pid), mean, na.rm=TRUE )[,-1]
    theta <- theta / matrix( maxK, nrow=N, ncol=I, byrow=TRUE )
    theta <- rowMeans(theta, na.rm=TRUE)
    theta <- ( theta + eps ) / ( 1 + 2*eps )
    theta <- stats::qlogis(theta)
    theta <- theta - mean(theta)
    theta <- sd_init / stats::sd(theta) * theta
    return(theta)
}
#####################################################################

Try the immer package in your browser

Any scripts or data that you put into this service are public.

immer documentation built on Aug. 22, 2022, 5:05 p.m.