Skip to content

Latest commit

 

History

History
111 lines (80 loc) · 5.18 KB

README.md

File metadata and controls

111 lines (80 loc) · 5.18 KB

PasitR

A collection of functions for use in the PASIT project group. Install using devtools::install_github("CWWhitney/pasitR")

Quick Links
Estimated yield given the expected chill
Chill portion intervals
Probability of yield given chill
Working with pasitR
pasitR Wiki

Functions

Data comprising related observations of chill and yield are used in all functions.

Using chillscatter() create a chill portions (x) and yield (y) scatter plot with associated and estimated densities with loess smooth linear fits density curves. Plot made with the scatter.hist() function in the plyr() package (Wickham 2011) in R (R Core Team 2017).

Use chillkernel() or another type of graphical representation of the same relationship. chillkernel() performs a two-dimensional kernel density estimation for yield and chill using the kde2d() function in the MASS() package (Venables and Ripley 2002). The function produces a matrix of the estimated density (z) of yield (y) and chill (x). As the density function restricts the shape of the kernel to a bivariate normal kernel, it looks slightly different compared to the scatter plot estimates above.

chillkernel() shows a density surface plot of chill portions (x) and yield (y). The legend shows the value for the estimated density (z). The plot is made with the filled.contour() function of the graphics() package.

In chillkernel() the density (z) over the entire plot integrates to one, and therefore represents the relative probability of an observation (yield along y-axis) given a specific chill portion (along x-axis).

Estimated yield given the expected chill

chillkernelslice() calculates the estimated yield given the expected chill, based on a slice of ‘z’ from the Kernel density calcualted with chillkernel(). The expectedchill parameter is set to 30.

chillkernelslice() plots the probabilities (shown along the y-axis) for the expected yield (shown along the x-axis). Since this is a cut through the density kernel chillkernel(), which integrates to 1, the probability values are relative, not absolute measures.

Chill portion intervals

chillviolin() determines different possible chill portion intervals by calculating the optimal interval width for chill portions using the IQR() function in the stats() package, after the Freedman-Diaconis rule (IQR = interquartile range). Optimal interval width for our sample = 2 * interquartile range for our sample / (total number of observations for the interquartile range for our sample)^(1/3)

chillviolin() shows violin plots of chill portions (x) and yield (y) with six different intervals of chill portions. Plot made with ggplot2() (Wickham 2016).

Probability of yield given chill

chillkernelslicerange() The chill portion intervals, optimized interquartile ranges shown in chillviolin() can be used to select a range to slice from the density kernel chillkernel() as was doen for a single chill value in chillkernelslice(). Here we set the maximum chill to 20 and the minimum to 10.

chillkernelslicerange() plots the probabilities (shown along the y-axis) for the expected yield (shown along the x-axis). As with chillkernelslice() the probability values shown are relative, not absolute measures. They are the result of cuts through the density kernel chillkernel(), which integrates to 1.

Create vignette

Create an Rmarkdown vignette using usethis::use_vignette()

Create online version of vignette

We created an online version of the vignette html by adding the prepend (http://htmlpreview.github.io/?) to the original URL http://htmlpreview.github.io/?https://github.com/hortibonn/pasitR/blob/master/vignettes/chill-yield-vignette.html

Change default data

To change the default data assign the data to an r object and use usethis::use_data(data, overwrite=TRUE)

References

R Core Team (2017) R: A Language and Environment for Statistical Computing [R Version 3.4.1 (2017-06-30) “Single Candle”] 3.4.1.

Venables, W. N., and B. D. Ripley (2002) Modern Applied Statistics with S. Fourth Edition. New York: Springer.

Wickham, Hadley (2011) Plyr: Tools for Splitting, Applying and Combining Data, Version 1.4. Available Online at Cran. r-Project. Elegant Graphics for Data Analysis. Springer.