Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Test, Distributions, CSV, GLM, Lasso, DataFrames
- using Random, Distributed, LinearAlgebra, SparseArrays, SharedArrays
- include("./test/testutils.jl")
- include("./test/addworkers.jl")
- import HurdleDMR; @everywhere using HurdleDMR
- include("./test/testdata.jl")
- testargs = Dict(:verbose=>false,:showwarnings=>true)
- zcounts = deepcopy(counts);
- zcounts[:,2] = zeros(n);
- zcounts[:,3] = ones(n);
- # make sure we are not adding all zero obseravtions
- m = sum(zcounts, dims=2)
- @test sum(m .== 0) == 0
- # hurdle dmr parallel local cluster
- hdmrcoefs = fit(HDMR,covars, zcounts; parallel=true, testargs...)
- coefsHppos, coefsHpzero = coef(hdmrcoefs);
- # hurdle dmr parallel remote cluster
- hdmrcoefs2 = fit(HDMRPaths,covars, zcounts; parallel=true, local_cluster=false, testargs...)
- coefsHppos2, coefsHpzero2 = coef(hdmrcoefs2)
- @test coefsHppos ≈ coefsHppos2
- @test coefsHpzero ≈ coefsHpzero2
- η = predict(hdmrcoefs2,newcovars)
- # 10×4 Array{Float64,2}:
- # 0.00632811 0.0 0.0 0.993672
- # 0.0820357 0.0 0.0 0.917964
- # 0.120042 0.0 0.0 0.879958
- # 0.000773842 0.0 0.0 0.999226
- # 0.00158558 0.0 0.0 0.998414
- # 0.0587256 0.0 0.0 0.941274
- # 0.0155122 0.0 0.0 0.984488
- # 0.00119599 0.0 0.0 0.998804
- # 0.018085 0.0 0.0 0.981915
- # 0.0141473 0.0 0.0 0.985853
- @test sum(η, dims=2) ≈ ones(size(newcovars, 1))
- # Test Passed
- @test η[:,2] == zeros(size(newcovars,1))
- # Test Passed
- @test η[:,3] ≈ ones(size(newcovars,1))*0.36 rtol=0.05
- # Test Failed at none:1
- # Expression: ≈(η[:, 3], ones(size(newcovars, 1)) * 0.36, rtol=0.05)
- # Evaluated: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] ≈ [0.36, 0.36, 0.36, 0.36, 0.36, 0.36, 0.36, 0.36, 0.36, 0.36] (rtol=0.05)
- # ERROR: There was an error during testing
- @test η[:,4] ≈ ones(size(newcovars,1))*0.6 rtol=0.06
- # Test Failed at none:2
- # Expression: ≈(η[:, 4], ones(size(newcovars, 1)) * 0.6, rtol=0.06)
- # Evaluated: [0.993672, 0.917964, 0.879958, 0.999226, 0.998414, 0.941274, 0.984488, 0.998804, 0.981915, 0.985853] ≈ [0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6] (rtol=0.06)
- # ERROR: There was an error during testing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement