使数据适合R中的逻辑功能

时间:2018-11-28 21:26:08

标签: r

我正在尝试将BEV和PHEV的全球销售数据调整为逻辑增长函数。

例如,我正在使用R-code for Logistic Growth Model of Australian Population in R (by Elise Gould)

但是用这种方法我得到了错误:

  

qr.default(.swts * gr)中的错误:     外部函数调用中的NA / NaN / Inf(arg 1)   另外:警告消息:   在Ops.factor(xmid,input)中:“-”对因子没有意义

我的数据是:

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 = structure(1:13, .Label = c("2005", "2006", "2007", 
"2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", 
"2016", "2017"), class = "factor"), 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)), class = "data.frame", row.names = c(NA, 
-13L), .Names = c("Country", "Year", "TotalSales"))

代码:

EV.ss <- nls(TotalSales ~ SSlogis(Year, phi1, phi2, phi3), data = EV_temp)

如果有人可以指出正确的方向来解决这个问题,将不胜感激。

0 个答案:

没有答案