Wednesday, July 29, 2015

Tuesday, June 30, 2015

ggplot2 - Easy way to mix multiple graphs on the same page


http://www.sthda.com/english/wiki/ggplot2-easy-way-to-mix-multiple-graphs-on-the-same-page-r-software-and-data-visualization


http://cran.r-project.org/web/packages/cowplot/vignettes/plot_grid.html

Saturday, June 27, 2015

Geocoding in R


http://www.r-bloggers.com/batch-geocoding-with-r-and-google-maps-2/

Saturday, June 13, 2015

Saturday, June 6, 2015

Meta-analysis in ECOLOGY with R

Note: this post originated from my 


0. Data retrieval  from published studies:

This is the starting point, which determines all the following steps. Hence, it is very important to construct a clear protocol of 'data acquisition'.



1.Calculate 'effect size' and 'sampling variances'

This is a detailed introduction to the 'escalc' function in "metafor" package.
http://www.inside-r.org/packages/cran/metafor/docs/escalc

2. Data assumptions and normality test

Prior to do the analysis, it is essential to examine the data to see whether it is normally distributed and there are publication biases. These can be conducted by plotting a normal QQ plot:

-http://www.metafor-project.org/doku.php/plots:normal_qq_plots?s[]=publication&s[]=bias
-http://finzi.psych.upenn.edu/library/metafor/html/qqnorm.rma.html

However, "funnel plot"(Light & Pillemer, 1984) can only be functional for publication bias test. The shape of funnel plot can indicate whether a publication bias exists. As suggested by Wang and Bushman (1998), one difficulty is to identifying the shape of the 'funnel' plot. This, however, can be resolved by statistical asymmetry test.

Trim and fill: http://onlinelibrary.wiley.com/doi/10.1111/j.0006341X.2000.00455.x/abstract;jsessionid=B0A2647FC60DC8FF84EE4B944FD4BDAC.f01t01

Paper by Wang and Bushman (1998;http://psycnet.apa.org/journals/met/3/1/46/) has a good discussion on the pros and cons of 'funnel plot' and normal quantile QQ plot to examine data.

2. Do the Metaanalysis
When doing a meta-analysis, we can fit the data to a random-effects model. We can use both functions of rma () and rma.mv(). But the function "rma.mv" is originally designed for multi-level meta-analysis (http://www.inside-r.org/packages/cran/metafor/docs/rma.mv). However, note that when using the rma.mv() function, random effects must be explicitly added to the model via the random argument. For a standard random-effects model, we need to add random effects for the trials, which can be done with:


StackExchange Q/A about non-linear regression:
http://stats.stackexchange.com/questions/122196/nonlinear-meta-regression

3. Results visualization with "forest plot" using ggplot2
http://www.r-bloggers.com/forest-plots-using-r-and-ggplot2-3/



Finallly, here is an detailed introduction in doing metaanlysis with an ecology example:
https://rpubs.com/dylanjcraven/metaforr

Tuesday, April 28, 2015

Mosaic Rasters to a Seamless Raster


Step 1 Create Mosaic Raster from rasters

This actually can be further divided into two steps: 1) create a mosaic raster dataset; 2) add rasters to mosaic raster dataset. A lot of details should be noticed when working on these two seemingly straightforward steps. The following links redirect you to webpages that are showing how to perform the operations step by step ( if you have any problems, feel free to leave comments on this post):

http://resources.arcgis.com/en/help/main/10.1/index.html#/Creating_a_mosaic_dataset_containing_raster_data_from_multiple_dates/009t000000v1000000/

http://gishelper.com/resources/USING%20A%20MOSAIC%20DATASET%20TO%20ADD%20A%20HILLSHADE%20TO%20A%20SCANNED%20MAP.pdf

Possible problems that you would come across during your operation can be solved:

http://blogs.esri.com/esri/supportcenter/2011/10/07/imagery-not-displaying-in-your-mosaic-dataset/


Step 2 Create seamless Mosaic Raster

https://www.youtube.com/watch?v=qJHCbEVbMv0

For latest version of ArcGIS for DESKTOP, code as follows works well:
Con(IsNull("myraster"), FocalStatistics("myraster", NbrRectangle(2,2, "CELL"), "MEAN"), "myraster")