Repository navigation
Expand file tree
/
Copy pathREADME.Rmd
More file actions
97 lines (76 loc) · 3.56 KB
/
Copy pathREADME.Rmd
File metadata and controls
97 lines (76 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# logisticat
<!-- badges: start -->
<!-- badges: end -->
The goal of logisticat is to ...
## Installation
There are two ways you could use this package. The "normal" way is to install
the development version of logisticat from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("Ergative/logisticat")
```
You can then uninstall it with:
``` r
remove.packages("logisticat")
```
The other way to use this package is to download the single .R file implementing
the whole package, which gets automatically generated and put in
[/generated/logisticat-single-file.R](https://github.com/Ergative/logisticat/blob/master/generated/logisticat-single-file.R).
You can then put this file wherever you want and source it using RStudio or
`source("logisticat-single-file.R")`.
## Example
Say you wanted to know whether feeding sea urchin larvae higher rations of food
enables them to develop to metamorphosis more quickly.
You run an experiment with two food ration treatments and three replicate
beakers of larvae per treatment. You sample several larvae per beaker each
day and record what number metamorphose.
The below code will plot curves estimating the progress of each beaker of larvae
towards becoming metamorphically competent as a whole population. These curves
are constructed from logistic regressions.
If we are interested in comparing the time at which each treatment reached 50%
metamorphosis, we can specify that as our "probability.of.interest" and
get inverse predictions from the logistic regression.
```{r example}
library(logisticat)
# Load example dataset.
# This is data from a hypothetical experiment, where echinoid larvae were raised
# on two rations of food, with the goal of comparing the time larvae in each
# ration treatment took to develop enough to metamorphose.
metamorphosis.data <- metamorphosis()
# Each ration treatment has several replicate beakers, from which a number of
# larvae were tested for metamorphosis each day.
# The number of larvae that succeeded or failed in each trial is listed.
head(metamorphosis.data)
# We want to determine how long it took larvae in each of the two food ration
# treatments to reach 50% metamorphic competence. This can be visualized
# by plotting a logistic regression and seeing where the curve intersects a
# horizontal line at 0.5.
gglogistic(metamorphosis.data,
predictor = days, # x-axis
success.counts = metamorphosed, # number of successes per trial
failure.counts = did.not.metamorphose,# number of failures per trial
treatment = ration, # column representing treatment
replicate = beaker, # column representing replicate
probability.of.interest = 0.5, # y-axis value to find.
# Extra options for customization.
line.var = "both", # See curves for treatment and replicates.
point.var = "replicate", # Points per replicate.
inverse.var = "treatment", # Per-treatment inverse predictions.
jitter.width = 0.2, # Jitter points a bit.
xlabel = "Days post fertilization",
ylabel = "Metamorphic competence",
treatment.colors = c("low" = "#4393C3",
"high" = "#5AAE61"))
```