Skip to content

Instantly share code, notes, and snippets.

@isaactpetersen
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save isaactpetersen/6accd7211427b0827b7a to your computer and use it in GitHub Desktop.

Select an option

Save isaactpetersen/6accd7211427b0827b7a to your computer and use it in GitHub Desktop.
#Calculate shape and rate parameters of average projections for Weibull distribution
weibullShape <- fitdistr(projections$projectedPts, 'weibull')$estimate[[1]]
weibullScale <- fitdistr(projections$projectedPts, 'weibull')$estimate[[2]]
projectedPtsLatentWeibull <- qweibull(pnorm(projectedPtsLatent), shape=weibullShape, scale=weibullScale)
#Recale distribution to have same range as average projections
rescaleRange function(variable, minOutput, maxOutput){
minObserved min(variable)
maxObserved max(variable)
values (maxOutput-minOutput)/(maxObserved-minObserved)*(variable-maxObserved)+maxOutput
return(values)
}
projections$projectedPtsLatent <- rescaleRange(variable=projectedPtsLatentWeibull, minOutput=0, maxOutput=max(projections$projectedPts))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment