Reputation: 11
everyone. I am using DLNM in R to analyze to lag-effect of climatic conditions on the prevalence of the disease. I followed somebody else's program strictly , and it worked in avg.temp and max.speed, but showed err "coef/vcov not consistent with basis matrix" in avg.ap and avg.hum. However, i just changed the variables set in code, and never changed other code. I have a hypothesis that maybe DLNM doesn't like wet weather. T T I don't know what to do, can you help me?
Part 1 was the Successfully run code, part 2 was the code that showed err, and part 3 was the data I used. Thank you very much. I hope you can help me
Part 1. Successfully run code
attach(cpdlnm)
cb.temp = crossbasis(avg.temp, lag=1 ,
argvar=list(fun="ns",
knots= c(10)),
arglag=list(fun="lin"))
modeltemp = glm(pre1 ~ cb.temp +
ns(no,1*1),
family=quasipoisson(), cpdlnm)
pred1.temp = crosspred(cb.temp,
modelhum,
cen=round(median(avg.temp)),
bylag=1)
Part 2. Error code
attach(cpdlnm)
cb.hum = crossbasis(avg.hum, lag=1 ,
argvar=list(fun="ns",
knots= c(10)),
arglag=list(fun="lin"))
modelhum = glm(pre1 ~ cb.hum +
ns(no,1*1),
family=quasipoisson(), cpdlnm)
pred1.hum = crosspred(cb.hum, # This step shows "coef/vcov not consistent with basis matrix"
modelhum,
cen=round(median(avg.hum)),
bylag=0.1)
Part 3. the data are as following:
no pre1 date year month avg.ap avg.temp avg.hum max.speed
1 3.23 12-Jan 2012 1 996.60 9.00 81.60 5.30
2 6.04 12-Feb 2012 2 993.20 10.90 80.80 6.20
3 5.18 12-Mar 2012 3 991.00 16.40 78.70 7.60
4 4.07 12-Apr 2012 4 985.40 23.50 73.50 7.40
5 4.88 12-May 2012 5 982.60 26.30 77.20 7.00
6 5.11 12-Jun 2012 6 978.10 27.00 81.30 6.20
7 6.18 12-Jul 2012 7 979.50 28.10 77.70 6.40
8 6.17 12-Aug 2012 8 980.40 28.00 75.60 7.90
9 5.18 12-Sep 2012 9 987.60 25.30 73.60 6.30
10 5.16 12-Oct 2012 10 990.70 23.60 72.20 6.20 11 4.61 12-Nov 2012 11 991.70 18.00 79.70 6.90 12 5.26 12-Dec 2012 12 995.00 13.20 74.90 6.50 13 3.79 13-Jan 2013 1 997.10 11.20 78.40 5.70 14 3.87 13-Feb 2013 2 993.50 15.30 82.20 6.50 15 3.37 13-Mar 2013 3 989.90 20.20 74.20 8.00 16 2.85 13-Apr 2013 4 987.00 21.50 78.50 7.70 17 4.38 13-May 2013 5 983.30 25.60 79.20 6.80 18 5.67 13-Jun 2013 6 980.60 27.40 76.90 6.60 19 6.45 13-Jul 2013 7 981.30 28.00 77.50 7.10 20 6.95 13-Aug 2013 8 980.50 27.90 78.20 7.90 21 6.51 13-Sep 2013 9 985.90 25.40 77.60 6.00 22 8.16 13-Oct 2013 10 992.20 22.10 68.80 5.30 23 5.34 13-Nov 2013 11 994.50 18.70 72.30 6.20 24 6.18 13-Dec 2013 12 997.30 11.70 67.20 5.30 25 5.69 14-Jan 2014 1 996.70 12.70 70.30 6.00 26 6.44 14-Feb 2014 2 993.00 12.10 76.90 6.40 27 4.16 14-Mar 2014 3 991.60 16.50 83.90 7.30 28 4.13 14-Apr 2014 4 987.60 22.60 82.40 6.70 29 3.96 14-May 2014 5 983.60 25.70 78.80 7.70 30 4.72 14-Jun 2014 6 979.20 27.70 81.40 7.90 31 5.21 14-Jul 2014 7 980.70 28.30 80.20 9.40 32 5.29 14-Aug 2014 8 982.40 27.50 81.30 7.50 33 6.74 14-Sep 2014 9 984.70 27.10 77.70 8.50 34 4.80 14-Oct 2014 10 991.20 23.90 73.10 5.90 35 4.31 14-Nov 2014 11 993.30 18.60 79.60 6.20 36 4.35 14-Dec 2014 12 998.70 12.30 67.30 5.90 37 2.95 15-Jan 2015 1 996.70 13.30 76.30 6.20 38 4.63 15-Feb 2015 2 993.50 15.50 78.30 6.50 39 4.00 15-Mar 2015 3 991.70 17.70 83.40 6.30 40 4.16 15-Apr 2015 4 988.40 22.80 70.20 7.30 41 4.67 15-May 2015 5 982.40 26.70 80.50 8.00 42 5.62 15-Jun 2015 6 980.90 28.20 81.00 7.40 43 5.04 15-Jul 2015 7 980.20 27.30 79.40 6.70 44 5.79 15-Aug 2015 8 982.40 27.60 80.10 6.50 45 5.28 15-Sep 2015 9 986.30 26.00 84.60 6.50 46 4.39 15-Oct 2015 10 991.20 23.00 78.30 6.90 47 4.13 15-Nov 2015 11 993.50 19.40 85.30 6.90 48 3.30 15-Dec 2015 12 997.80 13.00 80.90 5.70 49 5.30 16-Jan 2016 1 996.00 11.80 82.30 6.40 50 4.57 16-Feb 2016 2 997.80 12.20 68.90 7.00 51 4.66 16-Mar 2016 3 991.70 17.00 78.90 7.00 52 4.01 16-Apr 2016 4 984.60 23.40 80.90 9.80 53 4.90 16-May 2016 5 983.80 25.50 78.70 8.30 54 3.75 16-Jun 2016 6 981.70 28.20 78.80 7.70 55 3.13 16-Jul 2016 7 981.10 28.90 77.60 7.60 56 3.25 16-Aug 2016 8 979.00 28.00 79.80 8.70 57 2.93 16-Sep 2016 9 984.30 26.60 75.20 6.40 58 2.93 16-Oct 2016 10 987.90 24.40 72.90 7.00 59 3.08 16-Nov 2016 11 993.40 18.10 79.60 6.70 60 2.99 16-Dec 2016 12 995.70 15.40 71.70 6.80 61 3.10 17-Jan 2017 1 994.70 14.50 79.20 6.50 62 3.75 17-Feb 2017 2 994.80 14.70 71.50 8.30 63 3.49 17-Mar 2017 3 990.20 16.50 83.60 8.50 64 3.36 17-Apr 2017 4 986.80 21.90 76.70 7.80 65 3.69 17-May 2017 5 985.00 24.80 77.50 10.00 66 3.76 17-Jun 2017 6 980.20 26.90 84.80 8.50 67 2.69 17-Jul 2017 7 981.00 27.50 83.60 9.80 68 3.05 17-Aug 2017 8 980.50 27.70 83.40 9.00 69 3.05 17-Sep 2017 9 984.20 27.60 81.50 7.10 70 2.46 17-Oct 2017 10 990.00 22.80 75.90 7.90 71 2.08 17-Nov 2017 11 993.00 17.80 79.50 7.00 72 2.32 17-Dec 2017 12 996.90 13.30 69.30 6.90 73 2.53 18-Jan 2018 1 992.10 12.00 78.40 8.10 74 3.29 18-Feb 2018 2 992.90 13.40 68.70 7.20 75 3.03 18-Mar 2018 3 988.30 19.20 78.20 9.10 76 2.30 18-Apr 2018 4 986.50 21.80 77.30 8.70 77 1.75 18-May 2018 5 982.60 26.70 79.40 8.90 78 2.03 18-Jun 2018 6 978.30 26.90 81.60 9.00 79 2.79 18-Jul 2018 7 976.80 27.90 82.10 9.20 80 2.32 18-Aug 2018 8 976.40 27.50 83.40 9.60 81 1.88 18-Sep 2018 9 983.50 26.10 80.10 8.90 82 2.76 18-Oct 2018 10 990.50 21.10 78.70 7.10 83 2.14 18-Nov 2018 11 991.50 18.20 80.30 7.10 84 1.78 18-Dec 2018 12 994.50 13.00 84.00 7.80 85 2.77 19-Jan 2019 1 995.20 11.70 84.50 7.30 86 4.60 19-Feb 2019 2 990.50 13.70 84.80 8.10 87 2.32 19-Mar 2019 3 987.70 17.30 85.90 9.90 88 2.07 19-Apr 2019 4 983.60 23.10 84.80 9.80 89 2.97 19-May 2019 5 981.80 24.30 83.20 7.70 90 2.48 19-Jun 2019 6 977.80 27.50 84.80 9.00 91 2.32 19-Jul 2019 7 977.20 27.80 85.00 8.90 92 2.06 19-Aug 2019 8 977.20 28.30 81.20 10.30 93 2.10 19-Sep 2019 9 984.60 26.40 72.70 8.20 94 2.89 19-Oct 2019 10 989.10 22.70 78.00 7.00
Upvotes: 1
Views: 369
Reputation: 11
My guess is that when you specify "knots= c(10)", 10 is within the range of temperature but not the same for humidity (if the min>10, then the lag can't be defined).
Upvotes: 1