Skip to content

Commit

Permalink
Remove DataFramesMeta from the docs (#515)
Browse files Browse the repository at this point in the history
* fix reflink

* remove DataFramesMeta from the docs
  • Loading branch information
palday authored Apr 30, 2021
1 parent e9c2be3 commit 628cbf3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
1 change: 0 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DataFramesMeta = "1313f7d8-7da2-5740-9ea0-a2ca25f37964"
DisplayAs = "0b91fe84-8a4c-11e9-3e1d-67c38462b6d6"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
FreqTables = "da1fdf0e-e0ff-5433-a45f-9bb5ff651cb1"
Expand Down
38 changes: 23 additions & 15 deletions docs/src/bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ using DisplayAs

```@example Main
using DataFrames
using DataFramesMeta # dplyr-like operations
using Gadfly # plotting package
using MixedModels
using Random
Expand All @@ -54,21 +53,26 @@ first(df, 10)
Especially for those with a background in [`R`](https://www.R-project.org/) or [`pandas`](https://pandas.pydata.org),
the simplest way of accessing the parameter estimates in the parametric bootstrap object is to create a `DataFrame` from the `allpars` property as shown above.

The [`DataFramesMeta`](https://github.com/JuliaData/DataFramesMeta.jl) package provides macros for extracting rows or columns of a dataframe.
We can use `filter` to filter out relevant rows of a dataframe.
A density plot of the estimates of `σ`, the residual standard deviation, can be created as
```@example Main
σres = @where(df, :type .== "σ", :group .== "residual").value
plot(x = σres, Geom.density, Guide.xlabel("Parametric bootstrap estimates of σ"))
σres = filter(df) do row # create a thunk that operates on rows
row.type == "σ" && row.group == "residual" # our filtering rule
end
plot(x = σres.value, Geom.density, Guide.xlabel("Parametric bootstrap estimates of σ"))
```
For the estimates of the intercept parameter, the `getproperty` extractor must be used
```@example Main
plot(@where(df, :type .== "β"), x = :value, Geom.density, Guide.xlabel("Parametric bootstrap estimates of β₁"))
plot(filter(:type => ==("β"), df), x = :value, Geom.density, Guide.xlabel("Parametric bootstrap estimates of β₁"))
```

A density plot of the estimates of the standard deviation of the random effects is obtained as
```@example Main
σbatch = @where(df, :type .== "σ", :group .== "batch").value
plot(x = σbatch, Geom.density,
σbatch = filter(df) do row # create a thunk that operates on rows
row.type == "σ" && row.group == "batch" # our filtering rule
end
plot(x = σbatch.value, Geom.density,
Guide.xlabel("Parametric bootstrap estimates of σ₁"))
```

Expand All @@ -77,7 +81,7 @@ Although this mode appears to be diffuse, this is an artifact of the way that de
In fact, it is a pulse, as can be seen from a histogram.

```@example Main
plot(x = σbatch, Geom.histogram,
plot(x = σbatch.value, Geom.histogram,
Guide.xlabel("Parametric bootstrap estimates of σ₁"))
```

Expand Down Expand Up @@ -126,24 +130,28 @@ DataFrame(shortestcovint(samp2))

A histogram of the estimated correlations from the bootstrap sample has a spike at `+1`.
```@example Main
ρs = @where(df2, :type .== "ρ", :group .== "subj").value
plot(x = ρs, Geom.histogram,
ρs = filter(df2) do row
row.type == "ρ" && row.group == "subj"
end
plot(x = ρs.value, Geom.histogram,
Guide.xlabel("Parametric bootstrap samples of correlation of random effects"))
```
or, as a count,
```@example Main
sum(ρs .≈ 1)
count(ρs.value .≈ 1)
```

Close examination of the histogram shows a few values of `-1`.
```@example Main
sum(ρs .≈ -1)
count(ρs.value .≈ -1)
```

Furthermore there are even a few cases where the estimate of the standard deviation of the random effect for the intercept is zero.
```@example Main
σs = @where(df2, :type .== "σ", :group .== "subj", :names .== "(Intercept)").value
sum(σs .≈ 0)
σs = filter(df2) do row
row.type == "σ" && row.group == "subj" && row.names == "(Intercept)"
end
count(σs.value .≈ 0)
```

There is a general condition to check for singularity of an estimated covariance matrix or matrices in a bootstrap sample.
Expand All @@ -154,5 +162,5 @@ The `issingular` method for a `MixedModel` object that tests if a parameter vect

This operation is encapsulated in a method for the `issingular` function.
```@example Main
sum(issingular(samp2))
count(issingular(samp2))
```
4 changes: 2 additions & 2 deletions src/bootstrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bar is automatically disabled for non-interactive (i.e. logging) contexts.
Julia- and BLAS-level threads in the future.
!!! warning
The PRNG shared between threads is locked using [`Threads.SpinLock`](@ref), which
The PRNG shared between threads is locked using `Threads.SpinLock`, which
should not be used recursively. Do not wrap `parametricbootstrap` in an outer `SpinLock`.
"""
function parametricbootstrap(
Expand Down Expand Up @@ -261,7 +261,7 @@ end
"""
shortestcovint(bsamp::MixedModelBootstrap, level = 0.95)
Return the shortest interval containing `level` proportion for each parameter from [`bsamp.allpars`](@ref)
Return the shortest interval containing `level` proportion for each parameter from `bsamp.allpars`
"""
function shortestcovint(bsamp::MixedModelBootstrap{T}, level = 0.95) where {T}
allpars = bsamp.allpars
Expand Down

0 comments on commit 628cbf3

Please sign in to comment.