简体   繁体   English

使用R函数“ nls”估算GEV参数

[英]Use R-function “nls” to estimate GEV parameters

I want to estimate the parameters of a GEV (generalized extreme value) distribution using the method of weighted least squares. 我想使用加权最小二乘法估算GEV(广义极值)分布的参数。 I use R, and I found a function called nls which I think might be used for this purpose. 我使用R,我发现了一个名为nls的函数,我认为可以将其用于此目的。 It asks for a formula and an optional dataset. 它要求一个公式和一个可选的数据集。 I guess the GEV formula and annual maxima series should in here, but I am not sure how. 我想GEV公式和年度最高数列应该在这里,但我不确定如何。 Has anyone used nls and has any idea on how to do this? 有没有人使用过nls,并且对此有任何想法?

#Vector of ranged annual maxima
x <- c(21,24,29,32,32,34,35,35,35,36,37,37,38,40,40,41,43,47,47,52)
w <- c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2)
data <- list(x=x,w=w)
nls(y ~ exp(-(1+((x-location)/scale))^(-1/shape)),data=data, weights=w,start=list(location=5,scale=2,shape=0.10))                 

The error says that y is missing. 该错误表明y缺失。 y is what we get when we optimize the GEV parameters, so that y becomes as close to x as possible for all x's (also depending on the weights). y是我们优化GEV参数时得到的结果,因此y对于所有x而言都尽可能地接近x(还取决于权重)。 So y is unknown until we have estimated the GEV parameters... 因此,在我们估计GEV参数之前,y是未知的。

As @Roland commented, you need to have two variables to do a regression. 正如@Roland所说,您需要有两个变量才能进行回归。 In this case, you only have one: the observed values for the GEV. 在这种情况下,您只有一个:GEV的观测值。 As such you don't actually want to fit the distribution using nls , but some other algorithm, for example maximum likelihood. 因此,您实际上并不想使用nls拟合分布,而是使用其他算法,例如最大似然。 See the package evd which has functions to deal with GEVs including fitting them from data. 请参阅evd软件包,该软件包具有处理GEV的功能,包括根据数据进行拟合。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM