gen_test_score {lazy.tools}R Documentation

Generating Test Score Distribution

Description

This function generates a frequency distribution table of n discrete test scores in [minscore,maxscore].

Usage

gen_test_score(
  n,
  minscore = 0,
  maxscore = 100,
  normal = c(50, 15),
  beta = NULL,
  beta_ms = NULL,
  dump = 0,
  print = 0,
  plot = 0,
  title = "Score Distribution"
)

Arguments

n

# of observations.

minscore

The minimum score.

maxscore

The maximum score.

normal

Vector consisting of mean and std for normal distribution.

beta

Vector of alpha and beta parameters for beta distribution in [minscore,maxscore].

beta_ms

Vector of mean and std of the generalized beta distribution in [minscore,maxscore].

dump

= 1 to output the discrete random numbers.

print

= 1 to print the result.

plot

= 1 to plot the result.

title

Title string to be used in plot.

Details

This function generates a frequency distribution table of n discrete test scores in [minscore,maxscore].

Continuous random numbers, either normal or generalized beta, are first generated and then they are discretized by cut function. Those values outside of [minscore,maxscore] will be set to minscore or maxscore, resp.

beta_ms parameter has the priority over beta and nomal parameter.

Value

If dump == 0, a matrix consisting of (score, frequency).
otherwise, a list of rv, random numbers, and freqdist matrix.

Examples

seed <- 1701
set.seed(seed)

minscore <- 0; maxscore <- 100
n <- 500

s1 <- gen_test_score( n, minscore, maxscore, beta=c(4,8), plot=1 )
( mands(s1[,1],s1[,2]) )
s2 <- gen_test_score( n, minscore, maxscore
                    , beta_ms=c(33.29, 13.07), plot=1 )
( mands(s2[,1],s2[,2]) )

# mixture
minscore <- 0; maxscore <- 50
scoredist1 <- gen_test_score( n, minscore, maxscore, beta=c(4,8), plot=1 )
scoredist2 <- gen_test_score( n, minscore, maxscore, normal=c(30,5), plot=1)
scoredist12 <- merge_tables( scoredist1,scoredist2 )
barplot(height=scoredist12[,2], names.arg=as.character(scoredist12[,1])
        , main="Score Dist", cex.names=.65, space=0, las=2)


[Package lazy.tools version 0.1.4 ]