Displaying 20 results from an estimated 4000 matches similar to: "reason for error in small function?"
2013 Feb 21
2
error with bbox for k12hat (splancs) bivarite k-function
Hello,
I am trying to conduct a bi-variate ripley's k using the k12hat function in
the splancs package (found here
http://rss.acs.unt.edu/Rdoc/library/splancs/html/k12hat.html). Although, I
receive an error when getting to the bboxx part of the code:
poly <- list(x=c(fire4$X, nar4$X), y=c(fire4$Y, nar4$Y))
plot(seq(5,80,5), sqrt(k12hat(fire4), as.points(nar4),
2012 Nov 23
1
Spatstat: Mark correlation function
I normally use the following code to create a figure displaying the mark
correlation function for the point pattern process "A":
M<-markcorr(A)
plot(M)
I have now started to use the following code to perform 1000 Monte Carlo
simulations of Complete Spatial Randomness (CSR). It is a Monte Carlo test
based on envelopes of the Mark correlation function obtained from simulated
point
2007 Dec 17
1
polygon class in splancs package
Dear forum,
I would like to use the kernel2d or spkernel2d in the Splancs-package, but
it does not recognize my polygon data.
"Error in kernel2d(as.points(ptsbin), polygonprov, h0 = 2, nx = 100, : " is
the error message.
Invalid poly argument
The data are defined as follows:
polgonprov<-list(x=polyprov$X, y=polyprov$Y) with X and Y coordinates in the
Lambert1972
2011 Feb 17
1
How to speed up a for() loop
Dear all,
Does anyone have any idea on how to speed up the for() loop below.
Currently it takes approximately 2 minutes and 30 seconds.
Because of the size of Nsim and N, simulating a multivariate normal
(instead of simulating Nsim times a vector of N normal distributions)
would require too much memory space.
Many thanks for your kind help,
Simona
N=3000
PD=runif(N,0,1)
cutoff.=qnorm(PD)
2008 Feb 17
1
random location in polygons sp spsample splancs csr
Dear all,
I had to place points at random, one in each of larger number of
polygons (actually in objects of class 'SpatialPolygonsDataFrame' , see
sp library), and tried first to do it using spsample (from sp).
Surprisingly, every 5-15 trials, the output was a NULL value. The doc
says that ' this may occur when trying to hit a small and awkwardly
shaped polygon in a large
2007 Nov 30
0
How to Compute envelope of Khat in Splancs Package
Howdy Gurus
I am try to compute envelope of Khat from simulations of complete spatial
randomness using R package of "Splancs."
I got the following error:
> UL.khat <- Kenv.csr(length(X_coord), bnd, nsim=100, s)
Doing simulation 1
Error in runif(n, min, max) : invalid arguments
In addition: Warning message:
NAs introduced by coercion
I think that I have a problem with
2004 Sep 22
2
dot density maps
Dear All,
In the moment i'm using the map and maptools package to read shapefiles
and display the maps.
I'm looking for the possibility to draw points (randomly positioned or
positioned according to a grid) into the polygons instead of filling the
polygons with colors.
For example:
a map (shapefile) with 10 countries, 15 points in the polygon of country
A, 20 points in the
2007 Oct 03
2
Speeding up simulation of mean nearest neighbor distances
I've written the function below to simulate the mean 1st through nth
nearest neighbor distances for a random spatial pattern using the
functions nndist() and runifpoint() from spatsat. It works, but runs
relatively slowly - would appreciate suggestions on how to speed up
this function. Thanks. --Dale
library(spatstat)
sim.nth.mdist <- function(nth,nsim) {
D <- matrix(ncol=nth,
2005 Sep 16
1
Question:manipulating spatial data using combination of Maptools and Splancs
Hi,
I have a problem that concerns combination of the package Maptools and
Splancs
I have 2 shapefiles that i want to manipulate (one of type point and one
polygon).I import them in R using Maptools but then i can't estimate a
quartic Kernel using Splancs. The package doesn't recognize the shapes
(invalid points and poly argument).I don't know if this is an easy task but
i have
2010 Oct 13
1
(no subject)
Dear all,
I have just sent an email with my problem, but I think no one can see the red part, beacuse it is black. So, i am writing again the codes:
rm(list=ls()) #remove almost everything in the memory
set.seed(180185)
nsim <- 10
mresultx <- matrix(-99, nrow=1000, ncol=nsim)
mresultb <- matrix(-99, nrow=1000, ncol=nsim)
N <- 200
I <- 5
taus <- c(0.480:0.520)
h <-
2010 Oct 13
4
loop
Dear all,
I am trying to run a loop in my codes, but the software returns an error: "subscript out of bounds"
I dont understand exactly why this is happenning. My codes are the following:
rm(list=ls()) #remove almost everything in the memory
set.seed(180185)
nsim <- 10
mresultx <- matrix(-99, nrow=1000, ncol=nsim)
mresultb <- matrix(-99, nrow=1000, ncol=nsim)
N
2006 Jul 20
1
Loss of numerical precision from conversion to list ?
I?m working on an R-implementation of the simulation-based finite-sample null-distribution of (R)LR-Test in Mixed Models (i.e. testing for Var(RandomEffect)=0) derived by C. M. Crainiceanu and D. Ruppert.
I'm in the beginning stages of this project and while comparing quick and dirty grid-search-methods and more exact optim()/optimize()-based methods to find the maximum of a part of the
2010 Oct 07
3
quantile regression
Dear all,
I am a new user in r and I am facing some problems with the quantile regression specification. I have two matrix (mresultb and mresultx) with nrow=1000 and ncol=nsim, where I specify (let's say) nsim=10. Hence, the columns in my matrix represents each simulation of a determined variable. I need to regress each column of mresultb on mresultx. My codes are the following:
2011 Nov 07
1
How do I return to the row values of a matrix after computing distances
## Package Needed
library(fields)
## Assumptions
set.seed(123)
nsim<-5
p<-2
## Generate Random Matrix G
G <- matrix(runif(p*nsim),nsim,p)
## Set Empty Matraces dmax and dmin
dmax<- matrix(data=NA,nrow=nsim,ncol=p)
dmin<- matrix(data=NA,nrow=nsim,ncol=p)
## Loop to Fill dmax and dmin
for(i in 1:nsim) {
dmax[i]<- max(rdist(G[i,,drop=FALSE],G))
dmin[i]<-
2006 Mar 08
1
power and sample size for a GLM with Poisson response variable
Craig, Thanks for your follow-up note on using the asypow package. My
problem was not only constructing the "constraints" vector but, for my
particular situation (Poisson regression, two groups, sample sizes of
(1081,3180), I get very different results using asypow package compared
to my other (home grown) approaches.
library(asypow)
pois.mean<-c(0.0065,0.0003)
info.pois <-
2007 Dec 04
1
Metropolis-Hastings within Gibbs coding error
Dear list,
After running for a while, it crashes and gives the following error message: can anybody suggest how to deal with this?
Error in if (ratio0[i] < log(runif(1))) { :
missing value where TRUE/FALSE needed
################### original program ########
p2 <- function (Nsim=1000){
x<- c(0.301,0,-0.301,-0.602,-0.903,-1.208, -1.309,-1.807,-2.108,-2.71) # logdose
2009 Sep 02
1
problem in loop
Hi R-users,
I have a problem for updating the estimates of correlation coefficient in simulation loop.
I want to get the matrix of correlation coefficients (matrix, name: est) from geese by using loop(500 times) .
I used following code to update,
nsim<-500
est<-matrix(ncol=2, nrow=nsim)
for(i in 1:nsim){
fit <- geese(x ~ trt, id=subject, data=data_gee, family=binomial,
2002 Jan 25
2
selecting clusters of points
All:
Are there any functions out there for selecting all the
points in a region of a plot. I envision something like the
identify() function except one could circle a cloud of points (and
perhaps a vector would be returned of the same length as the points
plotted indicating logical membership in the circled cloud). Perhaps
someone has done something with the locator() function that would
2006 May 17
4
uniform and clumped point plots
I am trying to generate two dimensional random coordinates.
For randomly distributed data I have simply used
>xy<-cbind(runif(100),runif(100))
However I also want to generate coordinates that are more uniformly
distributed, and coordinates that are more contagiously distributed than
the above.
Can anyone make any suggestions
Thanks.
Dr Terry Beutel
Rangeland Scientist
Animal
2010 Nov 08
1
try (nls stops unexpectedly because of chol2inv error
Hi,
I am running simulations that does multiple comparisons to control.
For each simulation, I need to model 7 nls functions. I loop over 7 to do
the nls using try
if try fails, I break out of that loop, and go to next simulation.
I get warnings on nls failures, but the simulation continues to run, except
when the internal call (internal to nls) of the chol2inv fails.