Error in nls.multstart::nls_multstart(rate ~ beta_2012(temp = temp, a, : There must be as many parameter starting bounds as there are parameters

I’m using RStudio and trying to fit my data to a thermal performance curve model using rTPC, and keep encountering this error when trying to fit the data:

Error in nls.multstart::nls_multstart(rate ~ beta_2012(temp = temp, a, :
There must be as many parameter starting bounds as there are parameters.

Parameters to estimate: temp a b c d e
Parameters supplied as input data:
Number of parameters in start_lower: 5
Number of parameters in start_upper: 5

If there are parameters listed as input data which should be estimated,
this can be caused by variables in the environment/data with the same
name as model parameters.

rm(list=ls())
bug <- read.csv("earwigtimes.csv", header=TRUE)
df <- bug
df$Temperature <- as.factor(df$Temperature)
head(df)
library(ggplot2)

#examine data structure
str(bug)
bug$Treatment <- as.factor(bug$Treatment)
summary(bug)

mean(bug$Time) #3.296052
var(bug$Time) 
sd(bug$Time)

#check normality
par(row=c(1))
hist(bug$Time)
boxplot(bug$Time)
boxplot(Time ~ Treatment * Temperature, data = bug,
        xlab = "Temperature",
        ylab = "Time")
#Function to calculate the mean and sd
data_summary <- function(data, varname, groupnames){
  require(plyr)
  summary_func <- function(x, col){
    c(mean = mean(x[[col]], na.rm=TRUE),
      sd = sd(x[[col]], na.rm=TRUE))
  }
  data_sum<-ddply(data, groupnames, .fun=summary_func,
                  varname)
  data_sum <- rename(data_sum, c("mean" = varname))
  return(data_sum)
}

# Calculate mean and sd for each combination of Temperature and Treatment
bug2 <- data_summary(df, varname="Time", groupnames = c("Temperature", "Treatment"))

# Convert Time to a factor variable
bug2$Time <- as.factor(bug2$Time)

# Calculate standard deviation
bug2 <- ddply(df, .(Temperature, Treatment), summarise,
              mean_time = mean(Time, na.rm=TRUE),
              sd_time = sd(Time, na.rm=TRUE))

# Raw data plot with spline interpolation
pRaw <- ggplot(df, aes(x = Temperature, y = Time, group = Treatment, color = Treatment)) +
  geom_point(alpha = 0.7, size = 1.5, position = position_dodge(0.2)) +
  labs(title = "Activity per acclimation temperature", x = "Temperature (°C)", y = "Time to reach endpoint (seconds)") +
  scale_color_manual(values = c('#BA2BE5','#2BE59E'), labels = c("Stable", "Variable")) +
  theme_light()
print(pRaw)

#Plot of Means and Standard Error
pMeans <- ggplot(bug2, aes(x = Temperature, y = mean_time, group = Treatment, color = Treatment)) +
  geom_point(size - 1.5)+
  geom_errorbar(aes(ymin=mean_time - sd_time, ymax=mean_time + sd_time), width=.3, position=position_dodge(0.3)) +
  labs(title="Means and SD of activity per acclimation temperature", x="Temperature (°C)", y = "Time to reach dark zone (seconds)") +
  theme_light() +
  scale_color_manual(values=c('#BA2BE5','#2BE59E'), labels = c("Stable", "Variable"))
print(pMeans)

#rTPC
b <- subset(bug, Treatment == "c")

start_vals <- get_start_vals(b$Temperature, b$Time, model_name = "beta_2012")
mod <- nls.multstart::nls_multstart(rate~beta_2012(temp = temp, a, b, c, d, e),
                                    data = b,
                                    iter = c(7,7,7,7,7),
                                    start_lower = start_vals - 10,
                                    start_upper = start_vals + 10,
                                    lower = get_lower_lims(d$temp, d$rate, model_name = 'beta_2012'),
                                    upper = get_upper_lims(d$temp, d$rate, model_name = 'beta_2012'),
                                    supp_errors = 'Y',
                                    convergence_count = FALSE)

#linear model ggplot
ggplot(bug2,aes(x, y)) +
  geom_point() +
  geom_smooth(method='lm')


# Summary Statistics
summary(lm(Time ~ Temperature * Treatment, data = bug))



I’ve tried using other models and changing the start_lower and start_upper values but nothing’s helped.

New contributor

Felix Borrowdale is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật