missing functions in spatstat library (such as Kest, and rpoint) - r

i'm trying to use the Kest function (and many other in the spatstat package).
i have made a ppp point pattern data set (ppp.1)
summary (ppp.1)
Planar point pattern: 189 points
Average intensity 241122300 points per square unit
Coordinates are given to 6 decimal places
Window: rectangle = [40.74603, 40.74662] x [-111.84693, -111.8456] units
(0.000592 x 0.001324 units)
Window area = 7.83834e-07 square units
when i try to use the Kest function: Kest(ppp.1), i get the following error:
Error in Kest(ppp.1) : could not find function "Kest"
in fact, there are many functions in the spatstat package that can't be found (e.g., rpoint)... i get the same error.
does this have anything to do with "spatstat.random" not being found when i load the spatstat library:
Error: package ‘spatstat.random’ required by ‘spatstat’ could not be found
i'm using the most current version of R and spatstat (on an intel Mac):
R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)
spatstat 2.3-4 downloaded installed directly from R.
thank you.

Some time ago spatstat was one big package containing all the functions you mention, but due to technical requirements from CRAN it has now been split into several smaller packages all named according to the scheme spatstat.xxxx such as spatstat.random. The package spatstat is now an umbrella package with barely any functions, but it depends on spatstat.random and others, and it loads all these packages when you execute library(spatstat) in the R console.
Under normal circumstances R should refuse to install spatstat without all the needed sub-packages, but it appears you have an installation of spatstat without e.g. spatstat.random. Probably the easiest solution is to remove spatstat and install it again:
remove.packages("spatstat")
install.packages("spatstat", dependencies = TRUE)
Alternatively you can try (requires a relatively new version of spatstat to already be installed):
pkgs <- spatstat::spatstat.family()
install.packages(pkgs)

To find information about a package, you can visit its CRAN page (go to cran.r-project.org and look for Contributed Packages).
The CRAN page for spatstat says that spatstat 2.3-4 requires the packages spatstat.random and spatstat.core. This means that spatstat depends on code that is provided in these other packages.
Your error message says that spatstat.random is missing. This explains why the random generation function rpoint was not found.
As #EgeRubak says, the best solution is to remove and re-install spatstat.

Related

Is there an R package that runs "Spatial Vector Autoregression"?

I am looking for an R package which can run "Spatial Vector Autoregression".
tandfonline.com/doi/full/10.1080/17421770701346689
According to Chen and Conley (2001), this is a "vector autoregression (VAR) whose coefficient matrix and shock covariance matrix are functions of economic distances between agents. The impact of other agents’ variables on the conditional mean of a given agent’s variable is a function of their economic distances from this agent. Similarly, covariances of VAR shocks are functions of distances between agents in the previous period, a property we refer to as being isotropic."
(Chen, X & Conley, T.G. (2001) A new semiparametric spatial model for panel
time series, Journal of Econometrics, 105, 59–83)
Surprisingly, however, I could only see until "Spatial Autoregression" which is still not what I need for my purpose. May I get help finding the package for this please? Otherwise, may I know an official way to run this Spatial Vector Autoregression model using R programming?
I think I've found what you're looking for, devtools::install_github("James-Thorson/VAST"). VAST stands for "Vector-Autoregressive Spatio-Temporal." This package is a wrapper around a package that incorporates spatial modeling. Essentially it adds to it.
You can see coding examples here. If you want to look at help, use ?VAST::VAST and select one of the three hyperlinks at the bottom of the short description and details (make_settings, fit_model, and plot_results).
Please note:
When I installed this package to check out what it included, it came back with a conflict that the package TMB required an earlier version of the Matrix package. I had not had TMB installed before installing this package. I had no issues installing TMB independently (without a conflict with the version of the Matrix package). However when I called the library VAST it still gave me that error. When I called the library TMB, then the library VAST I didn't receive the warning and both libraries loaded.

package ‘Zelig’ is not available for R version 3.6.3

I want to use the Zelig package to get the ATT (Average treatment effect on treated) and ATE (Average treatment effect) after performing PSM (propensity score matching) using Nearest-neighbor matching method.
After going through all the related issues I found that Zelig has no compatibility with R version 3.6.3.
I would like to ask if there is any possible way to run the above package on macOS Catalina 10.15.4 and R: version 3.6.3.
If not, Is there any other way to get the ATT and ATE after performing PSM matching using MatchIt/Match. I would really appreciate a way out.
Thanks in advance.
Zelig has been removed from CRAN. See
https://cran.r-project.org/web/packages/Zelig/index.html
On the archive page, the last version appears to have been 5.1.6. You can get it using
remotes::install_version("Zelig", "5.1.6")

fmincon in R - disappeared from 'pracma' package?

In the 'pracma' package manual there is function fmincon to Minimize Nonlinear Constrained Multivariable Function (page 116). However I've installed this package, but there is no such function.
Has it been removed from this package?
Could anyone indicate any other R ackage or function with such funcionality (Minimize Nonlinear Constrained Multivariable Function) ?
What version of pracma do you have installed? The manual you linked to is from version 2.2.5, and that's also the version on CRAN, and it does have fmincon.
Perhaps you forgot
library(pracma)
to attach it? Installing isn't enough to make the contents visible.

R programming spectrum analysis

hello am new to R programming in r studio . I will be analyzing the spectral data of raman spectrum in future.
which package will be useful to for the spectral data analysis.I would like to learn that package. I have attached the image how I want to analyze. Please give me suggestions, how to plot the graph as shown in the fig in r studio
thanks in advance
There is a free package called hyperSpec that was specifically designed to handle spectral data together with associated extra data (e.g. experimental parameters etc.). The package also provides interface for common operations, like baseline correction, selection of spectral ranges, normalization, PCA, etc. Moreover, there is a host of plotting functions.
You can install it from CRAN with install.packages("hyperSpec"), however, as of today the CRAN version is outdated. I would recommend you to fetch the recent build from gitHub and install it via Rstudio (look for packages->install->from package archive file).
hyperSpec comes with an extensive documentation and example datasets. To browse through tutorials, run
browseVignettes("hyperSpec")
Plotting is as easy as
plot(chondro) # left plot
qplotspc(chondro) + ggtitle("Example dataset") # right plot
To import your own data, look for functions inside of hyperSpec, whose name starts with read. Just start typing hyperSpec::read and a pop-up will appear. A lot of device-specific data formats are supported. See vignette("fileio") for details.

Bivariate Poisson Regression in R?

I found a package 'bivpois' for R which evaluates a model for two related poisson processes (for example, the number of goals by the home and the away team in a soccer game). However, this package seems to no longer be useable in newer versions of R.
Is there a reasonable way to modify the glm() function to do a similar process, or run this older package on my new version of R? I have found very little literature on these sorts of processes and have found very little in terms of easy implementation in other statistical packages like STATA.
Any suggestions would be much appreciated.
While CRAN does not host a current binary of bivpois, you can build the package from the archived source code (see http://cran.r-project.org/doc/manuals/R-exts.html#Checking-and-building-packages ). Building bivpois 0.50-3.1 from source (available at http://cran.r-project.org/src/contrib/Archive/bivpois/) works for me on R 2.15.0 Windows x64. The zipped Windows binary I built is available here: http://commondatastorage.googleapis.com/jthetzel-public/bivpois_0.50-3.1.zip .
You can feel free to refer to odds modelling and testing inefficiency of sports-bookmakersas I had modified the relevant functions inside bivpois package.

Resources