I have been working in R
with nonlinear models such us:
Y = Alpha1*time + Alpha2*sin(2*pi*time/Alpha3) + Alpha4*(-1)^time
And I would line whether a bernoulli variable affects to the Alpha1*time
and intercept or not. Such bernoulli variable could be:
varia<-rep("BEFORE","AFTER"),each=30)
Having
Y<- -2.5+rnorm(60)+2*sin(2*pi*time/8)+2.5*(-1)^time
time<-seq(1,60)
I found that nls
can fit this model but without the effect of this categorical variable, I also found that the nlme
package can estimate effects over variables not over terms of the nonlinear model.
My question is: Which of these package could help me? and, how could I add this bernoulli variable in the code?
Regards and thanks.