I\'m having trouble with running an nls regression with seasonal dummies in R. I\'m able to do it without the seasonal dummies, but not with. This is what I have so far:
<
You can use the factor
to subset the estimated coefficient like alpha[dummy]
.
data(cars)
cars$dummy <- as.factor(LETTERS[1:5])
nls(dist ~ alpha[dummy] + beta1*speed^beta2, data=cars, start=list(beta1=.2, beta2=3, alpha=rep(10, nlevels(cars$dummy))))
#Nonlinear regression model
# model: dist ~ alpha[dummy] + beta1 * speed^beta2
# data: cars
# beta1 beta2 alpha1 alpha2 alpha3 alpha4 alpha5
# 0.2069 1.8580 2.8264 5.3971 13.0000 9.3537 2.5359
# residual sum-of-squares: 10040
#
#Number of iterations to convergence: 12
#Achieved convergence tolerance: 2.372e-06