r - Fiting 2-parameters weibull distribution for tabulated data -


i'm trying adjust weibull distribution 1 tabulated data. after process point cloud, columns number of returns each 1-meter slices of height. example:

a = matrix(c(7,12,10,10,20,3,15,40,33,57,58,60,79,132,174,201,191,184,115,70,22,2,0),1,23) colnames(a) <- c(13.5,14.5,15.5,16.5,17.5,18.5,19.5,20.5,21.5,22.5,23.5,24.5,25.5,26.5,27.5,28.5,29.5,30.5,31.5,32.5,33.5,34.5,35.5) 

in example above, height class center 13.5 meters has 7 points inside.

if plot matrix possible visualize data distribution:

barplot(a) 

enter image description here

does have suggestion how fit weibull 2-paramters tabulated data?

thanks in advance!

you maximum likelihood on censored data.

a = matrix(c(7,12,10,10,20,3,15,40,33,57,58,60,79,132,174,201,191,184,115,70,22,2,0),1,23) colnames(a) <- c(13.5,14.5,15.5,16.5,17.5,18.5,19.5,20.5,21.5,22.5,23.5,24.5,25.5,26.5,27.5,                  28.5,29.5,30.5,31.5,32.5,33.5,34.5,35.5)   centers <- as.numeric(colnames(a)) low <- centers - .5 <- centers + .5  ll.weibullcensored <- function(par, dat){     shape <- par[1]     scale <- par[2]     # probability each 'bin' , take log     log.ps <- log(pweibull(up, shape, scale) - pweibull(low, shape, scale))     # sum logs of bin probabilities many times     # should dictated data     sum(rep(log.ps, dat)) }  # use optim or other function find set # of parameters maximizes log likelihood o.optim <- optim(c(9, 28),                   ll.weibullcensored,                   dat = as.numeric(a),                   # tells find max instead of min                  control=list(fnscale=-1))   

this gives same estimates andrest approach assume of data fell in center of bins , perform maximum likelihood on imputed data set. doesn't make of difference method don't need other packages.

edit: fact andrest's solution , mine give estimates very similar makes lot of sense if @ we're maximizing each of methods. in mine we're looking @ probability of falling each of 'bins'. andret's solution uses density of distribution @ center of bin replacement probability. can @ ratio of probability of falling bin , density value in center of bin each of bins (using shape , scale obtained solution) gives:

# probability of each bin > ps  [1] 0.0005495886 0.0009989085 0.0017438767 0.0029375471 0.0047912909  [6] 0.0075863200 0.0116800323 0.0174991532 0.0255061344 0.0361186335 [11] 0.0495572085 0.0656015797 0.0832660955 0.1004801353 0.1139855466 [16] 0.1197890284 0.1144657811 0.0971503491 0.0711370586 0.0433654456 [21] 0.0210758647 0.0077516837 0.0020274896 # density evaluated @ center of bin > ps.cent  [1] 0.0005418957 0.0009868040 0.0017254545 0.0029103746 0.0047524364  [6] 0.0075325510 0.0116083397 0.0174078328 0.0253967142 0.0359988789 [11] 0.0494450583 0.0655288551 0.0832789134 0.1006305707 0.1143085230 [16] 0.1202647955 0.1149865305 0.0975322358 0.0712125315 0.0431169222 [21] 0.0206762531 0.0074246320 0.0018651941 # ratio of probability , density > ps/ps.cent  [1] 1.0141963 1.0122663 1.0106767 1.0093364 1.0081757 1.0071382 1.0061760  [8] 1.0052459 1.0043084 1.0033266 1.0022682 1.0011098 0.9998461 0.9985051 [15] 0.9971745 0.9960440 0.9954712 0.9960845 0.9989402 1.0057639 1.0193271 [22] 1.0440495 1.0870127 

all of these ratios close 1 - 2 methods trying maximize same likelihood.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -