Open behinger opened 4 years ago
I implemented spline as a starter. => See Pluto notebooks /docs/nb_timesplines.jl and ./docs/nb_timesplines_dev.jl
What I didnt really think about, is that we commonly want to move the temporal predictors from predictor space (e.g. 10 splines) back into timespace (e.g. 100 samples). I will leave this for a major overhaul of unfold :-)
begin
gd = groupby(res,[:basisname,:channel,:group,:coefname])
a = combine(gd) do d
return undoBasis(d,m)
end
a
end
function undoBasis(d,m)
bname = unique(d.basisname) # the current coefficient basename
@assert(length(bname)==1)
@assert(length(unique(d.channel))==1)
bnames = unique(Unfold.get_basis_name(m)) # all model basenames
# find out which formula / basisfunction we have
k = findfirst(bname .== bnames)
bf = designmatrix(m).formulas[k].rhs.basisfunction
estimate= bf.kernel.(0) *d.estimate
@show size(bf.kernel.(0))
@show size(Unfold.times(bf))
return DataFrame(:time=>Unfold.times(bf),:estimate=>estimate)
end
This will do the trick. Now we just have to