Description Usage Arguments Details Value See Also Examples
Calculates the log-likelihood multiplied by negative one. It is in a format that can be used with the functions nlm
and optim
.
1 |
params |
a vector of revised parameter values. |
object |
an object of class |
pmap |
a user provided function mapping the revised parameter values |
SNOWcluster |
an object of class |
This function can be used with the two functions nlm
and optim
(see “Examples” below) to maximise the likelihood function of a model specified in object
. Both nlm
and optim
are minimisers, hence the “negative” log-likelihood. The topic distribution
gives examples of their use in the relatively easy situation of fitting standard probability distributions to data assuming independence.
The maximisation of the model likelihood function can be restricted to be over a subset of the model parameters. Other parameters will then be fixed at the values stored in the model object
. Let Theta_0 denote the full model parameter space, and let Theta denote the parameter sub-space (Theta subseteq Theta_0) over which the likelihood function is to be maximised. The argument params
contains values in Theta, and pmap
is assigned a function that maps these values into the full model parameter space Theta_0. See “Examples” below.
The mapping function assigned to pmap
can also be made to impose restrictions on the domain of the parameter space Theta so that the minimiser cannot jump to values such that Theta not subseteq Theta_0. For example, if a particular parameter must be positive, one can work with a transformed parameter that can take any value on the real line, with the model parameter being the exponential of this transformed parameter. Similarly a modified logit like transform can be used to ensure that parameter values remain within a fixed interval with finite boundaries. Examples of these situations can be found in the topic distribution
and the “Examples” below.
Value of the log-likelihood times negative one.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # SRM: magnitude is iid exponential with bvalue=1
# maximise exponential mark density too
TT <- c(0, 1000)
bvalue <- 1
params <- c(-2.5, 0.01, 0.8, bvalue*log(10))
x <- mpp(data=NULL,
gif=srm_gif,
marks=list(dexp_mark, rexp_mark),
params=params,
gmap=expression(params[1:3]),
mmap=expression(params[4]),
TT=TT)
x <- simulate(x, seed=5)
allmap <- function(y, p){
# map all parameters into model object
# transform exponential param so it is positive
y$params[1:3] <- p[1:3]
y$params[4] <- exp(p[4])
return(y)
}
params <- c(-2.5, 0.01, 0.8, log(bvalue*log(10)))
z <- nlm(neglogLik, params, object=x, pmap=allmap,
print.level=2, iterlim=500, typsize=abs(params))
print(z$estimate)
# these should be the same:
print(exp(z$estimate[4]))
print(1/mean(x$data$magnitude))
|
iteration = 0
Step:
[1] 0 0 0 0
Parameter:
[1] -2.5000000 0.0100000 0.8000000 0.8340324
Function Value
[1] 659.9456
Gradient:
[1] -5.928379 -1170.384894 71.604123 14.570224
iteration = 1
Step:
[1] 5.201796e-03 1.643108e-05 -6.433620e-03 -1.422884e-03
Parameter:
[1] -2.49479820 0.01001643 0.79356638 0.83260956
Function Value
[1] 659.6774
Gradient:
[1] 4.5300702 87.8470420 0.6083668 14.1727108
iteration = 2
Step:
[1] -3.593370e-03 -6.767461e-08 -5.091879e-04 -1.479811e-03
Parameter:
[1] -2.49839157 0.01001636 0.79305719 0.83112975
Function Value
[1] 659.6407
Gradient:
[1] 4.2561258 55.9729822 0.5129374 13.7598933
iteration = 3
Step:
[1] -7.805398e-02 7.432114e-06 -1.111875e-02 -3.322105e-02
Parameter:
[1] -2.5764456 0.0100238 0.7819384 0.7979087
Function Value
[1] 659.2327
Gradient:
[1] -1.063755 -554.541070 -4.398265 4.651332
iteration = 4
Step:
[1] -2.531490e-03 8.315869e-06 -1.066273e-04 -1.953776e-03
Parameter:
[1] -2.57897704 0.01003211 0.78183182 0.79595492
Function Value
[1] 659.2229
Gradient:
[1] -1.303040 -582.926165 -3.514327 4.125008
iteration = 5
Step:
[1] -0.0116918864 0.0001086185 0.0009217669 -0.0165377236
Parameter:
[1] -2.59066893 0.01014073 0.78275358 0.77941720
Function Value
[1] 659.1426
Gradient:
[1] -1.9795075 -653.6987340 2.0315584 -0.2891071
iteration = 6
Step:
[1] 2.788796e-03 9.407412e-05 2.199659e-03 -8.507064e-03
Parameter:
[1] -2.5878801 0.0102348 0.7849532 0.7709101
Function Value
[1] 659.1002
Gradient:
[1] -1.136052 -539.374119 3.581083 -2.531468
iteration = 7
Step:
[1] 9.372588e-03 6.882755e-05 2.323539e-03 -2.284388e-03
Parameter:
[1] -2.57850754 0.01030363 0.78727678 0.76862575
Function Value
[1] 659.0795
Gradient:
[1] 0.3957093 -343.4770434 2.1458004 -3.1303636
iteration = 8
Step:
[1] 4.276699e-03 1.607381e-05 7.044899e-04 1.491925e-03
Parameter:
[1] -2.57423084 0.01031971 0.78798127 0.77011767
Function Value
[1] 659.0744
Gradient:
[1] 1.0779264 -257.8607863 0.6062309 -2.7393823
iteration = 9
Step:
[1] 2.383413e-03 1.786278e-05 4.984051e-04 2.063240e-03
Parameter:
[1] -2.57184743 0.01033757 0.78847968 0.77218091
Function Value
[1] 659.0685
Gradient:
[1] 1.6062230 -190.4342876 -0.7484554 -2.1977170
iteration = 10
Step:
[1] 8.770413e-05 5.204594e-05 7.136372e-04 3.492914e-03
Parameter:
[1] -2.57175973 0.01038961 0.78919331 0.77567382
Function Value
[1] 659.054
Gradient:
[1] 2.356700 -89.669616 -2.771936 -1.278166
iteration = 11
Step:
[1] -0.0087919889 0.0001449389 0.0010325703 0.0054219759
Parameter:
[1] -2.58055172 0.01053455 0.79022588 0.78109580
Function Value
[1] 659.0193
Gradient:
[1] 3.3640291 59.5051798 -5.5900995 0.1556105
iteration = 12
Step:
[1] -0.0329950790 0.0003512377 0.0012564184 0.0071574904
Parameter:
[1] -2.61354680 0.01088579 0.79148230 0.78825329
Function Value
[1] 658.9446
Gradient:
[1] 4.384402 248.740327 -8.674504 2.060267
iteration = 13
Step:
[1] -0.0745867247 0.0006407748 0.0007195355 0.0055220778
Parameter:
[1] -2.68813352 0.01152657 0.79220184 0.79377537
Function Value
[1] 658.8245
Gradient:
[1] 4.612149 396.160988 -10.375437 3.539074
iteration = 14
Step:
[1] -0.0950289466 0.0006848962 -0.0008525547 -0.0018243830
Parameter:
[1] -2.78316247 0.01221146 0.79134928 0.79195098
Function Value
[1] 658.7114
Gradient:
[1] 3.402626 377.076041 -9.672361 3.049603
iteration = 15
Step:
[1] -0.0543309995 0.0002963851 -0.0014416003 -0.0068705168
Parameter:
[1] -2.83749347 0.01250785 0.78990768 0.78508047
Function Value
[1] 658.6608
Gradient:
[1] 1.271483 170.303417 -3.756151 1.214276
iteration = 16
Step:
[1] -6.382666e-03 -3.142795e-05 -9.828394e-04 -3.948745e-03
Parameter:
[1] -2.84387613 0.01247642 0.78892484 0.78113172
Function Value
[1] 658.6525
Gradient:
[1] 0.1997653 33.8622689 -1.0065591 0.1651361
iteration = 17
Step:
[1] 3.858635e-03 -4.174551e-05 -7.458873e-05 -6.164115e-04
Parameter:
[1] -2.84001750 0.01243467 0.78885025 0.78051531
Function Value
[1] 658.6522
Gradient:
[1] -0.05105596 -5.08692259 0.47544177 0.00173577
iteration = 18
Step:
[1] 1.000024e-03 -1.013311e-05 -8.634215e-05 -3.239105e-05
Parameter:
[1] -2.83901747 0.01242454 0.78876391 0.78048292
Function Value
[1] 658.6522
Gradient:
[1] 0.020591006 2.551446689 -0.308604058 -0.006847934
iteration = 19
Step:
[1] 1.422043e-05 1.370460e-06 4.191556e-05 2.655909e-05
Parameter:
[1] -2.83900325 0.01242591 0.78880583 0.78050948
Function Value
[1] 658.6522
Gradient:
[1] -0.0008006524 -0.1052521167 0.0026150815 0.0001901522
iteration = 20
Parameter:
[1] -2.83900171 0.01242595 0.78880640 0.78050914
Function Value
[1] 658.6522
Gradient:
[1] -7.468328e-05 -9.066805e-03 2.583533e-04 1.011419e-04
Relative gradient close to zero.
Current iterate is probably solution.
[1] -2.83900171 0.01242595 0.78880640 0.78050914
[1] 2.182583
[1] 2.182583
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.