[R-sig-ME] Error in gamm4 function in names(x) <- value: 'names' attribute must be the same length as the vector
Ben Bolker
bbolker @ending from gm@il@com
Fri Jan 4 15:23:56 CET 2019
Hard to say much more without a reproducible example.
You could try to turning your date variable into a numeric value.
bs="cc" appears to be a cyclic smooth; I would probably experiment
with some very simple models (maybe in mgcv::gam() to start with) that
use a cyclic smooth on a date-valued covariate and see if that even
works ...
can you show us the results of traceback() ?
cheers
Ben Bolker
On Thu, Jan 3, 2019 at 11:44 PM 王 嘉炜 <wangjiawei92 using hotmail.com> wrote:
>
>
> Dear R users,
>
>
> I am using the *gamm4 package* to model the ozone pollution concentration according to some environmental covariates by generated additive mixed model. The model takes the form :
>
> model1 <-gamm4(O3~s(X,Y,bs="tp",k=10)+wd+s(date,bs="cc",k=100)+district,data=mydata,family= gaussian(link ="log" ), random=~(1|date/district), na.action="na.omit", method="REML",gamma=1.4)
>
> And here is the strcture of covariates
> > str(mydata)
> 'data.frame': 7100 obs. of 286 variables:
> $ date : Date, format: "2016-01-01" "2016-01-01" "2016-01-01" ...
> $ O3 : num 0.0141 0.0149 0.0102 0.0159 0.0186 ...
> $ district : Factor w/ 10 levels "bc","bh","dl",..: 1 8 7 8 2 6 4 4 10 2 ...
> $ wd : Factor w/ 16 levels "E","ENE","ESE",..: 13 13 13 13 13 2 9 9 11 13 ...
> $ X : num 0.389 0.365 1 0.44 0.892 ...
> $ Y : num 0.311 0.204 0.426 0.223 0.162 ...
>
> I am stuck on an error in R: 'names' attribute [1] must be the same length as the vector [0].
>
> I try to find where the problem is by delete the term of "s(date,bs="cc",k=100)" from the fomular and it could work well. It seems like there is something wrong with date field.
>
> I'm not exactly sure how to fix this problem. Any advice would be greatly
> appreciated!
> Jiawei Wang
> 发自 Outlook<http://aka.ms/weboutlook>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
More information about the R-sig-mixed-models
mailing list