Created
November 16, 2017 01:47
-
-
Save Nosferican/c141036301f9835ef0c84ca071384f49 to your computer and use it in GitHub Desktop.
Identifying error in StatsModels ModelMatrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Using modified forks to test code (mostly fixed depreciations, but can inspect the changes at the link) | |
using DataFrames # From https://github.com/JuliaEconometrics/DataFrames.jl | |
using Feather | |
using StatsModels # From https://github.com/JuliaEconometrics/StatsModels.jl | |
df = Feather.read("NLS.feather") # Feather file from Stata's webuse nlswork | |
df = df[[:idcode, :year, :ln_wage, :age, :race, :union, :ttl_exp]] | |
df[:idcode] = string.(df[:idcode]) | |
df[:year] = string.(df[:year]) | |
df[:union] = Vector{Union{Nulls.Null, String}}(get.(Dict([(0, "False"),(1, "True")]), df[:union], Nulls.null)) | |
categorical!(df, [:idcode, :year, :race, :union]) | |
dropnull!(df) | |
mf = ModelFrame(@formula(ln_wage ~ ttl_exp), df) | |
y = mf.df[:ln_wage] | |
X = ModelMatrix(mf).m | |
mf = ModelFrame(@formula(ln_wage ~ idcode), df); | |
ModelMatrix(mf).m # Error here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment