Alice
Alice C. HughesAssociate ProfessorCentre for Integrative
Conservation,Xishuangbanna Tropical Botanical Garden,Chinese Academy of
SciencesMenglun, Mengla, Yunnan 666303, P.R. ChinaPh:
[email protected]
Date: Mon, 6 May 2013 14:33:29 +1000
Subject: Re: [Trop-R] Kernel Density Estimation Bootstrap
From: [email protected]
To: [email protected]
Hi Christian,
This formatting shows that the data has been read in as a single column with
'V1' as the column name and 'x,y' as the value of row 1, and so on:
test<-read.table("test.csv")> test
V11 x,y
2 648501,89104003 641686,8917264
4 645984,89143285 647058,8913794
6 649659,89129257 649613,8912828
.....
You can check how many columns there are in a data frame using 'ncol':
ncol(test)
To troubleshoot, I would first try using read.csv:
test=read.csv(test,as.is=TRUE)ncol(test)
If this does not give you two columns, then I would check that the file really
is in standard .csv format.
Lauren
On Mon, May 6, 2013 at 1:17 PM, Christian Gredzens
<[email protected]> wrote:
Leila,
Thanks for your reply. I'm using likelihood cross validation (CVh) instead of
least squares cross validation (LSCV). To my knowledge adehabitatHR doesn't run
CVh so I think I will need to write a script or find another program which can
calculate CVh.
I used GME from spatialecology.com to calculate all of my KDEs, but I don't
think GME runs bootstrapping. So I'm trying to run it through the bootstrapping
package in R. Here is what I need to do:
1) Create my spatial points layer
=mydata
2) Run the bootstrapping script:
mydataboot<-boot(mydata, (KDE script), R=1000)
mydata= my spatial points file
(KDE script)= what formula to run the bootstrap on
R=1000 = the number of iterations I would like to run
The issue I'm having is getting the bootstrapping script to run the KDE
formula=(KDE script)
Cheers,
Christian
On Friday, May 3, 2013 12:58:55 AM UTC-7, Leila Brook wrote:
Hi Christian,
There is a package called adehabitatHR that does kernel density estimation with
LSCV bandwidth using a function called kernelUD(). I don't know if this will is
similar to what you want? You will need to have the data in UTM and in
SpatialPoints or SpatialPointsDataFrame format, which you can do using the sp
package.
There is a great vignette for adehabitatHR that will help with data formatting
and running the KDE. I exported the utilisation distribution for ArcGIS using
writeRaster() in the raster package, but you can also export as contours.
Cheers
Leila
________________________________________
From: [email protected] [[email protected]] on behalf of
Stewart Macdonald [[email protected]]
Sent: Friday, 3 May 2013 5:12 PM
To: [email protected]
Subject: Re: [Trop-R] Kernel Density Estimation Bootstrap
Hi Christian,
What sort of data are you trying to import? A series of lat/longs that are in a
text (or Excel) file? If so, the rGDAL library can be used to create spatial
points:
###############
library(rgdal)
# if you don't already have this installed, you can do:
install.packages('rgdal')
# read in the data from a tab-delimited text file that has a header line
rawPoints <- read.table('/data.csv', header=TRUE, sep='\t')
# format as a SpatialPoint class and define the projection/datum (WGS84)
q <- cbind(rawPoints$recordLon, rawPoints$recordLat)
colnames(q) <- c("x", "y")
qqq <- SpatialPoints(q, proj4string=CRS("+init=epsg:4326"))
###############
Note: the above is a copied-and-pasted fragment from a working script of mine.
I assume this fragment will work for you.
I can't help you with your second question, and the answer to your third
question will depend on the format of the bootstrap data (e.g., more points,
polygons, raster).
Hope this helps,
Stewart
On 03/05/2013, at 4:57 PM, Christian Gredzens <[email protected]>
wrote:
Hi All,
I would like to run a bootstrap within R on a spatial dataset using a kernel
density estimation function. Can anyone help me with this? I am new to R and
thus have very little experience. It seems relatively easy to run the actual
bootstrap but I am having problems in the following areas:
1) I don't know how to import spatial data into R and assign it an appropriate
projection
2) I need to setup a kernel function using a specific bandwidth (likelihood
cross-validation (CVh)) and create the script so it will run within the
bootstrap script
3) I need to export the bootstrap data as an ArcGIS 10 file.
Best Regards,
Christian Gredzens
Christian Gredzens
MSc Student
School of Marine and Tropical Biology
James Cook University
Townsville, QLD, Australia 4811
[email protected]
Phone: 04 3875 3652
--
An R group for questions, tips and tricks relevant to spatial ecology and
climate change.
All R questions welcome.
---
You received this message because you are subscribed to the Google Groups "Tropical
R" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send an email to [email protected].
To view this discussion on the web, visit
https://groups.google.com/d/msg/tropical-r/-/DgXQECjrCaoJ.
For more options, visit https://groups.google.com/groups/opt_out.
--
An R group for questions, tips and tricks relevant to spatial ecology and
climate change.
All R questions welcome.
---
You received this message because you are subscribed to the Google Groups "Tropical
R" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.