Skip to content

Commit

Permalink
Working on bonus homework problem
Browse files Browse the repository at this point in the history
  • Loading branch information
gjanee committed May 21, 2024
1 parent dbc6932 commit e0ed38d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions modules/hw_bonus.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,30 @@ title: "Homework Bonus"

## Relationship between egg volume and time of the year

One might wonder if egg volumes would be larger during warmer months. We don't have much data to work with using our database example, but we can leverage measurements for the months of June and July hypothesizing that July is warmer than June.
One might wonder if egg volumes are larger during warmer months. Indeed, in *Egg size variation within passerine clutches: effects of ambient temperature and laying sequence* [^1], the authors report that

Our ask:
[^1]: Mikko Ojanen, Markku Orell, and Risto A. Väisänen (1981). Egg size variation within passerine clutches: effects of ambient temperature and laying sequence. *Ornis Fennica* **58**:93-108. <https://ornisfennica.journal.fi/article/view/133071>

- Develop an SQL query to compute a table with the average egg volume per month (June & July) at each site (20pt)
> Slight but statistically significant positive correlations were detected between daily temperatures (mostly mean and minimum) and egg size. The first eggs of the clutch were often affected by the temperatures occurring about a week before they were laid. These temperatures probably influence the development of the insects from eggs and pupae providing protein for the egg-forming female. The last eggs of the clutch tended to be affected by the temperatures prevailing one to three days before laying, i.e.occurring in the most intensive period of egg formation.
- Use you favorite programming language (R or Python) to create a plot (choosing the type of plot you think is the most appropriate) of average egg volume differences between June and July (in percentage) and try to answer the question about influence of temperature on egg volume (10pt)
There are multiple factors at play here, including clutch size and laying order, and we don't have much data to work with using our database example, but still, we can investigate if there is any change we can leverage measurements for the months of June and July hypothesizing that July is warmer than June.

## Step 1

Create a query to compute and group average egg volumes by species and month. As before, use for volume the formula

$${\pi \over 6} W^2 L$$

where $W$ is the egg width and $L$ is the egg length, and use 3.14 for $\pi$.

## Step 2

You'll notice that we have egg data for months 6 and 7, but there is one species for which there is only data for month 6. We want to exclude all such species. Doing so will require two queries. First, create a query that selects all those species having exactly 2 records in the above table; call this query Q. Then, create a query that selects the species in that set, i.e., `SELECT * FROM above_table WHERE Species IN (query Q)`.

Join this table with ? write to csv.

## Step 3

Use you favorite programming language (R or Python) to plot to create a plot (choosing the type of plot you think is the most appropriate) of average egg volume differences between June and July (in percentage) and try to answer the question about influence of temperature on egg volume (10pt). An example is shown below.

![](output-plot.png)
Binary file added modules/output-plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e0ed38d

Please sign in to comment.