r - I would like to apply msmFit function to each day of minutely time series. How could I build a list of 'lm' class object? -


i have 3 months time series minutely data , need perform msmfit function each day. function comes 'mswm package'. time series xts object.

i split data 'split' function in way:

us.data.daily<-split(us.data2,"days")

the results 'list' object 91 1 elements. 'msmfit' requires 'lm' object input used 'lapply' , 'lm' functions 'us.data.daily' data in way:

mod<-lapply(us.data.daily,function(x) lm(spread~volatility,data=as.data.frame(x),na.action=na.exclude))

now apply msmfit each element of 'mod' list, here code:

mod_mswm<-lapply(mod,function(x) msmfit(mod,k=2,p=0,sw=c(t,t,t),control=list(parallel=f)))

it returns error message:

error in (function (classes, fdef, mtable) : unable find inherited method function ‘msmfit’ signature ‘"list", "numeric", "logical", "numeric", "missing", "missing"’

i supposing problem list 'mod' boult 'list' class elements , not elements 'lm' class. because class(mod[1]) gives me 'list'

i tried with: class(mod[1]) <-c("lm") doesn't work.

i have fund suggestions heremake list of lm objects, retain class, can't write 91 times. looking quicklier way

anyone knows if problem due reason? how solve problem or how convert element within list 'lm' class? don't have change class of entire list, class of each element.

ok, asked here there output given dput function. after: mod_mswm <- lapply(mod, function(x) try(msmfit(x, k=2,p=0,sw=c(t,t,t),control=list(parallel=f))))

and: dput(mod_mswm_1, file = "mod_mswm_1") output is:

list(structure("error in if ((max(abs(object[\"fit\"][\"loglikel\"] - oldll))/(0.1 + max(abs(object[\"fit\"][\"loglikel\"]))) < : \n missing value true/false needed\n", class = "try-error", condition = structure(list( message = "missing value true/false needed", call = if ((max(abs(object["fit"]["loglikel"] - oldll))/(0.1 + max(abs(object["fit"]["loglikel"]))) < control$tol) & (max(abs(object["coef"] - oldcoef))/(0.1 + max(abs(object["coef"]))) < control$tol)) break), .names = c("message", "call"), class = c("simpleerror", "error", "condition"))), <s4 object of class structure("msm.lm", package = "mswm")>, <s4 object of class structure("msm.lm", package = "mswm")>, structure("error in if ((max(abs(object[\"fit\"][\"loglikel\"] - oldll))/(0.1 + max(abs(object[\"fit\"][\"loglikel\"]))) < : \n missing value true/false needed\n", class = "try-error", condition = structure(list( message = "missing value true/false needed", call = if ((max(abs(object["fit"]["loglikel"] - oldll))/(0.1 + max(abs(object["fit"]["loglikel"]))) < control$tol) & (max(abs(object["coef"] - oldcoef))/(0.1 + max(abs(object["coef"]))) < control$tol)) break), .names = c("message", "call"), class = c("simpleerror", "error", "condition"))), structure("error in if ((max(abs(object[\"fit\"][\"loglikel\"] - oldll))/(0.1 + max(abs(object[\"fit\"][\"loglikel\"]))) < : \n missing value true/false needed\n", class = "try-error", condition = structure(list( message = "missing value true/false needed", call = if ((max(abs(object["fit"]["loglikel"] - oldll))/(0.1 + max(abs(object["fit"]["loglikel"]))) < control$tol) & (max(abs(object["coef"] - oldcoef))/(0.1 + max(abs(object["coef"]))) < control$tol)) break), .names = c("message", "call"), class = c("simpleerror", "error", "condition"))), <s4 object of class structure("msm.lm", package = "mswm")>, <s4 object of class structure("msm.lm", package = "mswm")>, <s4 object of class structure("msm.lm", package = "mswm")>, <s4 object of class structure("msm.lm", package = "mswm")>, <s4 object of class structure("msm.lm", package = "mswm")>, structure("error in if ((max(abs(object[\"fit\"][\"loglikel\"] - oldll))/(0.1 + max(abs(object[\"fit\"][\"loglikel\"]))) < : \n missing value true/false needed\n", class = "try-error", condition = structure(list( message = "missing value true/false needed", call = if ((max(abs(object["fit"]["loglikel"] - oldll))/(0.1 + max(abs(object["fit"]["loglikel"]))) < control$tol) & (max(abs(object["coef"] - oldcoef))/(0.1 + max(abs(object["coef"]))) < control$tol)) break), .names = c("message", "call"), class = c("simpleerror", "error", "condition"))), structure("error in if ((max(abs(object[\"fit\"][\"loglikel\"] - oldll))/(0.1 + max(abs(object[\"fit\"][\"loglikel\"]))) < : \n missing value true/false needed\n", class = "try-error", condition = structure(list( message = "missing value true/false needed", call = if ((max(abs(object["fit"]["loglikel"] - oldll))/(0.1 + max(abs(object["fit"]["loglikel"]))) < control$tol) & (max(abs(object["coef"] - oldcoef))/(0.1 + max(abs(object["coef"]))) < control$tol)) break), .names = c("message", "call"), class = c("simpleerror", "error", "condition"))), <s4 object of class structure("msm.lm", package = "mswm")>, structure("error in solve.default(res$hessian) : \n system computationally singular: reciprocal condition number = 2.66759e-17\n", class = "try-error", condition = structure(list( message = "system computationally singular: reciprocal condition number = 2.66759e-17", call = solve.default(res$hessian)), .names = c("message", "call"), class = c("simpleerror", "error", "condition"))), <s4 object of class structure("msm.lm", package = "mswm")>)

not tested, this:

mod_mswm <-   lapply(split(us.data2,"days"),          function(x)            msmfit(mod,                   lm(spread~volatility,data=as.data.frame(x),na.action=na.exclude),                   k=2,p=0,sw=c(t,t,t),control=list(parallel=f))) 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -