regression - How do I run an exponential nls with seasonal dummies in R? -


i'm having trouble running nls regression seasonal dummies in r. i'm able without seasonal dummies, not with. have far:

year=floor(time(lsts)) > month=round(time(lsts)-year,4) > month.f=factor(month) > dummies=model.matrix(~month.f) hotdognls<-nls(lsts~beta1/(1+exp(beta2+beta3*t)),start=list(beta1=2500,beta2=0.5,beta3=-0.5),trace=f) 

summary(hotdognls)

formula: lsts ~ beta1/(1 + exp(beta2 + beta3 * t))  parameters:         estimate std. error t value pr(>|t|)     beta1  2.030e+03  5.874e+01   34.55   <2e-16 *** beta2  1.146e+00  5.267e-02   21.76   <2e-16 *** beta3 -1.116e-02  7.668e-04  -14.56   <2e-16 *** --- signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1  residual standard error: 192.3 on 333 degrees of freedom  number of iterations convergence: 8  achieved convergence tolerance: 2.054e-06 

how include seasonal dummies? thanks!

i don't think dummies implemented nls in glm due fact "formula" nls real mathematical formula unlike glm.

you can nevertheless specify if parameter must assessed separately each class of dummy:

    data(cars)     # define dummy     cars$dummy <- as.factor(letters[1:5])     # code 0/1 dummy column per dummy level     cars$a<- as.numeric(cars$dummy=="a")     cars$b<- as.numeric(cars$dummy=="b")     cars$c<- as.numeric(cars$dummy=="c")     cars$d<- as.numeric(cars$dummy=="d")     cars$e<- as.numeric(cars$dummy=="e")      # precise in formula dummy level should play out     # here in intercept:     model <- nls(dist~beta1*speed^beta2+beta3*a+beta4*b+beta5*c+beta6*d+beta7*e,data=cars)      model      nonlinear regression model       model: dist ~ beta1 * speed^beta2 + beta3 * + beta4 * b + beta5 * c + beta6 * d + beta7 * e       data: cars       beta1   beta2   beta3   beta4   beta5   beta6   beta7        0.2069  1.8580  2.8266  5.3973 13.0002  9.3539  2.5361        residual sum-of-squares: 10040        number of iterations convergence: 8        achieved convergence tolerance: 4.924e-06 

Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -