R 关于在minpack.LM包中使用NLS.LM的问题
我试图在R中使用minpack.lm包,特别是NLS.lm函数。我正在浏览手册和帮助文件,但是设置它的要求有点超出了我目前的能力。非常感谢您的指导。下面是我的代码和我得到的错误声明 R代码:R 关于在minpack.LM包中使用NLS.LM的问题,r,parameters,calibration,par,R,Parameters,Calibration,Par,我试图在R中使用minpack.lm包,特别是NLS.lm函数。我正在浏览手册和帮助文件,但是设置它的要求有点超出了我目前的能力。非常感谢您的指导。下面是我的代码和我得到的错误声明 R代码: # Thomas P. Taggart # ERE445/645 # Spring 2013 - Calibration Presentation # Lumped parameter rainfall-runoff model for the Susquehanna River at Conklin,
# Thomas P. Taggart
# ERE445/645
# Spring 2013 - Calibration Presentation
# Lumped parameter rainfall-runoff model for the Susquehanna River at Conklin, NY.
# Outlined in Haith's (1987) GWLF model. The model uses the SCS curve
# number runoff technique to determine runoff, with snowpack, unsaturated zone, and
# saturated zone mass balances. Evapotranspiration is to be determined using Hamon’s
# method with average monthly values for daylight hours.
# In this model we assume the following constants, which are determined through calibration:
# Baseflow Recession Coefficient, Kb
# Field capacity, FCAP
# Curve number for average moisture conditions, CN2
# Initial antecedent moisture conditions, iAMC
# Initial snow accumulation, iSNt
# Initial saturated zone storage, iSATt
# No deep groundwater seepage
# including needed functions
source("Functions.R")
source("distributionFunctions.R")
source("GWLF_Model.R")
require(ggplot2)
require(reshape)
library(minpack.lm)
library(scales)
###############################################################################################
# USGS Discharge data for Conklin, NY - Gage on the Susquehanna
# Reading in the input file
dischargeInput <- read.csv("USGS_DailyDischarge_ConklinNY_01503000_A.csv", header=TRUE)
###############################################################################################
# Weather Data
# Read in input file
weatherInput = read.csv("Conklin_NY_WeatherData_Edit.csv")
###############################################################################################
# Setting up the model inputs - inital Run
# Baseflow Recession, Kb
Kb <- 0.90
# Initial unsaturated storage is at field capacity, FCAP (cm)
FCAP <- 10
# Curve number for average moisture conditions, CN
CN <- 65.7
# Initial antecedent moisture conditions, AMC
AMC <- 1.5
# Initial saturated zone storage, SATt
iSATt <- 0.45
# Snowmelt constant, K
K <- 0.45
parameters <- c(Kb, FCAP,CN, AMC, iSATt, K)
# Calling the Model - 1st time to see the initial outputs
# GWLF(parameters, dischargeInput, weatherInput)
###############################################################################################
# Calibrating the model
guess <- c("Kb"=0.1, "FCAP"=1,"CN"=50, "AMC"=0, "iSATt"=0, "K"=0.5)
out <- nls.lm(par = guess, fn = GWLF(parameters, dischargeInput, weatherInput))
<>我需要如何设置PAR?还是我在nls.lm中调用的函数中的第一个参数?
正在向GWLf函数传递6个参数,这些参数在函数中用作常量。这是我希望校准的6个参数
谢谢,
汤姆从阅读
?nls.lm
您需要传递函数,而不是调用函数
out <- nls.lm(par = guess, fn = GWLF, dischargeInput, weatherInput)
out从读取?nls.lm
您需要传递函数,而不是调用函数
out <- nls.lm(par = guess, fn = GWLF, dischargeInput, weatherInput)
out MNEL,哇!!我几分钟前才让它工作,这正是我让它工作的方式。确切地我知道这个问题,我想知道为什么我的迭代在第二次之后停止(甚至认为图的数目表明它应该更高,然后两次迭代),以及为什么产生的PAR输出根本没有任何不同于最初的猜测值。除非你能提供一个可复制的例子,否则这将很难提供帮助!!我几分钟前才让它工作,这正是我让它工作的方式。确切地我知道这个问题,我想知道为什么我的迭代在第二次之后停止(甚至认为图的数目表明它应该更高,然后两次迭代),以及为什么产生的PAR输出根本没有任何不同于最初的猜测值。除非你能提供一个可复制的例子,否则这将很难提供帮助