Modelling change over time in mediation model

Hi, and welcome!

Please see the FAQ: What's a reproducible example (`reprex`) and how do I create one? Using a reprex, complete with representative data will attract quicker and more answers.

I've reinterpreted the function (for one reason because there's no adjacency operator for multiplication and some of the tests were unneeded)

library(purrr)

zchange <- function(t, a = 0.5, T = 1) {
    ifelse(t <= 0, 0, 
        ifelse(t < T, a*t, a*T)
        )
    }

t <- seq(from = 0.01, to = 0.49, by = 0.01)
z <- map(t, zchange) %>% unlist()
plot(t,z)

Created on 2020-03-07 by the reprex package (v0.3.0)

It would be more interesting, of course, with varying a and T. BTW: I put t as the first argument, because R uses positional processing and a and T have defaults,