This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# load packages | |
library(nlsLoop) | |
library(tidyverse) # just need dplyr | |
# load in data | |
data(Chlorella_TRC) | |
# fit nlsLoop object | |
fits <- nlsLoop(ln.rate ~ schoolfield.high(ln.c, Ea, Eh, Th, temp = K, Tc = 20), | |
data = Chlorella_TRC, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Test hypothesis that activation energy of community is determined from activation energies of its determinants | |
n = 3 | |
community <- data.frame(expand.grid(temp = seq(275, 305,0.5), curve = c(1:3))) | |
params <- data.frame(ln.c = c(1.5, 1, 0.5), | |
Ea = c(0.7, 0.5, 0.3), | |
Eh = rep(rnorm(n, 3, sd = 0.5)), | |
Th = c(rnorm(n, 300, sd = 2)), | |
curve = c(1,2,3)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# function to get confidence intervals | |
confint_nlsLoop <- function(x, params, data, id_col, formula, ...){ | |
dat <- data[data[,id_col] == x,] | |
params2 <- params[params[,id_col] == x,] | |
fit = NULL | |
try(fit <- minpack.lm::nlsLM(formula, | |
data = dat, | |
start = params2[colnames(params2) %in% all.vars(formula[[3]])]), silent = TRUE) | |
if(!is.null(fit)){ | |
confint <- nlstools::confint2(fit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
structure(list(lat = c(50.16996, 50.16887, 50.16943, 50.17204, | |
50.17247, 50.17227, 50.17302, 50.17354, 50.17365, 50.17249, 50.17205, | |
50.17442, 50.17689, 50.1767, 50.17634, 50.17601, 50.17592, 50.17549, | |
50.17402, 50.17379, 50.17314, 50.17323, 50.17566, 50.17714, 50.17919, | |
50.18199, 50.18284, 50.1838, 50.18447, 50.18505, 50.1849, 50.18843, | |
50.1909, 50.19203, 50.19184, 50.19247, 50.19406, 50.19381, 50.19416, | |
50.1958, 50.19621, 50.19623, 50.19792, 50.19717, 50.1982, 50.19857, | |
50.19901, 50.19888, 50.19992, 50.20095, 50.19956, 50.19857, 50.1974, | |
50.19619, 50.19529, 50.19273, 50.19154, 50.1862, 50.18248, 50.18177, | |
50.17728, 50.17513, 50.17383, 50.17108, 50.17116, 50.17228, 50.17224, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(tidyr) | |
# create dummy data | |
Class <- rep(seq(1,3,1),2) | |
Count <- runif(length(Class),50,100) | |
Quad_ID <- c(rep("A",3),rep("B",3)) | |
x <- data.frame(Class,Count,Quad_ID) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# load package | |
library(nlsLoop) | |
library(nlme) | |
library(ggplot2) | |
library(dplyr) | |
# create dummy data | |
example <- data.frame(expand.grid(K = 280:330, rep = 1:3)) | |
# create dummy params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# good coding practice #### | |
# 1. #hashtag your code so you know what it does | |
# 2. clear workspace and load packages at the top to keep track of what you have loaded | |
# 3. make sure your working directory is in the right place | |
# 4. space things out in a way that makes your code readable to you | |
# 5. google things you do not understand. The answers are out there, go find them | |
# 6. do not get scared/angry when you get errors. It does get easier.... eventually | |
# clear workspace #### Good code practice to do first | |
rm(list = ls()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example of a VERY simple binomial regression #### | |
# good coding practice (in my opinion anyway!) #### | |
# 1. #hashtag your code so you know what it does | |
# 2. clear workspace and load packages at the top to keep track of what you have loaded | |
# 3. make sure your working directory is in the right place | |
# 4. space things out in a way that makes your code readable to you | |
# 5. google things you do not understand. The answers are out there, go find them | |
# 6. do not get scared/angry when you get errors. It does get easier.... eventually |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# good coding practice #### | |
# 1. #hashtag your code so you know what it does | |
# 2. clear workspace and load packages at the top to keep track of what you have loaded | |
# 3. make sure your working directory is in the right place | |
# 4. space things out in a way that makes your code readable to you | |
# 5. google things you do not understand. The answers are out there, go find them | |
# 6. do not get scared/angry when you get errors. It does get easier.... eventually | |
# clear workspace #### Good code practice to do first | |
rm(list = ls()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# good coding practice #### | |
# 1. #hashtag your code so you know what it does | |
# 2. clear workspace and load packages at the top to keep track of what you have loaded | |
# 3. make sure your working directory is in the right place | |
# 4. space things out in a way that makes your code readable to you | |
# 5. google things you do not understand. The answers are out there, go find them | |
# 6. do not get scared/angry when you get errors. It does get easier.... eventually | |
# clear workspace #### Good code practice to do first | |
# need to install mise first! |
OlderNewer