[R] KalmanSmooth problem
Uwe Ligges
ligges at statistik.uni-dortmund.de
Wed Jul 7 20:36:57 CEST 2004
Hazenberg21, Pieter wrote:
> Hello,
> In R I am trying to use Kalman filtering to find a solution for an hydrological problem. With Kalman Filtering I want to estimate the discharge comming from three storage bassins. I have programmed a function in R which can run KalmanSmooth. When I'm asking for the function and putting in values, R detects the following error: "Error in as.vector(data) : Argument "S1" is missing, with no default".
> I have try to find a solution for this error in the R help file, and in different manuals, but I can't find it. Please help me find a solution.
> Question: What does R mean with "S1" and what am I doing wrong?
> Here is the way I have programmed the hydrological problem in R.
>
>
>>discharge=read.table(file="C:/Program Files/R/rw1090/discharge.txt",header=T)
>>deb=discharge[,1]
>>deb
>
> [1] 11.545313 8.045465 5.670868 4.044584 2.919311 2.306668 2.940956
> [8] 4.238159 5.017374 3.818236 2.928805 2.262183 1.757765 1.633945
> [15] 2.295130 3.454054 4.035224 3.193967 2.533181 2.012406 1.600836
> [22] 1.652155 2.428678 3.642827 4.019545 3.209473 2.563617 2.048347
> [29] 1.637041 1.828952 2.757842 4.050821 4.147013 3.316503 2.652490
> [36] 2.121535 1.696934 2.027763 3.107366 4.429670 4.160178 3.327950
> [43] 2.662237 2.129710 1.703717 2.158095 3.337039 4.582359 3.905901
> [50] 3.124690 2.499732 1.999772 1.599810 2.130893 3.302622 4.336081
> [57] 3.468857 2.775081 2.220062 1.776048 1.560859 2.169537 3.348081
> [64] 4.170552 3.336440 2.669151 2.135320 1.708256 1.648859 2.374217
> [71] 3.624091 4.248563 3.398850 2.719080 2.175264 1.740211 1.826122
> [78] 2.704749 4.056438 4.437309 3.549847 2.839878 2.271902 1.817522
> [85] 2.053994 3.107875 4.548436 4.600601 3.680481 2.944385 2.355508
> [92] 1.884406 2.273248 3.490148 4.949898 4.584409 3.667527 2.934022
> [99] 2.347217 1.877774
>
>>Kalm = function(x,O1,O2,O3,T1,T2,T3,T4,T5,t,ga){
>
> + t=array(c(1+ga*O1+t/O1*(-(1/T2)-(1/T3)-(1/T1)),t/O1*(1/T2),t/O1*(1/T3),
> + t/O2*(1/T2),1+ga*O2+t/O2*(-(1/T2)-(1/T4)),t/O2*(1/T4),
> + t/O3*(1/T3),t/O3*(1/T4),1+ga*O3+t/O3*(-(1/T3)-(1/T4)-(1/T5))),dim=c(3,3));
> + h=0.5;
> + r=array(c(1,0,0,0,1,0,0,0,1),dim=c(3,3));
> + q=1;
> + v=r*q*t(r);
> + a=10.14286;
> + z=array(c((1/T1),0,0,0,0,0,0,0,(1/T5)), dim=c(3,3));
> + p=array(c(1,0,0,0,1,0,0,0,1),dim=c(3,3));
> + pn=array(c(1,0,0,0,1,0,0,0,1),dim=c(3,3));
> + kal=KalmanSmooth(x, list(T=t,Z=z,h=h,V=v,a=a,P=p,Pn=pn), nit=0)
> + kal}
>
>
>>Kalm(deb,4,.5,5,.7,.1,2,3,4,1,0.65)
>
> Error in as.vector(data) : Argument "S1" is missing, with no default
>
> First I thought I had to make a timeserie of deb. But this doesn't change the problem.
> Lot's of thanks trying to help me.
a) Please tell us R Version and OS (OK, implicitly done that we are
talking about R-1.9.0 on Windows).
b) Please tell us which packages you are using (I don't know
KalmanSmooth(), for example).
c) Please try to specify reproducible examples.
Conclusion for a-c): Please read the posting-guide.
My hint is to try to debug yourself, at least *try*, starting eith
calling traceback() right after the error appeared, in order to get a
guess where the error really happens. Then look at the data that is
passed to the function - and I'm pretty sure you will get at least an
idea what goes wrong.
Uwe Ligges
> Best regards,
> Pieter Hazenberg
> Student Hydrology and Watermanagement
> Wageningen University
> The Netherlands
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list