MixedModels.GHnorm
— FunctionGHnorm(k::Int)
Return the (unique) GaussHermiteNormalized{k} object.
The function values are stored (memoized) when first evaluated. Subsequent evaluations for the same k
have very low overhead.
diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 86892fc30..5a8d248eb 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2025-01-22T16:02:48","documenter_version":"1.8.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2025-01-22T19:29:19","documenter_version":"1.8.0"}} \ No newline at end of file diff --git a/dev/GaussHermite/index.html b/dev/GaussHermite/index.html index c1c1675e8..e6e5fdd80 100644 --- a/dev/GaussHermite/index.html +++ b/dev/GaussHermite/index.html @@ -16,7 +16,7 @@ x=gh9[1], y=gh9[2], Geom.hair, Geom.point, Scale.y_log2, Guide.ylabel("Weight (log scale)"), Guide.xlabel(""), -)
The definition of MixedModels.GHnorm
is similar to the gausshermitenorm
function with some extra provisions for ensuring symmetry of the abscissae and the weights and for caching values once they have been calculated.
MixedModels.GHnorm
— FunctionGHnorm(k::Int)
Return the (unique) GaussHermiteNormalized{k} object.
The function values are stored (memoized) when first evaluated. Subsequent evaluations for the same k
have very low overhead.
using MixedModels
+)
The definition of MixedModels.GHnorm
is similar to the gausshermitenorm
function with some extra provisions for ensuring symmetry of the abscissae and the weights and for caching values once they have been calculated.
MixedModels.GHnorm
— FunctionGHnorm(k::Int)
Return the (unique) GaussHermiteNormalized{k} object.
The function values are stored (memoized) when first evaluated. Subsequent evaluations for the same k
have very low overhead.
using MixedModels
GHnorm(3)
MixedModels.GaussHermiteNormalized{3}([-1.7320508075688772, 0.0, 1.7320508075688772], [0.16666666666666666, 0.6666666666666666, 0.16666666666666666])
By the properties of the normal distribution, when $\mathcal{X}\sim\mathscr{N}(\mu, \sigma^2)$
\[\mathbb{E}[g(x)] \approx \sum_{i=1}^k g(\mu + \sigma z_i)\,w_i\]
For example, $\mathbb{E}[\mathcal{X}^2]$ where $\mathcal{X}\sim\mathcal{N}(2, 3^2)$ is
μ = 2; σ = 3; ghn3 = GHnorm(3);
sum(@. ghn3.w * abs2(μ + σ * ghn3.z)) # should be μ² + σ² = 13
13.0
(In general a dot, '.
', after the function name in a function call, as in abs2.(...)
, or before an operator creates a fused vectorized evaluation in Julia. The macro @.
has the effect of vectorizing all operations in the subsequent expression.)
A binary response is a "Yes"/"No" type of answer. For example, in a 1989 fertility survey of women in Bangladesh (reported in Huq, N. M. and Cleland, J., 1990) one response of interest was whether the woman used artificial contraception. Several covariates were recorded including the woman's age (centered at the mean), the number of live children the woman has had (in 4 categories: 0, 1, 2, and 3 or more), whether she lived in an urban setting, and the district in which she lived. The version of the data used here is that used in review of multilevel modeling software conducted by the Center for Multilevel Modelling, currently at University of Bristol (http://www.bristol.ac.uk/cmm/learning/mmsoftware/data-rev.html). These data are available as the :contra
dataset.
contra = DataFrame(MixedModels.dataset(:contra))
describe(contra)
Row | variable | mean | min | median | max | nmissing | eltype |
---|---|---|---|---|---|---|---|
Symbol | Union… | Any | Union… | Any | Int64 | DataType | |
1 | dist | D01 | D61 | 0 | String | ||
2 | urban | N | Y | 0 | String | ||
3 | livch | 0 | 3+ | 0 | String | ||
4 | age | 0.00204757 | -13.56 | -1.56 | 19.44 | 0 | Float64 |
5 | use | N | Y | 0 | String |
A smoothed scatterplot of contraception use versus age
plot(contra, x=:age, y=:use, Geom.smooth, Guide.xlabel("Centered age (yr)"),
@@ -1141,4 +1141,4 @@
-'/>- 1https://en.wikipedia.org/wiki/Gaussian_quadrature
Settings
This document was generated with Documenter.jl version 1.8.0 on Wednesday 22 January 2025. Using Julia version 1.10.0.