Ashim Kapoor
2019-Jan-23 06:37 UTC
[R] Unable to compute Confidence Intervals from output from MARSS package
Dear All, I am trying to use this package ---> https://cran.r-project.org/web/packages/MARSS/index.html I am reading this book which shows some examples based on the above package ---> https://nwfsc-timeseries.github.io/atsa-labs/ In a few words, the incantation MARSS(...) estimates the parameters and MARSSparamCIs should return the confidence intervals. My problem is that MARSSparamCIs returns this error :-> MARSSparamCIs(fit)Error in MARSSharveyobsFI(MLEobj) : replacement has length zero>### This page and the next page, explains the jargon used : https://nwfsc-timeseries.github.io/atsa-labs/sec-dlm-example-of-a-univariate-dlm.html ### Here is a MWE to recreate the error :- # This is a Time Varying Parameters regression # Here a is fixed and b is doing a RW. x1 <- rnorm(1000) b <- cumsum(rnorm(1000, sd = sqrt(.6))) y <- 1 + b*x1 + rnorm(1000) Z = array(NA,c(1,2,1000)) Z[1,1,] = rep(1,1000) Z[1,2,] = x1 mod2.list = list ( B = matrix(c(1,0,0,1),nrow = 2 , byrow = T), U matrix(0,2,1), Q = matrix(list(0,0,0,"s2b"),2,2), Z= Z, A = matrix(0), R = matrix("r")) fit = MARSS(as.vector(y), model = mod2.list,inits list(x0=matrix(0,nrow=2,ncol=1))) MARSSparamsCIs(fit) # The above will give this error : Error in MARSSharveyobsFI(MLEobj) : replacement has length zero Best Regards, Ashim [[alternative HTML version deleted]]
Bill Poling
2019-Jan-23 18:45 UTC
[R] Unable to compute Confidence Intervals from output from MARSS package
sessionInfo()
#R version 3.5.2 (2018-12-20)
#Platform: x86_64-w64-mingw32/x64 (64-bit)
#Running under: Windows >= 8 x64 (build 9200)
Hello Ashim. I am not familiar with the MARSS pkg, however, I am always
interested in following many of these R-Help questions and often run them for my
own edification.
I ran your script and it appears to have run successfully, however, when I
(naively) use the suggested "# Use MARSSparamCIs to compute CIs and bias
estimates." below as you did I get a different error.
# I GET THIS ERROR
#Error in MARSSparamsCIs(fit) : could not find function
"MARSSparamsCIs"
After further googling I find that I was (as suspected) incorrect in using
" MARSSparamsCIs" as a function on fit or maybe not, take a look at
this URL
https://rdrr.io/cran/MARSS/man/MARSSparamCIs.html
I'm not sure how to proceed but this is interesting to follow, thank you.
WHP
x1 <- rnorm(1000)
View(x1)#----------------------Just curious
plot(x1)#----------------------Just curious
b <- cumsum(rnorm(1000, sd = sqrt(.6)))
plot(b)#----------------------Just curious
y <- 1 + b*x1 + rnorm(1000)
plot(y)#----------------------Just curious
Z = array(NA,c(1,2,1000))
Z[1,1,] = rep(1,1000)
Z[1,2,] = x1
mod2.list = list ( B = matrix(c(1,0,0,1),nrow = 2 , byrow = T),
U = matrix(0,2,1),
Q = matrix(list(0,0,0,"s2b"),2,2),
Z= Z, A = matrix(0), R = matrix("r"))
View(mod2.list)
#print(mod2.list)
str(mod2.list)#---------------------------------KNOW THY DATA
#List of 6
# $ B: num [1:2, 1:2] 1 0 0 1
# $ U: num [1:2, 1] 0 0
# $ Q:List of 4
# ..$ : num 0
# ..$ : num 0
# ..$ : num 0
# ..$ : chr "s2b"
# ..- attr(*, "dim")= int [1:2] 2 2
# $ Z: num [1, 1:2, 1:1000] 1 1.2 1 1.04 1 ...
# $ A: num [1, 1] 0
# $ R: chr [1, 1] "r"
fit = MARSS(as.vector(y), model = mod2.list,inits =
list(x0=matrix(0,nrow=2,ncol=1)))
#Success! abstol and log-log tests passed at 27 iterations.
# Alert: conv.test.slope.tol is 0.5.
# Test with smaller values (<0.1) to ensure convergence.
#
# MARSS fit is
# Estimation method: kem
# Convergence test: conv.test.slope.tol = 0.5, abstol = 0.001
# Estimation converged in 27 iterations.
# Log-likelihood: -1758.409
# AIC: 3524.818 AICc: 3524.858
#
# Estimate
# R.r 1.026
# Q.s2b 0.606
# x0.X1 0.999
# x0.X2 -1.025
# Initial states (x0) defined at t=0
#
# Standard errors have not been calculated.
# Use MARSSparamCIs to compute CIs and bias estimates.
MARSSparamsCIs(fit)
#I GET THIS ERROR
#Error in MARSSparamsCIs(fit) : could not find function
"MARSSparamsCIs"
#NOT THIS ERROR
# The above will give this error :
#Error in MARSSharveyobsFI(MLEobj) : replacement has length zero
WHP
From: R-help <r-help-bounces at r-project.org> On Behalf Of Ashim Kapoor
Sent: Wednesday, January 23, 2019 1:38 AM
To: r-help at r-project.org
Subject: [R] Unable to compute Confidence Intervals from output from MARSS
package
Dear All,
I am trying to use this package --->
https://cran.r-project.org/web/packages/MARSS/index.html
I am reading this book which shows some examples based on the above package
---> https://nwfsc-timeseries.github.io/atsa-labs/
In a few words, the incantation MARSS(...) estimates the parameters and
MARSSparamCIs should return the confidence intervals. My problem is that
MARSSparamCIs returns this error :-
> MARSSparamCIs(fit)
Error in MARSSharveyobsFI(MLEobj) : replacement has length
zero>
### This page and the next page, explains the jargon used :
https://nwfsc-timeseries.github.io/atsa-labs/sec-dlm-example-of-a-univariate-dlm.html
### Here is a MWE to recreate the error :-
# This is a Time Varying Parameters regression
# Here a is fixed and b is doing a RW.
x1 <- rnorm(1000)
b <- cumsum(rnorm(1000, sd = sqrt(.6)))
y <- 1 + b*x1 + rnorm(1000)
Z = array(NA,c(1,2,1000))
Z[1,1,] = rep(1,1000)
Z[1,2,] = x1
mod2.list = list ( B = matrix(c(1,0,0,1),nrow = 2 , byrow = T), U matrix(0,2,1),
Q = matrix(list(0,0,0,"s2b"),2,2), Z= Z, A = matrix(0), R =
matrix("r"))
fit = MARSS(as.vector(y), model = mod2.list,inits
list(x0=matrix(0,nrow=2,ncol=1)))
MARSSparamsCIs(fit)
# The above will give this error :
Error in MARSSharveyobsFI(MLEobj) : replacement has length zero
Best Regards,
Ashim
[[alternative HTML version deleted]]
______________________________________________
mailto:R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Confidentiality Notice This message is sent from Zelis. ...{{dropped:13}}
Bill Poling
2019-Jan-23 19:19 UTC
[R] Unable to compute Confidence Intervals from output from MARSS package
Ashim. I see where I was mistaken, using MARSSparamsCIs(fit) <--Somehow I got an s in between param & Cis. I now get new error similarly as you, my apologies. final <- MARSSparamCIs(fit) Error in dpari[time.varying] <- dparmat(MLEobj, time.varying, t = t) : replacement has length zero WHP From: R-help <r-help-bounces at r-project.org> On Behalf Of Ashim Kapoor Sent: Wednesday, January 23, 2019 1:38 AM To: r-help at r-project.org Subject: [R] Unable to compute Confidence Intervals from output from MARSS package Dear All, I am trying to use this package ---> https://cran.r-project.org/web/packages/MARSS/index.html I am reading this book which shows some examples based on the above package ---> https://nwfsc-timeseries.github.io/atsa-labs/ In a few words, the incantation MARSS(...) estimates the parameters and MARSSparamCIs should return the confidence intervals. My problem is that MARSSparamCIs returns this error :-> MARSSparamCIs(fit)Error in MARSSharveyobsFI(MLEobj) : replacement has length zero>### This page and the next page, explains the jargon used : https://nwfsc-timeseries.github.io/atsa-labs/sec-dlm-example-of-a-univariate-dlm.html ### Here is a MWE to recreate the error :- # This is a Time Varying Parameters regression # Here a is fixed and b is doing a RW. x1 <- rnorm(1000) b <- cumsum(rnorm(1000, sd = sqrt(.6))) y <- 1 + b*x1 + rnorm(1000) Z = array(NA,c(1,2,1000)) Z[1,1,] = rep(1,1000) Z[1,2,] = x1 mod2.list = list ( B = matrix(c(1,0,0,1),nrow = 2 , byrow = T), U matrix(0,2,1), Q = matrix(list(0,0,0,"s2b"),2,2), Z= Z, A = matrix(0), R = matrix("r")) fit = MARSS(as.vector(y), model = mod2.list,inits list(x0=matrix(0,nrow=2,ncol=1))) MARSSparamsCIs(fit) # The above will give this error : Error in MARSSharveyobsFI(MLEobj) : replacement has length zero Best Regards, Ashim [[alternative HTML version deleted]] ______________________________________________ mailto:R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Confidentiality Notice This message is sent from Zelis. ...{{dropped:13}}
Ashim Kapoor
2019-Jan-24 04:11 UTC
[R] Unable to compute Confidence Intervals from output from MARSS package
Dear Bill, Appreciate all your effort. I hope some one here can respond to this query. Many thanks, Ashim On Thu, Jan 24, 2019 at 12:49 AM Bill Poling <Bill.Poling at zelis.com> wrote:> > Ashim. > > I see where I was mistaken, using MARSSparamsCIs(fit) <--Somehow I got an > s in between param & Cis. > > I now get new error similarly as you, my apologies. > > final <- MARSSparamCIs(fit) > Error in dpari[time.varying] <- dparmat(MLEobj, time.varying, t = t) : > replacement has length zero > > WHP > > From: R-help <r-help-bounces at r-project.org> On Behalf Of Ashim Kapoor > Sent: Wednesday, January 23, 2019 1:38 AM > To: r-help at r-project.org > Subject: [R] Unable to compute Confidence Intervals from output from MARSS > package > > Dear All, > > I am trying to use this package ---> > https://cran.r-project.org/web/packages/MARSS/index.html > I am reading this book which shows some examples based on the above package > ---> https://nwfsc-timeseries.github.io/atsa-labs/ > > In a few words, the incantation MARSS(...) estimates the parameters and > MARSSparamCIs should return the confidence intervals. My problem is that > MARSSparamCIs returns this error :- > > > MARSSparamCIs(fit) > Error in MARSSharveyobsFI(MLEobj) : replacement has length zero > > > > ### This page and the next page, explains the jargon used : > > https://nwfsc-timeseries.github.io/atsa-labs/sec-dlm-example-of-a-univariate-dlm.html > > ### Here is a MWE to recreate the error :- > > # This is a Time Varying Parameters regression > # Here a is fixed and b is doing a RW. > > x1 <- rnorm(1000) > b <- cumsum(rnorm(1000, sd = sqrt(.6))) > y <- 1 + b*x1 + rnorm(1000) > > Z = array(NA,c(1,2,1000)) > Z[1,1,] = rep(1,1000) > Z[1,2,] = x1 > > mod2.list = list ( B = matrix(c(1,0,0,1),nrow = 2 , byrow = T), U > matrix(0,2,1), > Q = matrix(list(0,0,0,"s2b"),2,2), Z= Z, A = matrix(0), R = matrix("r")) > > fit = MARSS(as.vector(y), model = mod2.list,inits > list(x0=matrix(0,nrow=2,ncol=1))) > > MARSSparamsCIs(fit) > > # The above will give this error : > Error in MARSSharveyobsFI(MLEobj) : replacement has length zero > > Best Regards, > Ashim > > [[alternative HTML version deleted]] > > ______________________________________________ > mailto:R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > Confidentiality Notice This message is sent from Zelis. This transmission > may contain information which is privileged and confidential and is > intended for the personal and confidential use of the named recipient only. > Such information may be protected by applicable State and Federal laws from > this disclosure or unauthorized use. If the reader of this message is not > the intended recipient, or the employee or agent responsible for delivering > the message to the intended recipient, you are hereby notified that any > disclosure, review, discussion, copying, or taking any action in reliance > on the contents of this transmission is strictly prohibited. If you have > received this transmission in error, please contact the sender immediately. > Zelis, 2018. > > >[[alternative HTML version deleted]]