Nonlinear regression with dummie variables
I'm creating several templates, then making the selection based on the AICc. Among these models I'm creating, I have a categorical predictor variable (fire) that I need to include in the nonlinear regression model. The three models I need to run are:
fire_vertical <- nls(R~0.23-exp(A*lnNt+C)+d*fire,
start=list(A=-0.33,C=0.45,d=-0.001),trace=T)
fire_lateral <- nls(R~0.23-exp((A*lnNt)+(C+d*fire)),
start=list(A=-0.33,C=0.45,d=-0.001),trace=T)
fire_nonlinear <- nls(R~0.23-exp((A+d*fire)*lnNt+C),
start=list(A=-0.33,C=0.45,d=-0.001),trace=T)
Considering the following data:
R <- c(0.02,0.00,-0.06,0.11,0.06,0.00,-0.05,-0.06,
0.02,-0.26,0.00,0.07,-0.07,0.23,0.06,-0.14,-0.04,
0.09,-0.09,0.09,-0.02)
lnNt <- c(6.14,6.14,5.76,6.42,6.81,
6.81,6.49,6.14,6.24,4.81,4.81,5.14,
4.81,6.03,6.42,5.59,5.39,5.90,5.39,5.90,5.76)
fire <- c("before","before","before",
"before","before","before",
"before","afterone","afterone","afterone",
"afterone","afterone","afterone","afterone",
"aftertwo","aftertwo","aftertwo","aftertwo","aftertwo",
"aftertwo","aftertwo")
Where lnNt
is a continuous predictor variable, while fire is a categorical predictor with three levels: before
, afterone
, aftertwo
.
Need to transform the fire on a dummie variable and make the three models presented rotate that way.
Anyone who can help, I thank you right now.
0