Hey! I am new in the R-world and I am trying to model the change in Z due to X in a longitudinal mediation model. I developed a function to describe the change in Z but keep getting an error when I try to plot zchange. "t" is supposed to be the time that has passed, I suppose there is something wrong with the way I use that? Can anyone tell me what is wrong with my code?
Thank you in advance!
zchange <- function(a=0.5, t, T=1) {if (t<=0){0}
else if ((0<t)&(t<T)){at}
else if (t>=T) {aT}}
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,