You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since we now have a predict() function, it would be nice to have a function that easily plots the predicted data. Maybe overlayed/ subplotted with the actual data. I achieved it in the following way:
using Unfold, CairoMakie
# Predict the data from model m
pred_data_stim =predict(
m,
Unfold.formulas(m),
Unfold.events(m);
overlap =true,
keep_basis = [Unfold.basisname(Unfold.formulas(m))[2]]
)
pred_data_resp =predict(
m,
Unfold.formulas(m),
Unfold.events(m);
overlap =true,
keep_basis = [Unfold.basisname(Unfold.formulas(m))[1]]
)
fig =Figure()
ax1 =Axis(fig[1], width=Relative(1), height=Relative(0.5), halign=0.0, valign=1)
ax2 =Axis(fig[1], width=Relative(1), height=Relative(0.5), halign=0.0, valign=0.0)
l = (500, 1500) # limits of the plot# Plot continuous datalines!(ax1, data, color =:black)
# Plot non-overlapping datalines!(ax2, pred_data_stim[1,:], color = (:blue, 0.5))
lines!(ax2, pred_data_resp[1,:], color = (:red, 0.5))
# Set limits and hide stuff
axes = [ax1, ax2]
for a in axes; xlims!(a, l...); hidedecorations!(a); hidespines!(a); end# Stimulus marker
colors = [:blue, :green]
for (i,c) inenumerate(unique(evts.condition))
vlines!(Axis(fig[pos...]),@rsubset(evts, :condition.== c, :event.=='S').latency, color = (colors[i], 0.5))
xlims!(l...)
hidedecorations!(current_axis())
hidespines!(current_axis())
end# Response markervlines!(Axis(fig[pos...]),@rsubset(evts,:event.=='R').latency, color = (:red, 0.5))
xlims!(l...)
hidedecorations!(current_axis())
hidespines!(current_axis())
current_figure()
In this case it looks like this for me (but it's specific for my figure, thus no decorations)
This way one could visually inspect how much of the data is explained by the model (when plotting predicted data with overlap), how much overlap is in the data, etc.
Additionally, this could be nice for future figures and presentations.
The text was updated successfully, but these errors were encountered:
I like it. One issue I see, which I also see with the DesignMatrix, is that if we have a long dataset, we don't really know where (or "when in time") to plot, and plotting everything is maybe a bit much (even though possible outside CairoMakie+SVG).
Since we now have a
predict()
function, it would be nice to have a function that easily plots the predicted data. Maybe overlayed/ subplotted with the actual data. I achieved it in the following way:In this case it looks like this for me (but it's specific for my figure, thus no decorations)
This way one could visually inspect how much of the data is explained by the model (when plotting predicted data with overlap), how much overlap is in the data, etc.
Additionally, this could be nice for future figures and presentations.
The text was updated successfully, but these errors were encountered: