Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pharmcat/nestedterms.jl
Nested term concept package.
https://github.com/pharmcat/nestedterms.jl
Last synced: about 13 hours ago
JSON representation
Nested term concept package.
- Host: GitHub
- URL: https://github.com/pharmcat/nestedterms.jl
- Owner: PharmCat
- License: mit
- Created: 2024-03-24T20:04:39.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-03-24T21:03:20.000Z (8 months ago)
- Last Synced: 2024-03-25T21:28:18.568Z (8 months ago)
- Language: Julia
- Size: 90.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NestedTerms.jl
Nested term concept package.
## Install
```julia
import Pkg
Pkg.add(url = "https://github.com/PharmCat/NestedTerms.jl.git")
```## Example
```
using NestedTerms
using StatsModels, CSV, DataFrames, CategoricalArraysrds = CSV.File(joinpath(dirname(pathof(NestedTerms)), "..", "test", "csv", "rds12x2.csv")) |> DataFrame # DataFrame with nested factor Subject(Sequence)
transform!(rds, :Sequence => categorical, renamecols=false)
transform!(rds, :Subject => categorical, renamecols=false)# Nested term exploit function term in @formula macros
formula = @formula(Var ~ (Subject in Sequence))# Replace FunctionTerm to NestedTerm
formula = NestedTerms.process_nt(formula)# Make schema and apply_schema
sch = schema(formula, rds)
as = apply_schema(formula, sch) $ upper level factor not added to the formula (but it shoud be there)# Get model matrix for nested term
rmf, lmf = modelcols(as, rds)
```## Unsolvable problems
Can't get real `coefnames` and `levels` until `modelcols` not called. `apply_schema` not able to modify NestedTerm because have no appropriate information.