我正在尝试将Gompertz增长模型拟合到以下数据,但它会产生错误。我的目标是了解如果遵循该功能的相同趋势,将来的销量将是多少。上限可能应该在11,000左右。
EV_temp<-structure(list(Country = structure(c(21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L), .Label = c("Australia",
"Brazil", "Canada", "Chile", "China", "Finland", "France", "Germany",
"India", "Japan", "Korea", "Mexico", "Netherlands", "New Zealand",
"Norway", "Others", "Portugal", "South Africa", "Sweden", "Thailand",
"Total", "United Kingdom", "United States"), class = "factor"),
Year = c(2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,
2013, 2014, 2015, 2016, 2017), TotalSales = c(1.89, 2.23,
2.69, 5.15, 7.48, 14.26, 61.33, 179.03, 381.3, 703.65, 1239.45,
1982.04, 3109.05)), row.names = c(NA, -13L), .Names = c("Country",
"Year", "TotalSales"), class = "data.frame")
EV.ss <- nls(TotalSales ~ SSgompertz(Year, Asym, b2, b3), data = EV_temp)
给出错误:
Error in qr.qty(QR.rhs, .swts * ddot(attr(rhs, "gradient"), lin)) :
NA/NaN/Inf in foreign function call (arg 5)