I would like to apply the function 'fit.tcopula' from the package 'QRM' - Quantitative Risk Management and get the following error message:
fit.tcopula(Udata, method = 'Kendall')
Error: could not find function "forceAndCall"
Since I have applied the 'Udata' to different copulas from the package 'copula' already - and it worked fine - I assume the input is not an issue.
To my understanding 'forceAndCall' is part of the base package. I use the R version 3.1.3.
According to the documentation the QRM package depends R(>=3.0.1), so my version should be OK. However, listing all functions of my base package with
library(help = 'base')
reveals that the forceAndCall-Function is not there. What would the remedy be? Installing R version 3.2.1?
The reason I ask and not just do it is that I do not possess admin rights for my PC and therefore would be happy to get an opinion beforehand.
I posted the question though I already have the answer as it might be interesting to others.
Upgrading to R version 3.2.1 is the/one solution to the problem!
Related
I am trying to run through a mixed stock analysis in RStudio based on the walkthrough provided by Bolker (https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&doi=043730a02b148396ebd54b2f62e8f6364714b1b2), using the 'mixstock' package and the example 'lahanas98raw' dataset within. However, I am receiving a warning that the 'calc.RL.0' function cannot be found whilst trying to carry out Raftery and Lewis convergence diagnostics (p.14 of Bolker's walkthrough). I am wondering whether one of the packages has not installed properly (i.e., either 'mixstock' or 'coda'), or whether there is another package I can use to run this diagnostic instead.
When I initially tried to install the 'mixstock' package, the following warning came up:
'Warning in install.packages : package ‘mixstock’ is not available for this version of R.'
I tried installing the version of R (2.14.1) described as the 'current version of R' on page 2 of Bolker's walkthrough, but when I then tried to switch to this version of R in RStudio via the options menu, it says that this version of R is not compatible with RStudio. To work around this, I downloaded the 'mixstock' package (version 0.9.5.1) from the CRAN archive (https://cran.r-project.org/src/contrib/Archive/mixstock/) and uploaded it to RStudio this way instead.
This seemed to have worked, as I successfully ran through a significant amount of the code, but a new error arose when I tried to run Raftery and Lewis convergence diagnostics (p.14). When I try to run calc.RL.0(mydata), I receive the following error:
'Error in calc.RL.0(mydata) : could not find function "calc.RL.0"'
However, when I click on 'mixstock' in the package window, everything seems fine and the 'calc.RL.0' function appears, alongside several other 'calc' functions (e.g. 'calc.GR', 'calc.mult.GR', 'calc.mult.RL') that can all be found and run fine. The 'calc.RL.0' function relies on the 'raftery.diag' function within the 'coda' package, so I have also made sure that is installed and called. I have tried a bunch of other methods but nothing seems to be working.
Here is some of my code leading up to the warning message:
## Calculate confidence intervals - i.e., bootstrapping - and plot them
mydata.umlboot = genboot(mydata,"uml")
confint(mydata.umlboot)
plot(mydata.umlboot, ylim=c(0,1))
## Carry out Markov Chain Monte Carlo (MCMC) estimations and plot them
mydata.mcmc = tmcmc(mydata)
mydata.mcmc
confint(mydata.mcmc)
plot(mydata.mcmc, ylim=c(0,1))
## Check that the Markov chains have converged = run Raftery and Lewis diagnostics
library(mixstock)
library(coda)
calc.RL.0(mydata)
'Error in calc.RL.0(mydata) : could not find function "calc.RL.0"'
Could this be something to do with the way the 'mixstock' package was initially installed, or is it likely to be another issue? Is there another way to run Raftery and Lewis diagnostics and still get the outputs I need (diagnostics for the last chain evaluated; the history of how long each suggested chain was)? Any help would be much appreciated - thanks in advance!
The most reliable way to install mixstock, if you have development tools installed on your computer (compilers etc.), is remotes::install_github("bbolker/mixstock") (I don't think I've changed anything/fixed any bugs since the archived version, but if I did the changes would be reflected on GitHub.)
It looks like I forgot to export that function, so
mixstock:::calc.RL.0(mydata)
should work (this is something I can/should fix). Note that the Gelman-Rubin diagnostic (calc.GR(), which is properly exported) is more reliable than Raftery-Lewis anyway ...
I'm trying to use the Psycho package to analyze a model. I've tried installing Psycho through CRAN as well as install_github and the installation worked. The package is loaded but the analyze function is not being recognized. I've tried psycho::analyze which also does not work. Following this question I also installed and loaded statnet.common. Any suggestions?
Error in analyze(m2, CI = 95) : could not find function "analyze"
For any future person that comes across this, I was also having problems with the analyze() function. One can use the following solution that worked for me:
> install.packages("remotes")
> remotes::install_github("easystats/report")
> library("report")
> report(m2) # use this instead of analyze()
I had the same issue while trying to follow this tutorial: https://neuropsychology.github.io/psycho.R//2018/05/01/repeated_measure_anovas.html
(and I wish it was updated, unfortunately it still refers to outdated functions).
Potential solutions (alternative library) are discussed on this page: https://github.com/easystats/easystats/issues/58
Unfortunately, I have not managed to get these to work, but other people commented that the solutions worked for them.
I need to perform an analytic hierarchical process (AHP) on a dataset using R. I have basic understanding of navigation and can follow most guides to perform rudiment analyses. However, I'm not comfortable enough to be sure if I or the guide is wrong.
The guide I've followed is this: https://www.r-bloggers.com/analytic-hierarchy-process-ahp-with-the-ahp-package/.
(I run R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch")
1: I have (successfully) installed and loaded the AHP package using:
devtools::install_github("gluc/ahp", build_vignettes = install.packages("data.tree"))
2: I have (successfully) set working directory using:
setwd("myworkingdirectory")
3: I have attempted (PROBLEM) loaded the file to a variable using:
myahp <- LoadFile("myAHPfile.txt")
Error: could not find function "LoadFile"
3x: As diagnosis I run:
getAnywhere("LoadFile")
no object named ‘LoadFile’ was found
For your information: Step 3x is inspired by this SO answer (Error: could not find function ... in R)
Can someone tell me what I am doing wrong? I greatly appreciate any help.
Both. The guide refers to an old version of the gap package from github. With the latest version from cran (0.2.11), the function is now called Load, and the file format has changed.
If you just want to goof around with the package, I can recommend the online app at ipub.com.
If you insist on following the guide, make sure you get version 0.1.1 from github
very new to R, and this is my first question so please be kind :)
I was working with the choroplethr/choroplethrMaps/choroplethrZip packages for a few days without any issues, but suddenly, I keep getting the an error when I try to visualize a map--I have pasted the output below, and any help would be deeply appreciated.
The most perplexing issue for me is why it suddenly stopped working--I didn't add anything to the script--I get the same error with choroplethr/choroplethrMaps as well. Many thanks for your expertise and patience!
data(df_pop_zip)
choro = ZipChoropleth$new(df_pop_zip)
choro$title = "2012 ZCTA Population Estimates"
choro$ggplot_scale = scale_fill_brewer(name="Population", palette=2, drop=FALSE)
choro$set_zoom_zip(state_zoom="florida", county_zoom=NULL, msa_zoom=NULL, zip_zoom=NULL)
choro$render()
Error in FUN(X[[i]], ...) : attempt to apply non-function
I believe that your error can be solved by typing the following:
# install.packages("devtools")
library(devtools)
install_github("choroplethr", "arilamstein")
library(choroplethr)
If I install choroplethr from CRAN I can replicate your error. If I install it from github I can solve it. Note that the actual R code is currently the same in both github and CRAN, because I recently submitted a new version to CRAN.
When I load the version of choroplethr from CRAN I get this warning:
> library(choroplethr)
Warning message:
package ‘choroplethr’ was built under R version 3.2.4
However, the current version of R is 3.2.3. So it looks like CRAN is using different version of R for what they are distrbuting to the public and what they are using to build packages. I'm not sure why this is.
Note that while I think this solution will work for you, I don't find it particularly satisfying or elegant. I could probably install the development version of R to see if I can replicate (and debug) the issue myself. But at this point I'd rather wait until they officially release the new version to see if it is still present. I really don't have much experience with the development versions of R.
I am attempting to run the R code from this question
and I get the following error:
Error in rename(x, .base_to_ggplot, warn_missing = FALSE) :
could not find function "revalue"
I wonder whether it's an incompatibility between the R version I'm using and ggplot2 (v. 0.9.3.1). Is anybody aware of this problem, or is my issue something else?
Yes, ggplot2 works with the current version of R (3.0.1)
revalue is not a function in ggplot2, it's a function in plyr as pointed out in the comments.
A simple google search function revalue R will reveal this. Many packages depend on one another - so when you see an error like the one above, you need to use google/some other resource to find which package the missing function is from.