我刚才问了这个问题.我不确定是否应将此作为答案或新问题发布.我没有答案但是我通过nls.lm在R中应用Levenberg-Marquardt算法"解决"了这个问题,当解决方案在边界时,我运行信任区域反射算法(TRR,在R中实现)来执行远离它.现在我有了新的问题.
根据我的经验,以这种方式,程序达到最佳状态,并且对起始值不那么敏感.但这只是一种实用的方法,可以解决我遇到的问题nls.lm以及R中的其他优化函数.我想知道为什么nls.lm这种方式对于边界约束的优化问题以及如何nls.lm在实践中使用时处理边界约束.
下面我举例说明使用的两个问题nls.lm.
library(devtools)
install_github("KineticEval","zhenglei-gao")
library(KineticEval)
data(FOCUS2006D)
km <- mkinmod.full(parent=list(type="SFO",M0 = list(ini = 0.1,fixed = 0,lower = 0.0,upper =Inf),to="m1"),m1=list(type="SFO"),data=FOCUS2006D)
system.time(Fit.TRR <- KinEval(km,evalMethod = 'NLLS',optimMethod = 'TRR'))
system.time(Fit.LM <- KinEval(km,evalMethod = 'NLLS',optimMethod = 'LM',ctr=kingui.control(runTRR=FALSE)))
compare_multi_kinmod(km,rbind(Fit.TRR$par,Fit.LM$par))
dev.print(jpeg,"LMvsTRR.jpeg",width=480)
Run Code Online (Sandbox Code Playgroud)

描述模型/系统的微分方程是:
"d_parent = - k_parent * parent"
"d_m1 = - k_m1 * m1 + k_parent * f_parent_to_m1 * parent"
Run Code Online (Sandbox Code Playgroud)
在左边的图中是带有初始值的模型,中间是使用"TRR"的拟合模型(类似于Matlab lsqnonlin函数中的算法),右边是使用"LM"的拟合模型nls.lm.查看拟合参数(Fit.LM$par),您会发现一个拟合参数(f_parent_to_m1)位于边界处1.如果我将一个参数的起始值 …
我正在使用瘦Oracle JDBC驱动程序版本10.2.0(ojdbc14.jar).我想手动配置其NLS_LANG设置.有办法吗?
目前,它从VM变量user.language(通过设置当前区域设置或从系统环境启动时自动设置)获取此设置.
当用户将应用程序区域设置切换到Oracle JDBC驱动程序不支持的区域设置(例如mk_MK)时,这是一个问题.在这种情况下,下次我获取连接时,我得到以下异常:
ORA-00604: error occurred at recursive SQL level 1 ORA-12705: Cannot access NLS data files or invalid environment specified
我可以在获取连接之前动态更改语言环境,然后来回切换回用户选择的语音,但这看起来不那么优雅且效率低下.
R包ggpmisc可用于显示lm模型和poly模型的方程ggplot2(参见此处参考).想知道如何使用nls模型方程结果.以下是我的MWE.ggplot2ggmisc
library(ggpmisc)
args <- list(formula = y ~ k * e ^ x,
start = list(k = 1, e = 2))
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
stat_fit_augment(method = "nls",
method.args = args)
Run Code Online (Sandbox Code Playgroud) 我在预测 r 中的置信区间 ros 和 nls 时遇到一些麻烦。
pl <- ggplot(data) + geom_point(aes(x=date, y=cases),size=2, colour="black") + xlab("Date") + ylab("Cases")
model = nls(cases ~ SSlogis(log(date), Asym, xmid, scal), data= data )
new.data = data.frame(date=c(1:100))
interval <- predict(model, newdata = new.data, se.fit = TRUE, interval = "confidence", level= 0.9)
new.data[c("fit","lwr.conf", "upr.conf")] <- interval
pl +
geom_ribbon(data=new.data, aes(x=date, ymin=lwr.pred, ymax=upr.pred), alpha=0.05, inherit.aes=F, fill="blue")
Run Code Online (Sandbox Code Playgroud)
当我运行它时,它没有显示错误,但我得到的区间只是一个拟合向量,没有上置信区间和下置信区间。
我在我的j2ee Web应用程序中遇到此错误.
java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-12705: Cannot access NLS data files or invalid environment specified
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:283)
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:278)
oracle.jdbc.driver.T4CTTIoauthenticate.receiveOauth(T4CTTIoauthenticate.java:785)
oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:376)
oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:441)
oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:839)
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1353)
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1353)
Run Code Online (Sandbox Code Playgroud)
这个项目在我同事的电脑上工作......我的意思是这个项目对他们有效,但当我要求他们的项目文件夹并将其导入我的日食时,当我运行它时,我遇到了这个错误.jar文件已与项目文件夹一起打包.
我还使用hibernate创建了一个简单的j2ee项目,但我遇到了同样的错误.我试图ping数据库服务器并使用PL/SQL开发人员浏览它,我没有任何问题
我有几个似乎有对数关系的数据点(x和y).
> mydata
x y
1 0 123
2 2 116
3 4 113
4 15 100
5 48 87
6 75 84
7 122 77
> qplot(x, y, data=mydata, geom="line")
Run Code Online (Sandbox Code Playgroud)

现在我想找到一个适合图形的基础函数,并允许我推断其他数据点(即3或82).我读到了lm,nls但我真的没有到达任何地方.
起初,我创建了一个函数,我认为它最像是情节:
f <- function(x, a, b) {
a * exp(b *-x)
}
x <- seq(0:100)
y <- f(seq(0:100), 1,1)
qplot(x,y, geom="line")
Run Code Online (Sandbox Code Playgroud)

之后,我尝试使用nls以下方法生成拟合模型:
> fit <- nls(y ~ f(x, a, b), data=mydata, start=list(a=1, b=1))
Error in numericDeriv(form[[3]], names(ind), env) …Run Code Online (Sandbox Code Playgroud) 我的dojo应用程序在构建之后中断,在加载应用程序期间,抛出'multipleDefine'并给出此错误:
错误{src:"dojoLoader",info:Object}
消息:multipleDefine
info:Object {pid:"dojo",mid:"dojo/nls/dojo_en-us",pack:Object,url:"dojo/nls/dojo_en-us.js",执行:5 ...}
这是我的个人资料:
var profile = {
// `basePath` is relative to the directory containing this profile file; in this case, it is being set to the
// src/ directory, which is the same place as the `baseUrl` directory in the loader configuration. (If you change
// this, you will also need to update run.js.)
basePath: '../src/',
// This is the directory within the release directory where built packages will be placed. The release directory
// …Run Code Online (Sandbox Code Playgroud) 我试图在下面的数据(尾部)上拟合一条曲线:
[1] 1 1 1 1 1 1 2 1 2 2 3 2 1 1 4 3 2 11 6 2 16 7 17 36 [25] 27 39 41 33 42 66 92 138 189 249 665 224 309 247 641 777 671 532 749 506 315 292 281 130 [49] 137 91 40 27 34 19 1
我在R中使用以下函数来完成此任务:
nls(y~a x exp(-b*x ^ 2),start = list(a = 1,b = 1),trace = TRUE)
但是,我收到以下错误:
3650202:1 1
numericDeriv中的错误(表单[[3L]],名称(ind),env):评估模型时产生的缺失值或无穷大
当使用以下,x和y的人工值时,一切正常:
Y = …
Oracle 11.2.0.3.0,APEX 4.1.1.00.23.
我们需要在我们的应用程序中显示数字,格式FM999999999990.000和日期格式为英文DD-MON-YYYY.
即使应用程序语言将要改变(法语,西班牙等),我们总是需要这种格式的数字(组分隔符没有空格或逗号,小数分隔符的点,即-1254.010)和日期(3)英文月份名称的第一个字母,即12-FEB-2012).
以下是我们正在使用的全球化属性(Application Builder - > Application - > Edit Globalization Attributes):
我无法让它按预期工作......我仍然得到数字-1254,01和日期12-FÉVR.-2012而不是-1254.010和12-FEB-2012.似乎APEX忽略任何改变会话的调用......
我试图在" 初始化PL/SQL代码 "属性(应用程序生成器 - >应用程序 - >编辑安全属性)中输入以下代码,但没有任何成功:
BEGIN
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_NUMERIC_CHARACTERS= ''.,'' ';
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_DATE_LANGUAGE = ''AMERICAN'' ';
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_LANGUAGE = …Run Code Online (Sandbox Code Playgroud) 我从包中使用nls.lmminpack.lm来适应很多非线性模型.
由于初始参数估计处的奇异梯度矩阵,它经常在20次迭代后失败.
问题是当我在failling(trace = T)之前看一下迭代时我可以看到结果没问题.
可重复的例子:
数据:
df <- structure(list(x1 = c(7L, 5L, 10L, 6L, 9L, 10L, 2L, 4L, 9L, 3L,
11L, 6L, 4L, 0L, 7L, 12L, 9L, 11L, 11L, 0L, 2L, 3L, 5L, 6L, 6L,
9L, 1L, 7L, 7L, 4L, 3L, 13L, 12L, 13L, 5L, 0L, 5L, 6L, 6L, 7L,
5L, 10L, 6L, 10L, 0L, 7L, 9L, 12L, 4L, 5L, 6L, 3L, 4L, 5L, 5L,
0L, 9L, 9L, 1L, 2L, 2L, 13L, 8L, 2L, …Run Code Online (Sandbox Code Playgroud)