| gen.weight | R Documentation |
This function generates a set of normalized weights based on theta (ability)
values to be used in functions such as est_score(),
sx2_fit(), and covirt().
gen.weight(n = 41, dist = "norm", mu = 0, sigma = 1, l = -4, u = 4, theta)
n |
An integer specifying the number of theta (node) values for which weights are to be generated. Default is 41. |
dist |
A character string indicating the distribution type used to
generate weights. Available options are
|
mu, sigma |
Mean and standard deviation of the normal distribution (used
when |
l, u |
Lower and upper bounds of the uniform distribution (used when
|
theta |
A numeric vector of empirical theta (node) values for which weights are generated. |
If theta is not specified, n equally spaced quadrature points
and corresponding weights are generated from either the normal or uniform
distribution:
When dist = "norm", Gaussian quadrature points and weights are computed
using gauss.quad.prob() from the statmod package.
When dist = "unif", equally spaced points are drawn from the specified
interval [l, u], and weights are proportional to the uniform density.
If theta is specified:
When dist = "norm", the weights are proportional to the normal density
evaluated at each theta value and normalized to sum to 1.
When dist = "emp", equal weights are assigned to each provided theta value.
A data frame with two columns:
theta: The theta (node) values.
weight: The corresponding normalized weights.
Hwanggyu Lim hglim83@gmail.com
est_score(), sx2_fit(), covirt()
## Example 1:
## Generate 41 Gaussian quadrature points and weights from the normal distribution
gen.weight(n = 41, dist = "norm", mu = 0, sigma = 1)
## Example 2:
## Generate 41 theta values and weights from the uniform distribution,
## given a minimum value of -4 and a maximum value of 4
gen.weight(n = 41, dist = "unif", l = -4, u = 4)
## Example 3:
## Generate normalized weights from the standard normal distribution,
## given a user-defined set of theta values
theta <- seq(-4, 4, by = 0.1)
gen.weight(dist = "norm", mu = 0, sigma = 1, theta = theta)
## Example 4:
## Generate equal normalized weights for theta values
## randomly sampled from the standard normal distribution
theta <- rnorm(100)
gen.weight(dist = "emp", theta = theta)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.